• 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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//commonlibrary/ets_utils/ets_utils_config.gni")
17import("//foundation/arkui/ace_engine/ace_config.gni")
18import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni")
19
20# compile .ts to .js.
21action("build_ts_js") {
22  script = "${ets_util_path}/js_api_module/build_ts_js.py"
23
24  outFile_Path = target_out_dir + "/" + current_cpu
25  args = [
26    "--dst-file",
27    rebase_path(target_out_dir + "/js_uri.js"),
28    "--module-path",
29    rebase_path("/commonlibrary/ets_utils/js_api_module/uri"),
30    "--out-file",
31    rebase_path(outFile_Path + "/js_uri.js"),
32    "--out-filePath",
33    rebase_path(outFile_Path),
34    "--relative-path",
35    rebase_path("//", root_build_dir),
36  ]
37  outputs = [ target_out_dir + "/js_uri.js" ]
38}
39
40# compile .js to .abc.
41es2abc_gen_abc("gen_uri_abc") {
42  extra_visibility = [ ":*" ]
43  src_js = rebase_path(target_out_dir + "/js_uri.js")
44  dst_file = rebase_path(target_out_dir + "/uri.abc")
45  in_puts = [ target_out_dir + "/js_uri.js" ]
46  out_puts = [ target_out_dir + "/uri.abc" ]
47  extra_args = [ "--module" ]
48  extra_dependencies = [ ":build_ts_js" ]
49}
50
51abc_output_path = get_label_info(":uri_abc", "target_out_dir")
52
53gen_obj("uri_js") {
54  input = "$target_out_dir/js_uri.js"
55  if (use_mac || use_mingw_win || use_ios || use_linux) {
56    uri_obj_path = abc_output_path + "/uri.c"
57  } else {
58    uri_obj_path = abc_output_path + "/uri.o"
59  }
60  output = uri_obj_path
61  snapshot_dep = [ ":build_ts_js" ]
62}
63
64gen_obj("uri_abc") {
65  input = "$target_out_dir/uri.abc"
66  if (use_mac || use_mingw_win || use_ios || use_linux) {
67    uri_obj_path = abc_output_path + "/uri_abc.c"
68  } else {
69    uri_obj_path = abc_output_path + "/uri_abc.o"
70  }
71  output = uri_obj_path
72  snapshot_dep = [ ":gen_uri_abc" ]
73}
74
75uri_sources = [
76  "js_uri.cpp",
77  "native_module_uri.cpp",
78]
79
80ohos_shared_library("uri") {
81  deps = [ ":uri_static" ]
82  subsystem_name = "commonlibrary"
83  part_name = "ets_utils"
84  relative_install_dir = "module"
85}
86
87ohos_source_set("uri_static") {
88  include_dirs = [
89    "include",
90    "//third_party/node/src",
91  ]
92
93  configs = [ "//third_party/icu/icu4c:icu_config" ]
94  sources = uri_sources
95
96  deps = [
97    ":gen_obj_src_uri_abc",
98    ":gen_obj_src_uri_js",
99  ]
100
101  if (is_arkui_x) {
102    include_dirs += [
103      "$plugins_root/hilog/include",
104      "$plugins_root/interfaces",
105    ]
106    if (target_os == "android") {
107      defines = [ "ANDROID_PLATFORM" ]
108    }
109    deps += [
110      "$plugins_root/libs/icu:icu_${target_os}",
111      "$plugins_root/libs/napi:napi_${target_os}",
112      "$plugins_root/libs/securec:sec_${target_os}",
113    ]
114  } else {
115    include_dirs += [ "//third_party/icu/icu4c/source/common" ]
116    if (is_standard_system) {
117      external_deps = [ "hilog:libhilog" ]
118    } else {
119      external_deps = [
120        "c_utils:utils",
121        "hilog:libhilog",
122      ]
123    }
124    external_deps += [ "napi:ace_napi" ]
125    deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
126  }
127
128  subsystem_name = "commonlibrary"
129  part_name = "ets_utils"
130}
131
132group("uri_packages") {
133  deps = [ ":uri" ]
134}
135