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("//foundation/filemanagement/file_api/file_api.gni") 16import("//foundation/filemanagement/file_api/interfaces/kits/ts/gen_obj.gni") 17 18# compile .ts to .js. 19action("build_streamhash_js") { 20 script = "${file_api_path}/interfaces/kits/ts/streamhash/build_ts_js.py" 21 22 outFile_Path = target_out_dir + "/" + current_cpu 23 args = [ 24 "--dst-file", 25 rebase_path(target_out_dir + "/streamhash.js"), 26 "--module-path", 27 rebase_path( 28 "/foundation/filemanagement/file_api/interfaces/kits/ts/streamhash"), 29 "--out-file", 30 rebase_path(outFile_Path + "/streamhash.js"), 31 "--out-filePath", 32 rebase_path(outFile_Path), 33 "--relative-path", 34 rebase_path("//", root_build_dir), 35 ] 36 outputs = [ target_out_dir + "/streamhash.js" ] 37} 38 39# compile .js to .abc. 40es2abc_gen_abc("gen_streamhash_abc") { 41 extra_visibility = [ ":*" ] 42 src_js = rebase_path(target_out_dir + "/streamhash.js") 43 dst_file = rebase_path(target_out_dir + "/streamhash.abc") 44 in_puts = [ target_out_dir + "/streamhash.js" ] 45 out_puts = [ target_out_dir + "/streamhash.abc" ] 46 extra_args = [ "--module" ] 47 extra_dependencies = [ ":build_streamhash_js" ] 48} 49 50abc_output_path = get_label_info(":streamhash_abc", "target_out_dir") 51 52gen_obj("streamhash_js") { 53 input = "$target_out_dir/streamhash.js" 54 if (use_mac || use_mingw_win || use_ios || use_linux) { 55 stream_js_obj_path = abc_output_path + "/streamhash.c" 56 } else { 57 stream_js_obj_path = abc_output_path + "/streamhash.o" 58 } 59 output = stream_js_obj_path 60 snapshot_dep = [ ":build_streamhash_js" ] 61} 62 63gen_obj("streamhash_abc") { 64 input = "$target_out_dir/streamhash.abc" 65 if (use_mac || use_mingw_win || use_ios || use_linux) { 66 stream_js_obj_path = abc_output_path + "/streamhash_abc.c" 67 } else { 68 stream_js_obj_path = abc_output_path + "/streamhash_abc.o" 69 } 70 output = stream_js_obj_path 71 snapshot_dep = [ ":gen_streamhash_abc" ] 72} 73 74streamhash_sources = [ "native_module_streamhash.cpp" ] 75 76config("optimize-size") { 77 cflags = [ 78 "-fdata-sections", 79 "-ffunction-sections", 80 "-Oz", 81 ] 82 cflags_cc = [ 83 "-fvisibility-inlines-hidden", 84 "-Oz", 85 ] 86} 87 88ohos_shared_library("streamhash") { 89 configs = [ ":optimize-size" ] 90 branch_protector_ret = "pac_ret" 91 sanitize = { 92 integer_overflow = true 93 ubsan = true 94 boundary_sanitize = true 95 cfi = true 96 cfi_cross_dso = true 97 debug = false 98 } 99 100 deps = [ ":streamhash_static" ] 101 subsystem_name = "filemanagement" 102 part_name = "file_api" 103 relative_install_dir = "module/file" 104} 105 106ohos_source_set("streamhash_static") { 107 include_dirs = [ "include" ] 108 sources = streamhash_sources 109 110 branch_protector_ret = "pac_ret" 111 sanitize = { 112 integer_overflow = true 113 ubsan = true 114 boundary_sanitize = true 115 cfi = true 116 cfi_cross_dso = true 117 debug = false 118 } 119 120 deps = [ 121 ":gen_obj_src_streamhash_abc", 122 ":gen_obj_src_streamhash_js", 123 ] 124 external_deps = [ 125 "hilog:libhilog", 126 "napi:ace_napi", 127 ] 128 subsystem_name = "filemanagement" 129 part_name = "file_api" 130} 131 132group("streamhash_packages") { 133 public_deps = [ ":streamhash" ] 134} 135