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