1# Copyright (c) 2023 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("../../code_signature.gni") 16 17common_deps = [ 18 "${rust_openssl_dir}/openssl:lib", 19 "utils:libkey_enable_utils", 20 "//third_party/rust/crates/cxx:lib", 21] 22common_external_deps = [ 23 "c_utils:utils_rust", 24 "hilog:hilog_rust", 25 "hisysevent:hisysevent_rust", 26 "ylong_json:lib", 27] 28 29config("key_enable_rust_interface_config") { 30 include_dirs = [ "include" ] 31} 32 33ohos_rust_executable("key_enable") { 34 sources = [ "src/main.rs" ] 35 deps = common_deps 36 external_deps = common_external_deps 37 crate_name = "key_enable" 38 crate_type = "bin" 39 subsystem_name = "security" 40 part_name = "code_signature" 41 if (build_variant == "root") { 42 rustenv = [ "code_signature_debuggable=on" ] 43 } else { 44 rustenv = [ "code_signature_debuggable=off" ] 45 } 46} 47 48ohos_rust_shared_ffi("key_enable_lib") { 49 sources = [ "src/lib.rs" ] 50 deps = common_deps 51 external_deps = common_external_deps 52 crate_name = "key_enable" 53 subsystem_name = "security" 54 part_name = "code_signature" 55 if (build_variant == "root") { 56 rustenv = [ "code_signature_debuggable=on" ] 57 } else { 58 rustenv = [ "code_signature_debuggable=off" ] 59 } 60} 61 62ohos_prebuilt_etc("trusted_cert_path") { 63 if (code_signature_support_openharmony_ca) { 64 source = "config/openharmony/trusted_cert_path.json" 65 } else { 66 source = "config/trusted_cert_path.json" 67 } 68 part_name = "code_signature" 69 subsystem_name = "security" 70 relative_install_dir = "security" 71} 72 73ohos_prebuilt_etc("trusted_cert_path_test") { 74 if (defined(sign_hap_py_path)) { 75 source = "config/trusted_cert_path_test.json" 76 } else { 77 source = "config/not_sign_hap_py_path/trusted_cert_path_test.json" 78 } 79 part_name = "code_signature" 80 subsystem_name = "security" 81 relative_install_dir = "security" 82} 83 84ohos_prebuilt_etc("key_enable.cfg") { 85 if (code_signature_enable_xpm_mode) { 86 source = "cfg/enable_xpm/key_enable.cfg" 87 } else { 88 source = "cfg/disable_xpm/key_enable.cfg" 89 } 90 relative_install_dir = "init" 91 subsystem_name = "security" 92 part_name = "code_signature" 93} 94 95group("key_enable_targets") { 96 deps = [] 97 if (host_os == "linux" && !is_asan) { 98 deps += [ 99 ":key_enable", 100 ":key_enable.cfg", 101 ":key_enable_lib", 102 ":trusted_cert_path", 103 ":trusted_cert_path_test", 104 ] 105 } 106} 107