• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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/config/components/ace_engine/ace_gen_obj.gni")
15import("//build/config/components/ets_frontend/es2abc_config.gni")
16import("//build/ohos.gni")
17import("//commonlibrary/ets_utils/ets_utils_config.gni")
18
19# compile .ts to .js.
20action("build_ts_js") {
21  script = "$util_module/build_ts_js.py"
22  outFile_Path = target_out_dir + "/" + current_cpu
23  args = [
24    "--dst-file",
25    rebase_path(target_out_dir + "/json_js.js"),
26    "--module-path",
27    rebase_path("/commonlibrary/ets_utils/js_util_module/json"),
28    "--out-file",
29    rebase_path(outFile_Path + "/json_js.js"),
30    "--out-filePath",
31    rebase_path(outFile_Path),
32    "--relative-path",
33    rebase_path("//", root_build_dir),
34  ]
35  outputs = [ target_out_dir + "/json_js.js" ]
36}
37
38# compile .js to .abc.
39es2abc_gen_abc("gen_json_abc") {
40  extra_visibility = [ ":*" ]
41  src_js = rebase_path(target_out_dir + "/json_js.js")
42  dst_file = rebase_path(target_out_dir + "/json.abc")
43  in_puts = [ target_out_dir + "/json_js.js" ]
44  out_puts = [ target_out_dir + "/json.abc" ]
45  extra_args = [ "--module" ]
46  extra_dependencies = [ ":build_ts_js" ]
47}
48
49abc_output_path = get_label_info(":json_abc", "target_out_dir")
50
51gen_obj("json_js") {
52  input = "$target_out_dir/json_js.js"
53  if (use_mac || use_mingw_win || use_ios || use_linux) {
54    json_js_obj_path = abc_output_path + "/json.c"
55  } else {
56    json_js_obj_path = abc_output_path + "/json.o"
57  }
58  output = json_js_obj_path
59  snapshot_dep = [ ":build_ts_js" ]
60}
61
62gen_obj("json_abc") {
63  input = "$target_out_dir/json.abc"
64  if (use_mac || use_mingw_win || use_ios || use_linux) {
65    json_js_obj_path = abc_output_path + "/json_abc.c"
66  } else {
67    json_js_obj_path = abc_output_path + "/json_abc.o"
68  }
69  output = json_js_obj_path
70  snapshot_dep = [ ":gen_json_abc" ]
71}
72
73json_sources = [ "native_module_json.cpp" ]
74
75ohos_shared_library("json") {
76  branch_protector_ret = "pac_ret"
77  sanitize = {
78    cfi = true
79    cfi_cross_dso = true
80    debug = false
81  }
82  deps = [ ":json_static" ]
83  external_deps = [ "hilog:libhilog" ]
84  subsystem_name = "commonlibrary"
85  part_name = "ets_utils"
86  relative_install_dir = "module/util"
87}
88
89ohos_source_set("json_static") {
90  branch_protector_ret = "pac_ret"
91  sanitize = {
92    cfi = true
93    cfi_cross_dso = true
94    debug = false
95  }
96  include_dirs = [
97    "include",
98    ets_util_path,
99  ]
100
101  sources = json_sources
102
103  deps = [
104    ":gen_obj_src_json_abc",
105    ":gen_obj_src_json_js",
106  ]
107
108  if (is_arkui_x) {
109    include_dirs += [
110      "$plugins_root/hilog/include",
111      "$plugins_root/interfaces",
112      "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
113    ]
114
115    if (target_os == "android") {
116      defines = [ "ANDROID_PLATFORM" ]
117    } else if (target_os == "ios") {
118      defines = [ "IOS_PLATFORM" ]
119    }
120    deps += [
121      "$plugins_root/libs/icu:icu_${target_os}",
122      "$plugins_root/libs/napi:napi_${target_os}",
123      "$plugins_root/libs/securec:sec_${target_os}",
124    ]
125  } else {
126    external_deps = [
127      "bounds_checking_function:libsec_shared",
128      "hilog:libhilog",
129      "icu:shared_icuuc",
130      "napi:ace_napi",
131    ]
132  }
133  subsystem_name = "commonlibrary"
134  part_name = "ets_utils"
135}
136
137group("json_packages") {
138  public_deps = [ ":json" ]
139}
140