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