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 ets_util_path, 104 ] 105 106 sources = xml_sources 107 108 deps = [ 109 ":gen_obj_src_xml_abc", 110 ":gen_obj_src_xml_js", 111 ] 112 113 if (is_arkui_x) { 114 include_dirs += [ 115 "$plugins_root/hilog/include", 116 "$plugins_root/interfaces", 117 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 118 ] 119 if (target_os == "android") { 120 defines = [ "ANDROID_PLATFORM" ] 121 } 122 deps += [ 123 "$plugins_root/libs/icu:icu_${target_os}", 124 "$plugins_root/libs/napi:napi_${target_os}", 125 "$plugins_root/libs/securec:sec_${target_os}", 126 ] 127 } else { 128 if (is_standard_system) { 129 external_deps = [ "hilog:libhilog" ] 130 } else { 131 external_deps = [ 132 "c_utils:utils", 133 "hilog:libhilog", 134 ] 135 } 136 external_deps += [ 137 "bounds_checking_function:libsec_shared", 138 "icu:shared_icuuc", 139 "napi:ace_napi", 140 ] 141 } 142 subsystem_name = "commonlibrary" 143 part_name = "ets_utils" 144} 145 146group("xml_packages") { 147 deps = [ ":xml" ] 148} 149