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 deps = [ ":convertxml_static" ] 79 subsystem_name = "commonlibrary" 80 part_name = "ets_utils" 81 82 relative_install_dir = "module" 83} 84 85ohos_source_set("convertxml_static") { 86 include_dirs = [ 87 "include", 88 "//third_party/icu/icu4c/source/common", 89 "//third_party/node/src", 90 "//third_party/libxml2/include", 91 ] 92 93 sources = [ 94 "js_convertxml.cpp", 95 "native_module_convertxml.cpp", 96 ] 97 98 deps = [ 99 ":gen_obj_src_convertxml_abc", 100 ":gen_obj_src_js_convertxml", 101 "//third_party/libxml2:static_libxml2", 102 ] 103 104 if (defined(is_arkui_x) && is_arkui_x) { 105 include_dirs += [ 106 "$plugins_root/hilog/include", 107 "$plugins_root/interfaces", 108 ] 109 deps += [ "$plugins_root/interfaces/native:plugin_log" ] 110 if (target_os == "android") { 111 deps += [ "$plugins_root/interfaces/native:ace_plugin_util_android" ] 112 defines = [ "ANDROID_PLATFORM" ] 113 } 114 deps += [ 115 "$plugins_root/libs/icu:icu_${target_os}", 116 "$plugins_root/libs/napi:napi_${target_os}", 117 "$plugins_root/libs/securec:sec_${target_os}", 118 ] 119 } else { 120 external_deps = [ "napi:ace_napi" ] 121 if (is_standard_system) { 122 external_deps += [ "hilog:libhilog" ] 123 } else { 124 external_deps += [ 125 "c_utils:utils", 126 "hilog:libhilog", 127 ] 128 } 129 deps += [ "//third_party/icu/icu4c:shared_icuuc" ] 130 } 131 132 subsystem_name = "commonlibrary" 133 part_name = "ets_utils" 134} 135 136group("convertxml_packages") { 137 deps = [ ":convertxml" ] 138} 139