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("//build/ohos.gni") 15import("//foundation/filemanagement/file_api/file_api.gni") 16 17ohos_shared_library("cj_file_fs_ffi") { 18 sanitize = { 19 integer_overflow = true 20 ubsan = true 21 boundary_sanitize = true 22 cfi = true 23 cfi_cross_dso = true 24 debug = false 25 } 26 27 defines = [] 28 cflags = [ 29 "-fvisibility=hidden", 30 "-fdata-sections", 31 "-ffunction-sections", 32 "-Oz", 33 ] 34 cflags_cc = [ 35 "-fvisibility-inlines-hidden", 36 "-Oz", 37 ] 38 if (is_mingw || is_mac || is_linux) { 39 defines += [ "PREVIEW" ] 40 } 41 42 if (current_os == "ohos" && current_cpu == "x86_64") { 43 defines += [ "SIMULATOR" ] 44 } 45 if (is_ohos) { 46 defines += [ "OHOS_PLATFORM" ] 47 if (use_musl && !is_asan) { 48 defines += [ "HOOK_ENABLE" ] 49 } 50 } else if (is_mingw) { 51 defines += [ "WINDOWS_PLATFORM" ] 52 cflags_cc += [ "-std=c++17" ] 53 } else if (is_mac) { 54 defines += [ "MAC_PLATFORM" ] 55 } else if (is_linux) { 56 defines += [ "LINUX_PLATFORM" ] 57 cflags_cc += [ "-std=c++17" ] 58 } else if (is_arkui_x && target_os == "ios") { 59 defines += [ "IOS_PLATFORM" ] 60 } 61 62 include_dirs = [ 63 "${src_path}/common", 64 "${src_path}/common/napi", 65 "${src_path}/common/napi/n_async", 66 "${src_path}/common/file_helper", 67 "${src_path}/mod_fs", 68 "${src_path}/mod_fs/class_randomaccessfile", 69 "${src_path}/mod_fs/class_readeriterator", 70 "${src_path}/mod_fs/properties", 71 "${utils_path}/common/include", 72 "${utils_path}/filemgmt_libhilog", 73 "${utils_path}/filemgmt_libh", 74 "${utils_path}/filemgmt_libn/include", 75 "${file_api_path}/interfaces/kits/cj/src", 76 "${file_api_path}/interfaces/kits/native/remote_uri", 77 "${file_api_path}/interfaces/kits/native/task_signal", 78 "${file_api_path}/interfaces/kits/rust/include", 79 ] 80 81 if (!defined(defines)) { 82 defines = [] 83 } 84 85 use_exceptions = true 86 87 if (product_name != "ohos-sdk") { 88 deps = [ 89 "${file_api_path}/interfaces/kits/js:build_kits_js", 90 "${file_api_path}/interfaces/kits/js:fs", 91 "${file_api_path}/interfaces/kits/native:remote_uri_native", 92 "${file_api_path}/interfaces/kits/native:task_signal_native", 93 "${file_api_path}/interfaces/kits/rust:rust_file", 94 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 95 "${utils_path}/filemgmt_libn:filemgmt_libn", 96 ] 97 external_deps = [ 98 "ability_base:zuri", 99 "ability_runtime:ability_manager", 100 "ability_runtime:abilitykit_native", 101 "access_token:libtokenid_sdk", 102 "app_file_service:fileuri_native", 103 "bounds_checking_function:libsec_shared", 104 "bundle_framework:appexecfwk_base", 105 "bundle_framework:appexecfwk_core", 106 "c_utils:utils", 107 "data_share:datashare_common", 108 "data_share:datashare_consumer", 109 "dfs_service:distributed_file_daemon_kit_inner", 110 "hilog:libhilog", 111 "ipc:ipc_core", 112 "napi:ace_napi", 113 "napi:cj_bind_ffi", 114 "napi:cj_bind_native", 115 "samgr:samgr_proxy", 116 ] 117 sources = [ 118 "../js/src/common/file_helper/fd_guard.cpp", 119 "src/copy.cpp", 120 "src/copy_dir.cpp", 121 "src/copy_file.cpp", 122 "src/fdatasync.cpp", 123 "src/file_ffi.cpp", 124 "src/file_fs_ffi.cpp", 125 "src/file_fs_impl.cpp", 126 "src/file_impl.cpp", 127 "src/fsync.cpp", 128 "src/list_file.cpp", 129 "src/lseek.cpp", 130 "src/mkdtemp.cpp", 131 "src/move_file.cpp", 132 "src/randomAccessFile_impl.cpp", 133 "src/readerIterator_impl.cpp", 134 "src/stat_ffi.cpp", 135 "src/stream_ffi.cpp", 136 "src/stream_impl.cpp", 137 "src/symlink.cpp", 138 "src/task_signal_impl.cpp", 139 "src/translistener.cpp", 140 "src/uni_error.cpp", 141 "src/utils.cpp", 142 "src/watcher_impl.cpp", 143 ] 144 } else { 145 defines += [ "PREVIEWER" ] 146 sources = [ "src/file_fs_mock.cpp" ] 147 external_deps = [ "napi:cj_bind_ffi" ] 148 } 149 150 if (current_os == "ohos") { 151 defines += [ "OHOS_PLATFORM" ] 152 } 153 154 if (current_os == "mingw") { 155 defines += [ "WINDOWS_PLATFORM" ] 156 } 157 158 innerapi_tags = [ "platformsdk" ] 159 part_name = "file_api" 160 subsystem_name = "filemanagement" 161} 162