1# Copyright (c) 2023-2024 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 = [ "utils:libkey_enable_utils" ] 18common_external_deps = [ 19 "hilog:hilog_rust", 20 "hisysevent:hisysevent_rust", 21 "ylong_json:lib", 22] 23 24config("key_enable_rust_interface_config") { 25 include_dirs = [ "include" ] 26} 27 28ohos_rust_executable("key_enable") { 29 sources = [ "src/main.rs" ] 30 deps = common_deps 31 external_deps = common_external_deps 32 if (!ohos_indep_compiler_enable) { 33 deps += [ 34 "${rust_openssl_dir}/openssl:lib", 35 "//third_party/rust/crates/cxx:lib", 36 "//third_party/rust/crates/lazy-static.rs:lib", 37 ] 38 external_deps += [ "c_utils:utils_rust" ] 39 } 40 rustenv = [] 41 if (build_variant == "root") { 42 rustenv += [ "code_signature_debuggable=on" ] 43 } else { 44 rustenv += [ "code_signature_debuggable=off" ] 45 } 46 if (code_signature_support_oh_release_app) { 47 rustenv += [ "support_openharmony_ca=on" ] 48 } else { 49 rustenv += [ "support_openharmony_ca=off" ] 50 } 51 crate_name = "key_enable" 52 crate_type = "bin" 53 subsystem_name = "security" 54 part_name = "code_signature" 55} 56 57ohos_rust_shared_ffi("key_enable_lib") { 58 sources = [ "src/lib.rs" ] 59 deps = common_deps 60 external_deps = common_external_deps 61 if (!ohos_indep_compiler_enable) { 62 deps += [ 63 "${rust_openssl_dir}/openssl:lib", 64 "//third_party/rust/crates/cxx:lib", 65 "//third_party/rust/crates/lazy-static.rs:lib", 66 ] 67 external_deps += [ "c_utils:utils_rust" ] 68 } 69 rustenv = [] 70 if (build_variant == "root") { 71 rustenv += [ "code_signature_debuggable=on" ] 72 } else { 73 rustenv += [ "code_signature_debuggable=off" ] 74 } 75 if (code_signature_support_oh_release_app) { 76 rustenv += [ "support_openharmony_ca=on" ] 77 } else { 78 rustenv += [ "support_openharmony_ca=off" ] 79 } 80 crate_name = "key_enable" 81 subsystem_name = "security" 82 part_name = "code_signature" 83} 84 85ohos_prebuilt_etc("trusted_cert_path") { 86 if (code_signature_support_oh_release_app) { 87 source = "config/openharmony/release/trusted_cert_path.json" 88 } else { 89 source = "config/trusted_cert_path.json" 90 } 91 part_name = "code_signature" 92 subsystem_name = "security" 93 relative_install_dir = "security" 94} 95 96ohos_prebuilt_etc("trusted_cert_path_test") { 97 source = "config/trusted_cert_path_test.json" 98 part_name = "code_signature" 99 subsystem_name = "security" 100 relative_install_dir = "security" 101} 102 103ohos_prebuilt_etc("key_enable.cfg") { 104 if (code_signature_enable_xpm_mode == 1) { 105 source = "cfg/enable_xpm/level1/key_enable.cfg" 106 } else if (code_signature_enable_xpm_mode == 2) { 107 source = "cfg/enable_xpm/level2/key_enable.cfg" 108 } else if (code_signature_enable_xpm_mode == 3) { 109 source = "cfg/enable_xpm/level3/key_enable.cfg" 110 } else if (code_signature_enable_xpm_mode == 4) { 111 source = "cfg/enable_xpm/level4/key_enable.cfg" 112 } else if (code_signature_enable_xpm_mode == 5) { 113 source = "cfg/enable_xpm/level5/key_enable.cfg" 114 } else { 115 source = "cfg/disable_xpm/key_enable.cfg" 116 } 117 relative_install_dir = "init" 118 subsystem_name = "security" 119 part_name = "code_signature" 120} 121 122group("key_enable_targets") { 123 deps = [] 124 if (host_os == "linux" && !is_asan) { 125 deps += [ 126 ":key_enable.cfg", 127 ":trusted_cert_path", 128 ":trusted_cert_path_test", 129 ] 130 if (!use_clang_coverage) { 131 deps += [ 132 ":key_enable", 133 ":key_enable_lib", 134 ] 135 } 136 } 137} 138