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. 13import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni") 14import("//build/ohos.gni") 15import("//build/ohos/ace/ace.gni") 16import("//foundation/arkui/ace_engine/ace_config.gni") 17 18# compile .ts to .js. 19action("build_ts_js") { 20 script = "//commonlibrary/ets_utils/js_api_module/build_ts_js.py" 21 args = [ 22 "--dst-file", 23 rebase_path(target_out_dir + "/js_url.js"), 24 "--module-path", 25 rebase_path("/commonlibrary/ets_utils/js_api_module/url"), 26 "--out-file", 27 rebase_path("./out/js_url.js"), 28 "--relative-path", 29 rebase_path("//", root_build_dir), 30 ] 31 outputs = [ target_out_dir + "/js_url.js" ] 32} 33base_output_path = get_label_info(":js_url", "target_out_dir") 34js_url_obj_path = base_output_path + "/url.o" 35gen_js_obj("js_url") { 36 input = "$target_out_dir/js_url.js" 37 output = js_url_obj_path 38 dep = ":build_ts_js" 39} 40 41# compile .js to .abc. 42action("gen_url_abc") { 43 visibility = [ ":*" ] 44 script = "//arkcompiler/ets_frontend/ts2panda/scripts/generate_js_bytecode.py" 45 46 args = [ 47 "--src-js", 48 rebase_path(target_out_dir + "/js_url.js"), 49 "--dst-file", 50 rebase_path(target_out_dir + "/url.abc"), 51 "--node", 52 rebase_path("${node_path}"), 53 "--frontend-tool-path", 54 rebase_path("${ts2abc_build_path}"), 55 "--node-modules", 56 rebase_path("${node_modules}"), 57 "--module", 58 ] 59 deps = [ 60 ":build_ts_js", 61 "//arkcompiler/ets_frontend/ts2panda:ark_ts2abc_build", 62 ] 63 64 inputs = [ target_out_dir + "/js_url.js" ] 65 outputs = [ target_out_dir + "/url.abc" ] 66} 67 68abc_output_path = get_label_info(":url_abc", "target_out_dir") 69url_abc_obj_path = abc_output_path + "/url_abc.o" 70gen_js_obj("url_abc") { 71 input = "$target_out_dir/url.abc" 72 output = url_abc_obj_path 73 dep = ":gen_url_abc" 74} 75 76ohos_shared_library("url") { 77 include_dirs = [ 78 "//third_party/icu/icu4c/source/common", 79 "//third_party/node/src", 80 "//foundation/arkui/napi/interfaces/kits", 81 "//commonlibrary/ets_utils/js_api_module/url", 82 ] 83 84 sources = [ 85 "js_url.cpp", 86 "native_module_url.cpp", 87 ] 88 89 deps = [ 90 ":js_url", 91 ":url_abc", 92 "//commonlibrary/ets_utils/js_api_module/url/:js_url", 93 "//foundation/arkui/napi/:ace_napi", 94 "//third_party/icu/icu4c:shared_icuuc", 95 ] 96 97 if (is_standard_system) { 98 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 99 } else { 100 external_deps = [ 101 "c_utils:utils", 102 "hilog:libhilog", 103 ] 104 } 105 subsystem_name = "commonlibrary" 106 part_name = "ets_utils" 107 108 relative_install_dir = "module" 109} 110 111ohos_static_library("url_static") { 112 include_dirs = [ 113 "//third_party/icu/icu4c/source/common", 114 "//third_party/node/src", 115 "//foundation/arkui/napi/interfaces/kits", 116 "//commonlibrary/ets_utils/js_api_module/url", 117 ] 118 119 sources = [ 120 "js_url.cpp", 121 "native_module_url.cpp", 122 ] 123 124 deps = [ 125 ":js_url", 126 ":url_abc", 127 "//commonlibrary/ets_utils/js_api_module/url/:js_url", 128 "//foundation/arkui/napi/:ace_napi", 129 "//third_party/icu/icu4c:shared_icuuc", 130 ] 131 132 if (is_standard_system) { 133 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 134 } else { 135 external_deps = [ 136 "c_utils:utils", 137 "hilog:libhilog", 138 ] 139 } 140 subsystem_name = "commonlibrary" 141 part_name = "ets_utils" 142} 143 144group("url_packages") { 145 deps = [ ":url" ] 146} 147