1# Copyright (c) 2024 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("//commonlibrary/ets_utils/js_util_module/stream/stream_gen_obj.gni") 18 19# compile .ts to .js. 20action("build_ts_js") { 21 script = "$util_module/build_ts_js.py" 22 outFile_Path = target_out_dir + "/" + current_cpu 23 args = [ 24 "--dst-file", 25 rebase_path(target_out_dir + "/stream_js.js"), 26 "--module-path", 27 rebase_path("/commonlibrary/ets_utils/js_util_module/stream"), 28 "--out-file", 29 rebase_path(outFile_Path + "/stream_js.js"), 30 "--out-filePath", 31 rebase_path(outFile_Path), 32 "--relative-path", 33 rebase_path("//", root_build_dir), 34 ] 35 outputs = [ target_out_dir + "/stream_js.js" ] 36} 37 38# compile .js to .abc. 39es2abc_gen_abc("gen_stream_abc") { 40 extra_visibility = [ ":*" ] 41 src_js = rebase_path(target_out_dir + "/stream_js.js") 42 dst_file = rebase_path(target_out_dir + "/stream.abc") 43 in_puts = [ target_out_dir + "/stream_js.js" ] 44 out_puts = [ target_out_dir + "/stream.abc" ] 45 extra_args = [ "--module" ] 46 extra_dependencies = [ ":build_ts_js" ] 47} 48 49abc_output_path = get_label_info(":stream_abc", "target_out_dir") 50 51gen_obj("stream_js") { 52 input = "$target_out_dir/stream_js.js" 53 if (use_mac || use_mingw_win || use_ios || use_linux) { 54 stream_js_obj_path = abc_output_path + "/stream.c" 55 } else { 56 stream_js_obj_path = abc_output_path + "/stream.o" 57 } 58 output = stream_js_obj_path 59 snapshot_dep = [ ":build_ts_js" ] 60} 61 62gen_obj("stream_abc") { 63 input = "$target_out_dir/stream.abc" 64 if (use_mac || use_mingw_win || use_ios || use_linux) { 65 stream_js_obj_path = abc_output_path + "/stream_abc.c" 66 } else { 67 stream_js_obj_path = abc_output_path + "/stream_abc.o" 68 } 69 output = stream_js_obj_path 70 snapshot_dep = [ ":gen_stream_abc" ] 71} 72 73stream_sources = [ "native_module_stream.cpp" ] 74 75ohos_shared_library("stream") { 76 deps = [ ":stream_static" ] 77 subsystem_name = "commonlibrary" 78 part_name = "ets_utils" 79 relative_install_dir = "module/util" 80} 81 82ohos_source_set("stream_static") { 83 include_dirs = [ "include" ] 84 sources = stream_sources 85 86 deps = [ 87 ":gen_obj_src_stream_abc", 88 ":gen_obj_src_stream_js", 89 ] 90 91 if (is_arkui_x) { 92 include_dirs += [ 93 "$plugins_root/hilog/include", 94 "$plugins_root/interfaces", 95 ] 96 97 if (target_os == "android") { 98 defines = [ "ANDROID_PLATFORM" ] 99 } else if (target_os == "ios") { 100 defines = [ "IOS_PLATFORM" ] 101 } 102 deps += [ "$plugins_root/libs/napi:napi_${target_os}" ] 103 } else { 104 external_deps = [ 105 "hilog:libhilog", 106 "napi:ace_napi", 107 ] 108 } 109 subsystem_name = "commonlibrary" 110 part_name = "ets_utils" 111} 112 113group("stream_packages") { 114 public_deps = [ ":stream" ] 115} 116