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