• 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    ets_util_path,
104  ]
105
106  sources = url_sources
107
108  deps = [
109    ":gen_obj_src_url_abc",
110    ":gen_obj_src_url_js",
111  ]
112
113  if (is_arkui_x) {
114    include_dirs += [
115      "$plugins_root/hilog/include",
116      "$plugins_root/interfaces",
117      "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
118    ]
119    if (target_os == "android") {
120      defines = [ "ANDROID_PLATFORM" ]
121    }
122    deps += [
123      "$plugins_root/libs/icu:icu_${target_os}",
124      "$plugins_root/libs/napi:napi_${target_os}",
125      "$plugins_root/libs/securec:sec_${target_os}",
126    ]
127  } else {
128    if (is_standard_system) {
129      external_deps = [ "hilog:libhilog" ]
130    } else {
131      external_deps = [
132        "c_utils:utils",
133        "hilog:libhilog",
134      ]
135    }
136    external_deps += [
137      "bounds_checking_function:libsec_shared",
138      "icu:shared_icuuc",
139      "napi:ace_napi",
140    ]
141  }
142
143  subsystem_name = "commonlibrary"
144  part_name = "ets_utils"
145}
146
147group("url_packages") {
148  deps = [ ":url" ]
149}
150