# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//ark/ts2abc/ts2panda/ts2abc_config.gni") import("//build/ohos.gni") import("//build/ohos/ace/ace.gni") import("//foundation/ace/ace_engine/ace_config.gni") # compile .ts to .js. action("build_ts_js") { script = "//base/compileruntime/js_util_module/build_ts_js.py" args = [ "--dst-file", rebase_path(target_out_dir + "/util_js.js"), "--module-path", rebase_path("/base/compileruntime/js_util_module/util"), "--out-file", rebase_path("./out/util_js.js"), ] depfile = "$target_gen_dir/$target_name.d" outputs = [ target_out_dir + "/util_js.js" ] } base_output_path = get_label_info(":util_js", "target_out_dir") util_js_obj_path = base_output_path + "/util.o" gen_js_obj("util_js") { input = "$target_out_dir/util_js.js" output = util_js_obj_path dep = ":build_ts_js" } # compile .js to .abc. action("gen_util_abc") { visibility = [ ":*" ] script = "//ark/ts2abc/ts2panda/scripts/generate_js_bytecode.py" args = [ "--src-js", rebase_path(target_out_dir + "/util_js.js"), "--dst-file", rebase_path(target_out_dir + "/util.abc"), "--node", rebase_path("${node_path}"), "--frontend-tool-path", rebase_path("${ts2abc_build_path}"), "--node-modules", rebase_path("${node_modules}"), "--module", ] deps = [ ":build_ts_js", "//ark/ts2abc/ts2panda:ark_ts2abc_build", ] inputs = [ target_out_dir + "/util_js.js" ] outputs = [ target_out_dir + "/util.abc" ] } abc_output_path = get_label_info(":util_abc", "target_out_dir") util_abc_obj_path = abc_output_path + "/util_abc.o" gen_js_obj("util_abc") { input = "$target_out_dir/util.abc" output = util_abc_obj_path dep = ":gen_util_abc" } ohos_shared_library("util") { include_dirs = [ "//foundation/ace/napi", "//foundation/ace/napi/native_engine", "//third_party/icu/icu4c/source/common", "//third_party/node/src", "//foundation/ace/napi/interfaces/kits", "//base/compileruntime/js_util_module/util", ] sources = [ "js_base64.cpp", "js_textdecoder.cpp", "js_textencoder.cpp", "js_types.cpp", "native_module_util.cpp", ] deps = [ ":util_abc", ":util_js", "//base/compileruntime/js_util_module/util/:util_js", "//foundation/ace/napi/:ace_napi", "//foundation/ace/napi/:ace_napi_quickjs", "//third_party/icu/icu4c:static_icuuc", "//utils/native/base:utils", ] if (is_standard_system) { external_deps = [ "hiviewdfx_hilog_native:libhilog" ] } else { external_deps = [ "hilog:libhilog" ] } subsystem_name = "utils" part_name = "jsapi_util" relative_install_dir = "module" } group("util_packages") { deps = [ ":util" ] }