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