• 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")
16import("config.gni")
17
18config("internal") {
19  include_dirs = [ "include" ]
20  include_dirs += [ syscap_codec_config_path ]
21  if (syscap_codec_config_extern_path != "") {
22    include_dirs += [ "${root_build_dir}" ]
23    cflags = [ "-DSYSCAP_DEFINE_EXTERN_ENABLE" ]
24  }
25}
26
27sources_platform_common = [
28  "./src/syscap_tool.c",
29  "./src/create_pcid.c",
30  "./src/endian_internal.c",
31]
32
33ohos_executable("syscap_tool_bin") {
34  deps = []
35  if (syscap_codec_config_extern_path != "") {
36    deps += [ ":gen_syscap_define_custom" ]
37    inputs = [ "${root_build_dir}/syscap_define_custom.h" ]
38  }
39  output_name = "syscap_tool"
40  install_enable = true
41  include_dirs = [ "src" ]
42  configs = [ ":internal" ]
43  defines = []
44
45  if (is_mingw) {
46    defines += [ "_POSIX_" ]
47  }
48  if (defined(ohos_lite) && ohos_kernel_type == "liteos_m") {
49    cflags = [ "-DPATH_MAX=1024" ]
50    cflags += [ "-Wno-int-conversion" ]
51  }
52  sources = [ "./src/main.c" ]
53  sources += sources_platform_common
54
55  deps += [ "//third_party/bounds_checking_function:libsec_static" ]
56
57  if (defined(ohos_lite)) {
58    deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
59  } else {
60    deps += [ "//third_party/cJSON:cjson_static" ]
61  }
62
63  subsystem_name = "developtools"
64  part_name = "syscap_codec"
65}
66
67config("syscap_interface_public_config") {
68  include_dirs = [ "./interfaces/inner_api/" ]
69}
70
71if (defined(ohos_lite)) {
72  if (ohos_kernel_type == "liteos_m") {
73    group("syscap_interface_shared") {
74    }
75  } else {
76    shared_library("syscap_interface_shared") {
77      deps = []
78      if (syscap_codec_config_extern_path != "") {
79        deps += [ ":gen_syscap_define_custom" ]
80        inputs = [ "${root_build_dir}/syscap_define_custom.h" ]
81      }
82      _version_script = rebase_path("libsyscap_interface_shared.versionscript")
83      if (!defined(ldflags)) {
84        ldflags = []
85      }
86      ldflags += [
87        "-rdynamic",
88        "-Wl,--version-script=${_version_script}",
89      ]
90
91      include_dirs = [ "src" ]
92      configs += [ ":internal" ]
93      public_configs = [ ":syscap_interface_public_config" ]
94      sources = [
95        "./interfaces/inner_api/syscap_interface.c",
96        "./src/endian_internal.c",
97        "./src/syscap_tool.c",
98      ]
99
100      deps += [
101        "//build/lite/config/component/cJSON:cjson_static",
102        "//third_party/bounds_checking_function:libsec_static",
103      ]
104    }
105  }
106} else {
107  ohos_shared_library("syscap_interface_shared") {
108    deps = []
109    if (syscap_codec_config_extern_path != "") {
110      deps += [ ":gen_syscap_define_custom" ]
111      inputs = [ "${root_build_dir}/syscap_define_custom.h" ]
112    }
113    version_script = "libsyscap_interface_shared.versionscript"
114    include_dirs = [ "src" ]
115    configs = [ ":internal" ]
116    public_configs = [ ":syscap_interface_public_config" ]
117    sources = [
118      "./interfaces/inner_api/syscap_interface.c",
119      "./src/endian_internal.c",
120      "./src/syscap_tool.c",
121    ]
122    deps += [
123      "//third_party/bounds_checking_function:libsec_static",
124      "//third_party/cJSON:cjson_static",
125    ]
126
127    subsystem_name = "developtools"
128    part_name = "syscap_codec"
129  }
130}
131
132group("syscap_tool_bin_linux") {
133  deps = [ ":syscap_tool_bin(//build/toolchain/linux:clang_x64)" ]
134}
135
136build_ext_component("generate_pcid") {
137  outputs = [ "$root_out_dir/PCID.sc" ]
138  deps = [ ":syscap_tool_bin_linux" ]
139  exec_path = rebase_path(root_out_dir)
140  preload_path = rebase_path(preloader_output_dir)
141  if (defined(ohos_lite)) {
142    cmd = "${exec_path}/clang_x64/syscap_tool"
143  } else {
144    cmd = "${exec_path}/clang_x64/developtools/syscap_codec/syscap_tool"
145  }
146  command = "chmod 777 $cmd"
147  command +=
148      " && $cmd -P -e -i ${preload_path}/system/etc/SystemCapability.json"
149  if (defined(ohos_lite)) {
150    command += " && mkdir -p $exec_path/system/etc && cp $exec_path/PCID.sc $exec_path/system/etc/PCID.sc"
151  }
152}
153
154ohos_prebuilt_etc("PCID.sc") {
155  deps = [ ":generate_pcid" ]
156  source = "$root_out_dir/PCID.sc"
157  subsystem_name = "developtools"
158  part_name = "syscap_codec"
159}
160
161if (syscap_codec_config_extern_path != "") {
162  # generate syscap_define_custom.h
163  action("gen_syscap_define_custom") {
164    script = "./tools/syscap_config_merge.py"
165    args = [
166      "--base",
167      rebase_path("include/codec_config/syscap_define.h"),
168      "--extern",
169      rebase_path(syscap_codec_config_extern_path),
170      "--output",
171      rebase_path("${root_build_dir}/syscap_define_custom.h"),
172    ]
173    inputs = [
174      "include/codec_config/syscap_define.h",
175      syscap_codec_config_extern_path,
176    ]
177    outputs = [ "${root_build_dir}/syscap_define_custom.h" ]
178  }
179}
180
181group("pcid_sc") {
182  deps = [ ":PCID.sc" ]
183}
184
185group("syscap_codec") {
186  deps = [
187    ":pcid_sc",
188    ":syscap_interface_shared",
189  ]
190  if (support_jsapi && is_standard_system) {
191    deps += [ "napi:systemcapability" ]
192  }
193}
194