# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") import("//foundation/filemanagement/file_api/file_api.gni") import("//foundation/filemanagement/file_api/interfaces/kits/ts/gen_obj.gni") # compile .ts to .js. action("build_streamhash_js") { script = "${file_api_path}/interfaces/kits/ts/streamhash/build_ts_js.py" outFile_Path = target_out_dir + "/" + current_cpu args = [ "--dst-file", rebase_path(target_out_dir + "/streamhash.js"), "--module-path", rebase_path( "/foundation/filemanagement/file_api/interfaces/kits/ts/streamhash"), "--out-file", rebase_path(outFile_Path + "/streamhash.js"), "--out-filePath", rebase_path(outFile_Path), "--relative-path", rebase_path("//", root_build_dir), ] outputs = [ target_out_dir + "/streamhash.js" ] } # compile .js to .abc. es2abc_gen_abc("gen_streamhash_abc") { extra_visibility = [ ":*" ] src_js = rebase_path(target_out_dir + "/streamhash.js") dst_file = rebase_path(target_out_dir + "/streamhash.abc") in_puts = [ target_out_dir + "/streamhash.js" ] out_puts = [ target_out_dir + "/streamhash.abc" ] extra_args = [ "--module" ] extra_dependencies = [ ":build_streamhash_js" ] } abc_output_path = get_label_info(":streamhash_abc", "target_out_dir") gen_obj("streamhash_js") { input = "$target_out_dir/streamhash.js" if (use_mac || use_mingw_win || use_ios || use_linux) { stream_js_obj_path = abc_output_path + "/streamhash.c" } else { stream_js_obj_path = abc_output_path + "/streamhash.o" } output = stream_js_obj_path snapshot_dep = [ ":build_streamhash_js" ] } gen_obj("streamhash_abc") { input = "$target_out_dir/streamhash.abc" if (use_mac || use_mingw_win || use_ios || use_linux) { stream_js_obj_path = abc_output_path + "/streamhash_abc.c" } else { stream_js_obj_path = abc_output_path + "/streamhash_abc.o" } output = stream_js_obj_path snapshot_dep = [ ":gen_streamhash_abc" ] } streamhash_sources = [ "native_module_streamhash.cpp" ] config("optimize-size") { cflags = [ "-fdata-sections", "-ffunction-sections", "-Oz", ] cflags_cc = [ "-fvisibility-inlines-hidden", "-Oz", ] } ohos_shared_library("streamhash") { configs = [ ":optimize-size" ] branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true ubsan = true boundary_sanitize = true cfi = true cfi_cross_dso = true debug = false } deps = [ ":streamhash_static" ] subsystem_name = "filemanagement" part_name = "file_api" relative_install_dir = "module/file" } ohos_source_set("streamhash_static") { include_dirs = [ "include" ] sources = streamhash_sources branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true ubsan = true boundary_sanitize = true cfi = true cfi_cross_dso = true debug = false } deps = [ ":gen_obj_src_streamhash_abc", ":gen_obj_src_streamhash_js", ] external_deps = [ "hilog:libhilog", "napi:ace_napi", ] subsystem_name = "filemanagement" part_name = "file_api" } group("streamhash_packages") { public_deps = [ ":streamhash" ] }