15bebb993Sopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd. 25bebb993Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 35bebb993Sopenharmony_ci# you may not use this file except in compliance with the License. 45bebb993Sopenharmony_ci# You may obtain a copy of the License at 55bebb993Sopenharmony_ci# 65bebb993Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 75bebb993Sopenharmony_ci# 85bebb993Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 95bebb993Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 105bebb993Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 115bebb993Sopenharmony_ci# See the License for the specific language governing permissions and 125bebb993Sopenharmony_ci# limitations under the License. 135bebb993Sopenharmony_ci 145bebb993Sopenharmony_ciimport("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") 155bebb993Sopenharmony_ciimport("//foundation/filemanagement/file_api/file_api.gni") 165bebb993Sopenharmony_ciimport("//foundation/filemanagement/file_api/interfaces/kits/ts/gen_obj.gni") 175bebb993Sopenharmony_ci 185bebb993Sopenharmony_ci# compile .ts to .js. 195bebb993Sopenharmony_ciaction("build_streamrw_js") { 205bebb993Sopenharmony_ci script = "${file_api_path}/interfaces/kits/ts/streamrw/build_ts_js.py" 215bebb993Sopenharmony_ci 225bebb993Sopenharmony_ci outFile_Path = target_out_dir + "/" + current_cpu 235bebb993Sopenharmony_ci args = [ 245bebb993Sopenharmony_ci "--dst-file", 255bebb993Sopenharmony_ci rebase_path(target_out_dir + "/streamrw.js"), 265bebb993Sopenharmony_ci "--module-path", 275bebb993Sopenharmony_ci rebase_path( 285bebb993Sopenharmony_ci "/foundation/filemanagement/file_api/interfaces/kits/ts/streamrw"), 295bebb993Sopenharmony_ci "--out-file", 305bebb993Sopenharmony_ci rebase_path(outFile_Path + "/streamrw.js"), 315bebb993Sopenharmony_ci "--out-filePath", 325bebb993Sopenharmony_ci rebase_path(outFile_Path), 335bebb993Sopenharmony_ci "--relative-path", 345bebb993Sopenharmony_ci rebase_path("//", root_build_dir), 355bebb993Sopenharmony_ci ] 365bebb993Sopenharmony_ci outputs = [ target_out_dir + "/streamrw.js" ] 375bebb993Sopenharmony_ci} 385bebb993Sopenharmony_ci 395bebb993Sopenharmony_ci# compile .js to .abc. 405bebb993Sopenharmony_cies2abc_gen_abc("gen_streamrw_abc") { 415bebb993Sopenharmony_ci extra_visibility = [ ":*" ] 425bebb993Sopenharmony_ci src_js = rebase_path(target_out_dir + "/streamrw.js") 435bebb993Sopenharmony_ci dst_file = rebase_path(target_out_dir + "/streamrw.abc") 445bebb993Sopenharmony_ci in_puts = [ target_out_dir + "/streamrw.js" ] 455bebb993Sopenharmony_ci out_puts = [ target_out_dir + "/streamrw.abc" ] 465bebb993Sopenharmony_ci extra_args = [ "--module" ] 475bebb993Sopenharmony_ci extra_dependencies = [ ":build_streamrw_js" ] 485bebb993Sopenharmony_ci} 495bebb993Sopenharmony_ci 505bebb993Sopenharmony_ciabc_output_path = get_label_info(":streamrw_abc", "target_out_dir") 515bebb993Sopenharmony_ci 525bebb993Sopenharmony_cigen_obj("streamrw_js") { 535bebb993Sopenharmony_ci input = "$target_out_dir/streamrw.js" 545bebb993Sopenharmony_ci if (use_mac || use_mingw_win || use_ios || use_linux) { 555bebb993Sopenharmony_ci stream_js_obj_path = abc_output_path + "/streamrw.c" 565bebb993Sopenharmony_ci } else { 575bebb993Sopenharmony_ci stream_js_obj_path = abc_output_path + "/streamrw.o" 585bebb993Sopenharmony_ci } 595bebb993Sopenharmony_ci output = stream_js_obj_path 605bebb993Sopenharmony_ci snapshot_dep = [ ":build_streamrw_js" ] 615bebb993Sopenharmony_ci} 625bebb993Sopenharmony_ci 635bebb993Sopenharmony_cigen_obj("streamrw_abc") { 645bebb993Sopenharmony_ci input = "$target_out_dir/streamrw.abc" 655bebb993Sopenharmony_ci if (use_mac || use_mingw_win || use_ios || use_linux) { 665bebb993Sopenharmony_ci stream_js_obj_path = abc_output_path + "/streamrw_abc.c" 675bebb993Sopenharmony_ci } else { 685bebb993Sopenharmony_ci stream_js_obj_path = abc_output_path + "/streamrw_abc.o" 695bebb993Sopenharmony_ci } 705bebb993Sopenharmony_ci output = stream_js_obj_path 715bebb993Sopenharmony_ci snapshot_dep = [ ":gen_streamrw_abc" ] 725bebb993Sopenharmony_ci} 735bebb993Sopenharmony_ci 745bebb993Sopenharmony_cistreamrw_sources = [ "native_module_streamrw.cpp" ] 755bebb993Sopenharmony_ci 765bebb993Sopenharmony_ciconfig("optimize-size") { 775bebb993Sopenharmony_ci cflags = [ 785bebb993Sopenharmony_ci "-fdata-sections", 795bebb993Sopenharmony_ci "-ffunction-sections", 805bebb993Sopenharmony_ci "-Oz", 815bebb993Sopenharmony_ci ] 825bebb993Sopenharmony_ci cflags_cc = [ 835bebb993Sopenharmony_ci "-fvisibility-inlines-hidden", 845bebb993Sopenharmony_ci "-Oz", 855bebb993Sopenharmony_ci ] 865bebb993Sopenharmony_ci} 875bebb993Sopenharmony_ci 885bebb993Sopenharmony_ciohos_shared_library("streamrw") { 895bebb993Sopenharmony_ci configs = [ ":optimize-size" ] 905bebb993Sopenharmony_ci branch_protector_ret = "pac_ret" 915bebb993Sopenharmony_ci sanitize = { 925bebb993Sopenharmony_ci integer_overflow = true 935bebb993Sopenharmony_ci ubsan = true 945bebb993Sopenharmony_ci boundary_sanitize = true 955bebb993Sopenharmony_ci cfi = true 965bebb993Sopenharmony_ci cfi_cross_dso = true 975bebb993Sopenharmony_ci debug = false 985bebb993Sopenharmony_ci } 995bebb993Sopenharmony_ci 1005bebb993Sopenharmony_ci deps = [ ":streamrw_static" ] 1015bebb993Sopenharmony_ci subsystem_name = "filemanagement" 1025bebb993Sopenharmony_ci part_name = "file_api" 1035bebb993Sopenharmony_ci relative_install_dir = "module/file" 1045bebb993Sopenharmony_ci} 1055bebb993Sopenharmony_ci 1065bebb993Sopenharmony_ciohos_source_set("streamrw_static") { 1075bebb993Sopenharmony_ci include_dirs = [ "include" ] 1085bebb993Sopenharmony_ci sources = streamrw_sources 1095bebb993Sopenharmony_ci 1105bebb993Sopenharmony_ci branch_protector_ret = "pac_ret" 1115bebb993Sopenharmony_ci sanitize = { 1125bebb993Sopenharmony_ci integer_overflow = true 1135bebb993Sopenharmony_ci ubsan = true 1145bebb993Sopenharmony_ci boundary_sanitize = true 1155bebb993Sopenharmony_ci cfi = true 1165bebb993Sopenharmony_ci cfi_cross_dso = true 1175bebb993Sopenharmony_ci debug = false 1185bebb993Sopenharmony_ci } 1195bebb993Sopenharmony_ci 1205bebb993Sopenharmony_ci deps = [ 1215bebb993Sopenharmony_ci ":gen_obj_src_streamrw_abc", 1225bebb993Sopenharmony_ci ":gen_obj_src_streamrw_js", 1235bebb993Sopenharmony_ci ] 1245bebb993Sopenharmony_ci external_deps = [ 1255bebb993Sopenharmony_ci "hilog:libhilog", 1265bebb993Sopenharmony_ci "napi:ace_napi", 1275bebb993Sopenharmony_ci ] 1285bebb993Sopenharmony_ci subsystem_name = "filemanagement" 1295bebb993Sopenharmony_ci part_name = "file_api" 1305bebb993Sopenharmony_ci} 1315bebb993Sopenharmony_ci 1325bebb993Sopenharmony_cigroup("streamrw_packages") { 1335bebb993Sopenharmony_ci public_deps = [ ":streamrw" ] 1345bebb993Sopenharmony_ci} 135