1# Copyright (c) 2021 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("//ark/ts2abc/ts2panda/ts2abc_config.gni") 14import("//build/ohos.gni") 15import("//build/ohos/ace/ace.gni") 16import("//foundation/ace/ace_engine/ace_config.gni") 17 18# compile .ts to .js. 19action("build_ts_js") { 20 script = "//base/compileruntime/js_api_module/build_ts_js.py" 21 args = [ 22 "--dst-file", 23 rebase_path(target_out_dir + "/js_uri.js"), 24 "--module-path", 25 rebase_path("/base/compileruntime/js_api_module/uri"), 26 "--out-file", 27 rebase_path("./out/js_uri.js"), 28 ] 29 depfile = "$target_gen_dir/$target_name.d" 30 outputs = [ target_out_dir + "/js_uri.js" ] 31} 32base_output_path = get_label_info(":js_uri", "target_out_dir") 33js_uri_obj_path = base_output_path + "/uri.o" 34gen_js_obj("js_uri") { 35 input = "$target_out_dir/js_uri.js" 36 output = js_uri_obj_path 37 dep = ":build_ts_js" 38} 39 40# compile .js to .abc. 41action("gen_uri_abc") { 42 visibility = [ ":*" ] 43 script = "//ark/ts2abc/ts2panda/scripts/generate_js_bytecode.py" 44 45 args = [ 46 "--src-js", 47 rebase_path(target_out_dir + "/js_uri.js"), 48 "--dst-file", 49 rebase_path(target_out_dir + "/uri.abc"), 50 "--node", 51 rebase_path("${node_path}"), 52 "--frontend-tool-path", 53 rebase_path("${ts2abc_build_path}"), 54 "--node-modules", 55 rebase_path("${node_modules}"), 56 "--module", 57 ] 58 deps = [ 59 ":build_ts_js", 60 "//ark/ts2abc/ts2panda:ark_ts2abc_build", 61 ] 62 63 inputs = [ target_out_dir + "/js_uri.js" ] 64 outputs = [ target_out_dir + "/uri.abc" ] 65} 66 67abc_output_path = get_label_info(":uri_abc", "target_out_dir") 68uri_abc_obj_path = abc_output_path + "/uri_abc.o" 69gen_js_obj("uri_abc") { 70 input = "$target_out_dir/uri.abc" 71 output = uri_abc_obj_path 72 dep = ":gen_uri_abc" 73} 74 75ohos_shared_library("uri") { 76 include_dirs = [ 77 "//third_party/icu/icu4c/source/common", 78 "//third_party/node/src", 79 "//foundation/ace/napi/interfaces/kits", 80 "//base/compileruntime/js_api_module/uri", 81 ] 82 83 sources = [ 84 "js_uri.cpp", 85 "native_module_uri.cpp", 86 ] 87 88 deps = [ 89 ":js_uri", 90 ":uri_abc", 91 "//base/compileruntime/js_api_module/uri/:js_uri", 92 "//foundation/ace/napi/:ace_napi", 93 "//foundation/ace/napi/:ace_napi_quickjs", 94 "//third_party/icu/icu4c:static_icuuc", 95 "//utils/native/base:utils", 96 ] 97 98 if (is_standard_system) { 99 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 100 } else { 101 external_deps = [ "hilog:libhilog" ] 102 } 103 subsystem_name = "utils" 104 part_name = "jsapi_api" 105 106 relative_install_dir = "module" 107} 108 109group("uri_packages") { 110 deps = [ ":uri" ] 111} 112