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_url.js"), 28 "--module-path", 29 rebase_path("/commonlibrary/ets_utils/js_api_module/url"), 30 "--out-file", 31 rebase_path(outFile_Path + "/js_url.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_url.js" ] 38} 39 40# compile .js to .abc. 41es2abc_gen_abc("gen_url_abc") { 42 extra_visibility = [ ":*" ] 43 src_js = rebase_path(target_out_dir + "/js_url.js") 44 dst_file = rebase_path(target_out_dir + "/url.abc") 45 in_puts = [ target_out_dir + "/js_url.js" ] 46 out_puts = [ target_out_dir + "/url.abc" ] 47 extra_args = [ "--module" ] 48 extra_dependencies = [ ":build_ts_js" ] 49} 50 51abc_output_path = get_label_info(":url_abc", "target_out_dir") 52 53gen_obj("url_js") { 54 input = "$target_out_dir/js_url.js" 55 if (use_mac || use_mingw_win || use_ios || use_linux) { 56 url_obj_path = abc_output_path + "/url.c" 57 } else { 58 url_obj_path = abc_output_path + "/url.o" 59 } 60 output = url_obj_path 61 snapshot_dep = [ ":build_ts_js" ] 62} 63 64gen_obj("url_abc") { 65 input = "$target_out_dir/url.abc" 66 if (use_mac || use_mingw_win || use_ios || use_linux) { 67 url_obj_path = abc_output_path + "/url_abc.c" 68 } else { 69 url_obj_path = abc_output_path + "/url_abc.o" 70 } 71 output = url_obj_path 72 snapshot_dep = [ ":gen_url_abc" ] 73} 74 75url_sources = [ 76 "js_url.cpp", 77 "native_module_url.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 "//third_party/node/src", 104 ets_util_path, 105 ] 106 107 configs = [ "//third_party/icu/icu4c:icu_config" ] 108 sources = url_sources 109 110 deps = [ 111 ":gen_obj_src_url_abc", 112 ":gen_obj_src_url_js", 113 ] 114 115 if (is_arkui_x) { 116 include_dirs += [ 117 "$plugins_root/hilog/include", 118 "$plugins_root/interfaces", 119 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 120 ] 121 if (target_os == "android") { 122 defines = [ "ANDROID_PLATFORM" ] 123 } 124 deps += [ 125 "$plugins_root/libs/icu:icu_${target_os}", 126 "$plugins_root/libs/napi:napi_${target_os}", 127 "$plugins_root/libs/securec:sec_${target_os}", 128 ] 129 } else { 130 include_dirs += [ "//third_party/icu/icu4c/source/common" ] 131 if (is_standard_system) { 132 external_deps = [ "hilog:libhilog" ] 133 } else { 134 external_deps = [ 135 "c_utils:utils", 136 "hilog:libhilog", 137 ] 138 } 139 external_deps += [ 140 "bounds_checking_function:libsec_shared", 141 "napi:ace_napi", 142 ] 143 144 deps += [ "//third_party/icu/icu4c:shared_icuuc" ] 145 } 146 147 subsystem_name = "commonlibrary" 148 part_name = "ets_utils" 149} 150 151group("url_packages") { 152 deps = [ ":url" ] 153} 154