• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2022 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/lite/config/component/lite_component.gni")
15import("//build/ohos.gni")
16
17config("pubilc") {
18  include_dirs = [ "include" ]
19}
20
21sources_platform_common = [
22  "./src/syscap_tool.c",
23  "./src/create_pcid.c",
24  "./src/endian_internal.c",
25]
26
27ohos_executable("syscap_define_check_bin") {
28  include_dirs = [ "include" ]
29  sources = [ "./test/syscap_define_check.c" ]
30
31  if (is_mingw) {
32    defines = [ "_POSIX_" ]
33  }
34
35  subsystem_name = "developtools"
36  part_name = "syscap_codec"
37}
38
39build_ext_component("syscap_define_check") {
40  deps = [ ":syscap_define_check_bin(//build/toolchain/linux:clang_x64)" ]
41  exec_path = rebase_path(root_out_dir)
42
43  if (defined(ohos_lite)) {
44    cmd = "${exec_path}/clang_x64/syscap_define_check_bin"
45  } else {
46    cmd = "${exec_path}/clang_x64/developtools/syscap_codec/syscap_define_check_bin"
47  }
48
49  command = "chmod 777 $cmd && $cmd"
50}
51
52ohos_executable("syscap_tool_bin") {
53  output_name = "syscap_tool"
54  install_enable = true
55  include_dirs = [ "src" ]
56  public_configs = [ ":pubilc" ]
57  defines = []
58
59  if (is_mingw) {
60    defines += [ "_POSIX_" ]
61  }
62  sources = [ "./src/main.c" ]
63  sources += sources_platform_common
64
65  deps = [ "//third_party/bounds_checking_function:libsec_static" ]
66
67  if (defined(ohos_lite)) {
68    deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
69  } else {
70    deps += [ "//third_party/cJSON:cjson_static" ]
71  }
72
73  subsystem_name = "developtools"
74  part_name = "syscap_codec"
75}
76
77ohos_executable("syscap_tool_test") {
78  install_enable = true
79  include_dirs = [ "src" ]
80  public_configs = [ ":pubilc" ]
81  defines = []
82
83  if (is_mingw) {
84    defines += [ "_POSIX_" ]
85  }
86
87  sources = [ "./test/syscap_tool_test.c" ]
88  sources += sources_platform_common
89
90  deps = [ "//third_party/bounds_checking_function:libsec_static" ]
91
92  if (defined(ohos_lite)) {
93    deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
94  } else {
95    deps += [ "//third_party/cJSON:cjson_static" ]
96  }
97
98  subsystem_name = "developtools"
99  part_name = "syscap_codec"
100}
101
102ohos_shared_library("syscap_tool_shared") {
103  output_name = "syscap_codec"
104  include_dirs = [ "src" ]
105  public_configs = [ ":pubilc" ]
106
107  sources = sources_platform_common
108
109  deps = [ "//third_party/bounds_checking_function:libsec_static" ]
110
111  if (defined(ohos_lite)) {
112    deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
113  } else {
114    deps += [ "//third_party/cJSON:cjson_static" ]
115  }
116
117  subsystem_name = "developtools"
118  part_name = "syscap_codec"
119}
120
121config("syscap_interface_public_config") {
122  include_dirs = [ "./interfaces/inner_api/" ]
123}
124
125if (defined(ohos_lite)) {
126  if (ohos_kernel_type == "liteos_m") {
127    group("syscap_interface_shared") {
128    }
129  } else {
130    shared_library("syscap_interface_shared") {
131      _version_script = rebase_path("libsyscap_interface_shared.versionscript")
132      if (!defined(ldflags)) {
133        ldflags = []
134      }
135      ldflags += [
136        "-rdynamic",
137        "-Wl,--version-script=${_version_script}",
138      ]
139
140      include_dirs = [
141        "include",
142        "src",
143      ]
144      public_configs = [ ":syscap_interface_public_config" ]
145      sources = [
146        "./interfaces/inner_api/syscap_interface.c",
147        "./src/endian_internal.c",
148        "./src/syscap_tool.c",
149      ]
150
151      deps = [
152        "//build/lite/config/component/cJSON:cjson_static",
153        "//third_party/bounds_checking_function:libsec_static",
154      ]
155    }
156  }
157} else {
158  ohos_shared_library("syscap_interface_shared") {
159    version_script = "libsyscap_interface_shared.versionscript"
160    include_dirs = [
161      "include",
162      "src",
163    ]
164    public_configs = [ ":syscap_interface_public_config" ]
165    sources = [
166      "./interfaces/inner_api/syscap_interface.c",
167      "./src/endian_internal.c",
168      "./src/syscap_tool.c",
169    ]
170    deps = [
171      "//third_party/bounds_checking_function:libsec_static",
172      "//third_party/cJSON:cjson_static",
173    ]
174
175    subsystem_name = "developtools"
176    part_name = "syscap_codec"
177  }
178}
179
180group("syscap_tool_bin_linux") {
181  deps = [ ":syscap_tool_bin(//build/toolchain/linux:clang_x64)" ]
182}
183
184build_ext_component("generate_pcid") {
185  outputs = [ "$root_out_dir/PCID.sc" ]
186  deps = [ ":syscap_tool_bin_linux" ]
187  exec_path = rebase_path(root_out_dir)
188  preload_path = rebase_path(preloader_output_dir)
189  if (defined(ohos_lite)) {
190    cmd = "${exec_path}/clang_x64/syscap_tool"
191  } else {
192    cmd = "${exec_path}/clang_x64/developtools/syscap_codec/syscap_tool"
193  }
194  command = "chmod 777 $cmd"
195  command +=
196      " && $cmd -P -e -i ${preload_path}/system/etc/SystemCapability.json"
197  if (defined(ohos_lite)) {
198    command += " && mkdir -p $exec_path/system/etc && cp $exec_path/PCID.sc $exec_path/system/etc/PCID.sc"
199  }
200}
201
202ohos_prebuilt_etc("PCID.sc") {
203  deps = [ ":generate_pcid" ]
204  source = "$root_out_dir/PCID.sc"
205  part_name = "syscap_codec"
206}
207
208group("pcid_sc") {
209  deps = [ ":PCID.sc" ]
210}
211
212group("syscap_codec") {
213  deps = [
214    ":pcid_sc",
215    ":syscap_define_check",
216    ":syscap_interface_shared",
217    ":syscap_tool_shared",
218  ]
219  if (support_jsapi && is_standard_system) {
220    deps += [ "napi:systemcapability" ]
221  }
222}
223