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