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("//commonlibrary/ets_utils/ets_utils_config.gni") 17import("//foundation/arkui/ace_engine/ace_config.gni") 18import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni") 19 20# compile .ts to .js. 21action("build_ts_js") { 22 script = "${ets_util_path}/js_api_module/build_ts_js.py" 23 24 outFile_Path = target_out_dir + "/" + current_cpu 25 args = [ 26 "--dst-file", 27 rebase_path(target_out_dir + "/js_buffer.js"), 28 "--module-path", 29 rebase_path("/commonlibrary/ets_utils/js_api_module/buffer"), 30 "--out-file", 31 rebase_path(outFile_Path + "/js_buffer.js"), 32 "--out-filePath", 33 rebase_path(outFile_Path), 34 "--relative-path", 35 rebase_path("//", root_build_dir), 36 ] 37 outputs = [ target_out_dir + "/js_buffer.js" ] 38} 39 40config("buffer_config") { 41 cflags_cc = [ 42 "-std=c++17", 43 "-Wno-deprecated-declarations", 44 ] 45} 46 47base_output_path = get_label_info(":js_buffer", "target_out_dir") 48gen_obj("js_buffer") { 49 input = "$target_out_dir/js_buffer.js" 50 if (use_mac || use_mingw_win || use_ios || use_linux) { 51 js_buffer_obj_path = base_output_path + "/buffer.c" 52 } else { 53 js_buffer_obj_path = base_output_path + "/buffer.o" 54 } 55 output = js_buffer_obj_path 56 snapshot_dep = [ ":build_ts_js" ] 57} 58 59# compile .js to .abc. 60es2abc_gen_abc("gen_buffer_abc") { 61 extra_visibility = [ ":*" ] 62 src_js = rebase_path(target_out_dir + "/js_buffer.js") 63 dst_file = rebase_path(target_out_dir + "/buffer.abc") 64 in_puts = [ target_out_dir + "/js_buffer.js" ] 65 out_puts = [ target_out_dir + "/buffer.abc" ] 66 extra_args = [ "--module" ] 67 extra_dependencies = [ ":build_ts_js" ] 68} 69 70abc_output_path = get_label_info(":buffer_abc", "target_out_dir") 71gen_obj("buffer_abc") { 72 input = "$target_out_dir/buffer.abc" 73 if (use_mac || use_mingw_win || use_ios || use_linux) { 74 buffer_abc_obj_path = abc_output_path + "/buffer_abc.c" 75 } else { 76 buffer_abc_obj_path = abc_output_path + "/buffer_abc.o" 77 } 78 output = buffer_abc_obj_path 79 snapshot_dep = [ ":gen_buffer_abc" ] 80} 81 82buffer_sources = [ 83 "converter.cpp", 84 "js_blob.cpp", 85 "js_buffer.cpp", 86 "native_module_buffer.cpp", 87] 88 89ohos_shared_library("buffer") { 90 deps = [ ":buffer_static" ] 91 subsystem_name = "commonlibrary" 92 part_name = "ets_utils" 93 94 relative_install_dir = "module" 95} 96 97ohos_source_set("buffer_static") { 98 include_dirs = [ 99 "include", 100 "//third_party/icu/icu4c/source/common", 101 "//third_party/node/src", 102 ] 103 104 sources = buffer_sources 105 106 deps = [ 107 ":gen_obj_src_buffer_abc", 108 ":gen_obj_src_js_buffer", 109 ] 110 111 configs = [ ":buffer_config" ] 112 113 if (is_cross_platform_build) { 114 include_dirs += [ 115 "$plugins_root/hilog/include", 116 "$plugins_root/interfaces", 117 ] 118 if (target_os == "android") { 119 defines = [ "ANDROID_PLATFORM" ] 120 } else if (target_os == "ios") { 121 defines = [ "IOS_PLATFORM" ] 122 } 123 deps += [ 124 "$plugins_root/libs/icu:icu_${target_os}", 125 "$plugins_root/libs/napi:napi_${target_os}", 126 "$plugins_root/libs/securec:sec_${target_os}", 127 ] 128 } else { 129 deps += [ 130 "//third_party/bounds_checking_function:libsec_shared", 131 "//third_party/icu/icu4c:shared_icuuc", 132 ] 133 134 external_deps = [ 135 "hilog:libhilog", 136 "napi:ace_napi", 137 ] 138 139 deps += [ "//third_party/icu/icu4c:shared_icuuc" ] 140 } 141 subsystem_name = "commonlibrary" 142 part_name = "ets_utils" 143} 144 145group("buffer_packages") { 146 public_deps = [ ":buffer" ] 147} 148