• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-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 = "${ets_util_path}/js_api_module/build_ts_js.py"
22
23  outFile_Path = target_out_dir + "/" + current_cpu
24  args = [
25    "--dst-file",
26    rebase_path(target_out_dir + "/js_url.js"),
27    "--module-path",
28    rebase_path("/commonlibrary/ets_utils/js_api_module/url"),
29    "--out-file",
30    rebase_path(outFile_Path + "/js_url.js"),
31    "--out-filePath",
32    rebase_path(outFile_Path),
33    "--relative-path",
34    rebase_path("//", root_build_dir),
35  ]
36  outputs = [ target_out_dir + "/js_url.js" ]
37}
38
39# compile .js to .abc.
40es2abc_gen_abc("gen_url_abc") {
41  extra_visibility = [ ":*" ]
42  src_js = rebase_path(target_out_dir + "/js_url.js")
43  dst_file = rebase_path(target_out_dir + "/url.abc")
44  in_puts = [ target_out_dir + "/js_url.js" ]
45  out_puts = [ target_out_dir + "/url.abc" ]
46  extra_args = [ "--module" ]
47  extra_dependencies = [ ":build_ts_js" ]
48}
49
50abc_output_path = get_label_info(":url_abc", "target_out_dir")
51
52gen_obj("url_js") {
53  input = "$target_out_dir/js_url.js"
54  if (use_mac || use_mingw_win || use_ios || use_linux) {
55    url_obj_path = abc_output_path + "/url.c"
56  } else {
57    url_obj_path = abc_output_path + "/url.o"
58  }
59  output = url_obj_path
60  snapshot_dep = [ ":build_ts_js" ]
61}
62
63gen_obj("url_abc") {
64  input = "$target_out_dir/url.abc"
65  if (use_mac || use_mingw_win || use_ios || use_linux) {
66    url_obj_path = abc_output_path + "/url_abc.c"
67  } else {
68    url_obj_path = abc_output_path + "/url_abc.o"
69  }
70  output = url_obj_path
71  snapshot_dep = [ ":gen_url_abc" ]
72}
73
74url_sources = [
75  "js_url.cpp",
76  "native_module_url.cpp",
77  "url_helper.cpp",
78]
79
80ohos_shared_library("url") {
81  branch_protector_ret = "pac_ret"
82  sanitize = {
83    cfi = true
84    cfi_cross_dso = true
85    debug = false
86  }
87  deps = [ ":url_static" ]
88  external_deps = [ "hilog:libhilog" ]
89  subsystem_name = "commonlibrary"
90  part_name = "ets_utils"
91  relative_install_dir = "module"
92}
93
94ohos_source_set("url_static") {
95  branch_protector_ret = "pac_ret"
96  sanitize = {
97    cfi = true
98    cfi_cross_dso = true
99    debug = false
100  }
101  include_dirs = [
102    "include",
103    "//third_party/node/src",
104    ets_util_path,
105  ]
106
107  sources = url_sources
108
109  deps = [
110    ":gen_obj_src_url_abc",
111    ":gen_obj_src_url_js",
112  ]
113
114  if (is_arkui_x) {
115    include_dirs += [
116      "$plugins_root/hilog/include",
117      "$plugins_root/interfaces",
118      "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
119    ]
120    if (target_os == "android") {
121      defines = [ "ANDROID_PLATFORM" ]
122    }
123    deps += [
124      "$plugins_root/libs/icu:icu_${target_os}",
125      "$plugins_root/libs/napi:napi_${target_os}",
126      "$plugins_root/libs/securec:sec_${target_os}",
127    ]
128  } else {
129    include_dirs += [ "//third_party/icu/icu4c/source/common" ]
130    if (is_standard_system) {
131      external_deps = [ "hilog:libhilog" ]
132    } else {
133      external_deps = [
134        "c_utils:utils",
135        "hilog:libhilog",
136      ]
137    }
138    external_deps += [
139      "bounds_checking_function:libsec_shared",
140      "icu:shared_icuuc",
141      "napi:ace_napi",
142    ]
143  }
144
145  subsystem_name = "commonlibrary"
146  part_name = "ets_utils"
147}
148
149group("url_packages") {
150  deps = [ ":url" ]
151}
152