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/ts2panda/ts2abc_config.gni") 15import("//build/ohos.gni") 16import("//build/ohos/ace/ace.gni") 17import("//foundation/arkui/ace_engine/ace_config.gni") 18 19# compile .ts to .js. 20action("build_ts_js") { 21 script = "//commonlibrary/ets_utils/js_api_module/build_ts_js.py" 22 23 args = [ 24 "--dst-file", 25 rebase_path(target_out_dir + "/js_buffer.js"), 26 "--module-path", 27 rebase_path("/commonlibrary/ets_utils/js_api_module/buffer"), 28 "--out-file", 29 rebase_path("./out/js_buffer.js"), 30 "--relative-path", 31 rebase_path("//", root_build_dir), 32 ] 33 outputs = [ target_out_dir + "/js_buffer.js" ] 34} 35 36base_output_path = get_label_info(":js_buffer", "target_out_dir") 37js_buffer_obj_path = base_output_path + "/buffer.o" 38gen_js_obj("js_buffer") { 39 input = "$target_out_dir/js_buffer.js" 40 output = js_buffer_obj_path 41 dep = ":build_ts_js" 42} 43 44# compile .js to .abc. 45action("gen_buffer_abc") { 46 visibility = [ ":*" ] 47 script = "//arkcompiler/ets_frontend/ts2panda/scripts/generate_js_bytecode.py" 48 49 args = [ 50 "--src-js", 51 rebase_path(target_out_dir + "/js_buffer.js"), 52 "--dst-file", 53 rebase_path(target_out_dir + "/buffer.abc"), 54 "--node", 55 rebase_path("${node_path}"), 56 "--frontend-tool-path", 57 rebase_path("${ts2abc_build_path}"), 58 "--node-modules", 59 rebase_path("${node_modules}"), 60 "--module", 61 ] 62 deps = [ 63 ":build_ts_js", 64 "//arkcompiler/ets_frontend/ts2panda:ark_ts2abc_build", 65 ] 66 67 inputs = [ target_out_dir + "/js_buffer.js" ] 68 outputs = [ target_out_dir + "/buffer.abc" ] 69} 70 71abc_output_path = get_label_info(":buffer_abc", "target_out_dir") 72buffer_abc_obj_path = abc_output_path + "/buffer_abc.o" 73gen_js_obj("buffer_abc") { 74 input = "$target_out_dir/buffer.abc" 75 output = buffer_abc_obj_path 76 dep = ":gen_buffer_abc" 77} 78 79ohos_shared_library("buffer") { 80 include_dirs = [ 81 "//third_party/icu/icu4c/source/common", 82 "//third_party/node/src", 83 "//foundation/arkui/napi/interfaces/kits", 84 "//commonlibrary/ets_utils/js_api_module/buffer", 85 ] 86 87 sources = [ 88 "converter.cpp", 89 "js_blob.cpp", 90 "js_buffer.cpp", 91 "native_module_buffer.cpp", 92 ] 93 94 external_deps = [ "c_utils:utils" ] 95 deps = [ 96 ":buffer_abc", 97 ":js_buffer", 98 "//commonlibrary/ets_utils/js_api_module/buffer/:js_buffer", 99 "//foundation/arkui/napi/:ace_napi", 100 "//third_party/icu/icu4c:shared_icuuc", 101 ] 102 103 if (is_standard_system) { 104 external_deps += [ "hiviewdfx_hilog_native:libhilog" ] 105 } else { 106 external_deps += [ "hilog:libhilog" ] 107 } 108 subsystem_name = "commonlibrary" 109 part_name = "ets_utils" 110 111 relative_install_dir = "module" 112} 113 114ohos_static_library("buffer_static") { 115 include_dirs = [ 116 "//third_party/icu/icu4c/source/common", 117 "//third_party/node/src", 118 "//foundation/arkui/napi/interfaces/kits", 119 "//commonlibrary/ets_utils/js_api_module/buffer", 120 ] 121 122 sources = [ 123 "converter.cpp", 124 "js_blob.cpp", 125 "js_buffer.cpp", 126 "native_module_buffer.cpp", 127 ] 128 129 external_deps = [ "c_utils:utils" ] 130 deps = [ 131 ":buffer_abc", 132 ":js_buffer", 133 "//commonlibrary/ets_utils/js_api_module/buffer/:js_buffer", 134 "//foundation/arkui/napi/:ace_napi", 135 "//third_party/icu/icu4c:shared_icuuc", 136 ] 137 138 if (is_standard_system) { 139 external_deps += [ "hiviewdfx_hilog_native:libhilog" ] 140 } else { 141 external_deps += [ "hilog:libhilog" ] 142 } 143 subsystem_name = "commonlibrary" 144 part_name = "ets_utils" 145} 146 147group("buffer_packages") { 148 deps = [ ":buffer" ] 149} 150