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_buffer.js"), 27 "--module-path", 28 rebase_path("/commonlibrary/ets_utils/js_api_module/buffer"), 29 "--out-file", 30 rebase_path(outFile_Path + "/js_buffer.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_buffer.js" ] 37} 38 39config("buffer_config") { 40 cflags_cc = [ 41 "-std=c++17", 42 "-Wno-deprecated-declarations", 43 ] 44} 45 46base_output_path = get_label_info(":js_buffer", "target_out_dir") 47gen_obj("js_buffer") { 48 input = "$target_out_dir/js_buffer.js" 49 if (use_mac || use_mingw_win || use_ios || use_linux) { 50 js_buffer_obj_path = base_output_path + "/buffer.c" 51 } else { 52 js_buffer_obj_path = base_output_path + "/buffer.o" 53 } 54 output = js_buffer_obj_path 55 snapshot_dep = [ ":build_ts_js" ] 56} 57 58# compile .js to .abc. 59es2abc_gen_abc("gen_buffer_abc") { 60 extra_visibility = [ ":*" ] 61 src_js = rebase_path(target_out_dir + "/js_buffer.js") 62 dst_file = rebase_path(target_out_dir + "/buffer.abc") 63 in_puts = [ target_out_dir + "/js_buffer.js" ] 64 out_puts = [ target_out_dir + "/buffer.abc" ] 65 extra_args = [ "--module" ] 66 extra_dependencies = [ ":build_ts_js" ] 67} 68 69abc_output_path = get_label_info(":buffer_abc", "target_out_dir") 70gen_obj("buffer_abc") { 71 input = "$target_out_dir/buffer.abc" 72 if (use_mac || use_mingw_win || use_ios || use_linux) { 73 buffer_abc_obj_path = abc_output_path + "/buffer_abc.c" 74 } else { 75 buffer_abc_obj_path = abc_output_path + "/buffer_abc.o" 76 } 77 output = buffer_abc_obj_path 78 snapshot_dep = [ ":gen_buffer_abc" ] 79} 80 81buffer_sources = [ 82 "converter.cpp", 83 "js_blob.cpp", 84 "js_buffer.cpp", 85 "native_module_buffer.cpp", 86] 87 88ohos_shared_library("buffer") { 89 branch_protector_ret = "pac_ret" 90 sanitize = { 91 cfi = true 92 cfi_cross_dso = true 93 debug = false 94 } 95 deps = [ ":buffer_static" ] 96 external_deps = [ "hilog:libhilog" ] 97 subsystem_name = "commonlibrary" 98 part_name = "ets_utils" 99 100 relative_install_dir = "module" 101} 102 103ohos_source_set("buffer_static") { 104 branch_protector_ret = "pac_ret" 105 sanitize = { 106 cfi = true 107 cfi_cross_dso = true 108 debug = false 109 } 110 include_dirs = [ 111 "include", 112 ets_util_path, 113 ] 114 115 sources = buffer_sources 116 117 deps = [ 118 ":gen_obj_src_buffer_abc", 119 ":gen_obj_src_js_buffer", 120 ] 121 122 configs = [ ":buffer_config" ] 123 124 if (is_arkui_x) { 125 include_dirs += [ 126 "$plugins_root/hilog/include", 127 "$plugins_root/interfaces", 128 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 129 ] 130 if (target_os == "android") { 131 defines = [ "ANDROID_PLATFORM" ] 132 } else if (target_os == "ios") { 133 defines = [ "IOS_PLATFORM" ] 134 } 135 deps += [ 136 "$plugins_root/libs/icu:icu_${target_os}", 137 "$plugins_root/libs/napi:napi_${target_os}", 138 "$plugins_root/libs/securec:sec_${target_os}", 139 ] 140 } else { 141 external_deps = [ 142 "bounds_checking_function:libsec_shared", 143 "hilog:libhilog", 144 "icu:shared_icuuc", 145 "napi:ace_napi", 146 ] 147 } 148 subsystem_name = "commonlibrary" 149 part_name = "ets_utils" 150} 151 152group("buffer_packages") { 153 public_deps = [ ":buffer" ] 154} 155