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