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_xml.js"), 27 "--module-path", 28 rebase_path("/commonlibrary/ets_utils/js_api_module/xml"), 29 "--out-file", 30 rebase_path(outFile_Path + "/js_xml.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_xml.js" ] 37} 38 39# compile .js to .abc. 40es2abc_gen_abc("gen_xml_abc") { 41 extra_visibility = [ ":*" ] 42 src_js = rebase_path(target_out_dir + "/js_xml.js") 43 dst_file = rebase_path(target_out_dir + "/xml.abc") 44 in_puts = [ target_out_dir + "/js_xml.js" ] 45 out_puts = [ target_out_dir + "/xml.abc" ] 46 extra_args = [ "--module" ] 47 extra_dependencies = [ ":build_ts_js" ] 48} 49 50abc_output_path = get_label_info(":xml_abc", "target_out_dir") 51 52gen_obj("xml_js") { 53 input = "$target_out_dir/js_xml.js" 54 if (use_mac || use_mingw_win || use_ios || use_linux) { 55 xml_obj_path = abc_output_path + "/xml.c" 56 } else { 57 xml_obj_path = abc_output_path + "/xml.o" 58 } 59 output = xml_obj_path 60 snapshot_dep = [ ":build_ts_js" ] 61} 62 63gen_obj("xml_abc") { 64 input = "$target_out_dir/xml.abc" 65 if (use_mac || use_mingw_win || use_ios || use_linux) { 66 xml_obj_path = abc_output_path + "/xml_abc.c" 67 } else { 68 xml_obj_path = abc_output_path + "/xml_abc.o" 69 } 70 output = xml_obj_path 71 snapshot_dep = [ ":gen_xml_abc" ] 72} 73 74xml_sources = [ 75 "js_xml.cpp", 76 "js_xml_dynamic.cpp", 77 "native_module_xml.cpp", 78] 79 80ohos_shared_library("xml") { 81 branch_protector_ret = "pac_ret" 82 sanitize = { 83 cfi = true 84 cfi_cross_dso = true 85 debug = false 86 } 87 deps = [ ":xml_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("xml_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/icu/icu4c/source/common", 104 "//third_party/node/src", 105 ets_util_path, 106 ] 107 108 sources = xml_sources 109 110 deps = [ 111 ":gen_obj_src_xml_abc", 112 ":gen_obj_src_xml_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 if (is_standard_system) { 131 external_deps = [ "hilog:libhilog" ] 132 } else { 133 external_deps = [ 134 "c_utils:utils", 135 "hilog:libhilog", 136 ] 137 } 138 external_deps += [ 139 "bounds_checking_function:libsec_shared", 140 "icu:shared_icuuc", 141 "napi:ace_napi", 142 ] 143 } 144 subsystem_name = "commonlibrary" 145 part_name = "ets_utils" 146} 147 148group("xml_packages") { 149 deps = [ ":xml" ] 150} 151