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