1# Copyright (c) 2021-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 17file_common_src = [ 18 "src/common/file_helper/fd_guard.cpp", 19 "src/common/napi/n_async/n_async_work_callback.cpp", 20 "src/common/napi/n_async/n_async_work_promise.cpp", 21 "src/common/napi/n_async/n_ref.cpp", 22 "src/common/napi/n_class.cpp", 23 "src/common/napi/n_func_arg.cpp", 24 "src/common/napi/n_val.cpp", 25 "src/common/uni_error.cpp", 26] 27 28config("kits_public_config") { 29 visibility = [ ":*" ] 30 31 include_dirs = [ "src/mod_securitylabel" ] 32} 33 34ohos_shared_library("fileio") { 35 cflags = [ 36 "-fvisibility=hidden", 37 "-fdata-sections", 38 "-ffunction-sections", 39 "-Oz", 40 ] 41 cflags_cc = [ 42 "-fvisibility-inlines-hidden", 43 "-Oz", 44 ] 45 branch_protector_ret = "pac_ret" 46 sanitize = { 47 integer_overflow = true 48 ubsan = true 49 boundary_sanitize = true 50 cfi = true 51 cfi_cross_dso = true 52 debug = false 53 } 54 55 subsystem_name = "filemanagement" 56 part_name = "file_api" 57 58 relative_install_dir = "module" 59 60 include_dirs = [ 61 "${arkui_napi_path}/interfaces/kits", 62 "src/common/file_helper", 63 "src/common/napi", 64 "src/common/napi/n_async", 65 "//third_party/node/src", 66 "//third_party/libuv/include", 67 "//third_party/openssl/include", 68 "${utils_path}/common/include", 69 ] 70 71 sources = file_common_src 72 sources += [ 73 "src/common/file_helper/hash_file.cpp", 74 "src/mod_fileio/class_constants/constants.cpp", 75 "src/mod_fileio/class_dir/dir_n_exporter.cpp", 76 "src/mod_fileio/class_dirent/dirent_n_exporter.cpp", 77 "src/mod_fileio/class_stat/stat_n_exporter.cpp", 78 "src/mod_fileio/class_stream/flush.cpp", 79 "src/mod_fileio/class_stream/stream_n_exporter.cpp", 80 "src/mod_fileio/class_watcher/watcher_n_exporter.cpp", 81 "src/mod_fileio/common_func.cpp", 82 "src/mod_fileio/module.cpp", 83 "src/mod_fileio/properties/chmod.cpp", 84 "src/mod_fileio/properties/chown.cpp", 85 "src/mod_fileio/properties/close.cpp", 86 "src/mod_fileio/properties/copy_file.cpp", 87 "src/mod_fileio/properties/create_stream.cpp", 88 "src/mod_fileio/properties/fchmod.cpp", 89 "src/mod_fileio/properties/fchown.cpp", 90 "src/mod_fileio/properties/fdatasync.cpp", 91 "src/mod_fileio/properties/fdopen_stream.cpp", 92 "src/mod_fileio/properties/fstat.cpp", 93 "src/mod_fileio/properties/fsync.cpp", 94 "src/mod_fileio/properties/ftruncate.cpp", 95 "src/mod_fileio/properties/hash.cpp", 96 "src/mod_fileio/properties/lchown.cpp", 97 "src/mod_fileio/properties/link.cpp", 98 "src/mod_fileio/properties/lseek.cpp", 99 "src/mod_fileio/properties/lstat.cpp", 100 "src/mod_fileio/properties/mkdtemp.cpp", 101 "src/mod_fileio/properties/open.cpp", 102 "src/mod_fileio/properties/open_dir.cpp", 103 "src/mod_fileio/properties/posix_fallocate.cpp", 104 "src/mod_fileio/properties/prop_n_exporter.cpp", 105 "src/mod_fileio/properties/read_dir.cpp", 106 "src/mod_fileio/properties/read_text.cpp", 107 "src/mod_fileio/properties/rename.cpp", 108 "src/mod_fileio/properties/rmdir.cpp", 109 "src/mod_fileio/properties/rmdirent.cpp", 110 "src/mod_fileio/properties/stat.cpp", 111 "src/mod_fileio/properties/symlink.cpp", 112 "src/mod_fileio/properties/truncate.cpp", 113 "src/mod_fileio/properties/watcher.cpp", 114 ] 115 116 deps = [ 117 "${file_api_path}/interfaces/kits/native:remote_uri_native", 118 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 119 "//third_party/openssl:libcrypto_shared", 120 ] 121 122 use_exceptions = true 123 124 external_deps = [ 125 "ability_base:zuri", 126 "bounds_checking_function:libsec_shared", 127 "hilog:libhilog", 128 "napi:ace_napi", 129 ] 130 defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 131} 132 133ohos_shared_library("fs") { 134 subsystem_name = "filemanagement" 135 part_name = "file_api" 136 137 relative_install_dir = "module/file" 138 139 include_dirs = [ 140 "${filemanagement_service_path}/distributedfiledaemon/include/ipc", 141 "${src_path}/common", 142 "${src_path}/common/file_helper", 143 "${src_path}/mod_fs", 144 "${src_path}/mod_fs/properties", 145 "${src_path}/mod_fs/properties/copy_listener", 146 "${utils_path}/common/include", 147 "//third_party/libuv/include", 148 ] 149 150 sources = [ 151 "src/common/file_helper/fd_guard.cpp", 152 "src/mod_fs/class_file/file_n_exporter.cpp", 153 "src/mod_fs/class_stat/stat_n_exporter.cpp", 154 "src/mod_fs/common_func.cpp", 155 "src/mod_fs/module.cpp", 156 "src/mod_fs/properties/close.cpp", 157 "src/mod_fs/properties/fdatasync.cpp", 158 "src/mod_fs/properties/fsync.cpp", 159 "src/mod_fs/properties/lstat.cpp", 160 "src/mod_fs/properties/mkdtemp.cpp", 161 "src/mod_fs/properties/open.cpp", 162 "src/mod_fs/properties/prop_n_exporter.cpp", 163 "src/mod_fs/properties/rename.cpp", 164 "src/mod_fs/properties/rmdirent.cpp", 165 "src/mod_fs/properties/stat.cpp", 166 "src/mod_fs/properties/truncate.cpp", 167 "src/mod_fs/properties/utimes.cpp", 168 ] 169 170 cflags_cc = [ "-std=c++17" ] 171 172 deps = [ 173 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 174 "${utils_path}/filemgmt_libn:filemgmt_libn", 175 ] 176 177 use_exceptions = true 178 179 if (use_mingw_win) { 180 defines = [ "WIN_PLATFORM" ] 181 } 182 if (use_mac) { 183 defines = [ "IOS_PLATFORM" ] 184 } 185 186 external_deps = [ 187 "hilog:libhilog", 188 "napi:ace_napi", 189 ] 190 191 if (!use_mingw_win && !use_mac) { 192 cflags = [ 193 "-fvisibility=hidden", 194 "-fdata-sections", 195 "-ffunction-sections", 196 "-Oz", 197 ] 198 cflags_cc += [ 199 "-fvisibility-inlines-hidden", 200 "-Oz", 201 ] 202 defines = [ "FILE_API_TRACE" ] 203 branch_protector_ret = "pac_ret" 204 sanitize = { 205 integer_overflow = true 206 ubsan = true 207 boundary_sanitize = true 208 cfi = true 209 cfi_cross_dso = true 210 debug = false 211 } 212 213 include_dirs += [ 214 "${file_api_path}/interfaces/kits/rust/include", 215 "${filemanagement_service_path}/distributedfiledaemon/include/ipc", 216 ] 217 sources += [ 218 "src/mod_fs/class_randomaccessfile/randomaccessfile_n_exporter.cpp", 219 "src/mod_fs/class_readeriterator/readeriterator_n_exporter.cpp", 220 "src/mod_fs/class_stream/stream_n_exporter.cpp", 221 "src/mod_fs/class_tasksignal/task_signal_entity.cpp", 222 "src/mod_fs/class_tasksignal/task_signal_n_exporter.cpp", 223 "src/mod_fs/class_watcher/watcher_entity.cpp", 224 "src/mod_fs/class_watcher/watcher_n_exporter.cpp", 225 "src/mod_fs/properties/connectdfs.cpp", 226 "src/mod_fs/properties/copy.cpp", 227 "src/mod_fs/properties/copy_file.cpp", 228 "src/mod_fs/properties/copy_listener/trans_listener.cpp", 229 "src/mod_fs/properties/copydir.cpp", 230 "src/mod_fs/properties/create_randomaccessfile.cpp", 231 "src/mod_fs/properties/create_stream.cpp", 232 "src/mod_fs/properties/create_streamrw.cpp", 233 "src/mod_fs/properties/dfs_listener/file_dfs_listener_stub.cpp", 234 "src/mod_fs/properties/disconnectdfs.cpp", 235 "src/mod_fs/properties/dup.cpp", 236 "src/mod_fs/properties/fdopen_stream.cpp", 237 "src/mod_fs/properties/listfile.cpp", 238 "src/mod_fs/properties/lseek.cpp", 239 "src/mod_fs/properties/move.cpp", 240 "src/mod_fs/properties/movedir.cpp", 241 "src/mod_fs/properties/read_lines.cpp", 242 "src/mod_fs/properties/read_text.cpp", 243 "src/mod_fs/properties/symlink.cpp", 244 "src/mod_fs/properties/watcher.cpp", 245 "src/mod_fs/properties/xattr.cpp", 246 ] 247 external_deps += [ 248 "ability_base:zuri", 249 "ability_runtime:ability_manager", 250 "ability_runtime:abilitykit_native", 251 "ability_runtime:extensionkit_native", 252 "access_token:libtokenid_sdk", 253 "app_file_service:fileuri_native", 254 "bundle_framework:appexecfwk_base", 255 "bundle_framework:appexecfwk_core", 256 "c_utils:utils", 257 "data_share:datashare_common", 258 "data_share:datashare_consumer", 259 "dfs_service:distributed_file_daemon_kit_inner", 260 "hisysevent:libhisysevent", 261 "hitrace:hitrace_meter", 262 "ipc:ipc_core", 263 "samgr:samgr_proxy", 264 ] 265 deps += [ 266 "${file_api_path}/interfaces/kits/native:remote_uri_native", 267 "${file_api_path}/interfaces/kits/native:task_signal_native", 268 "${file_api_path}/interfaces/kits/rust:rust_file", 269 ] 270 } 271} 272 273ohos_shared_library("hash") { 274 cflags = [ 275 "-fvisibility=hidden", 276 "-fdata-sections", 277 "-ffunction-sections", 278 "-Oz", 279 ] 280 cflags_cc = [ 281 "-fvisibility-inlines-hidden", 282 "-Oz", 283 ] 284 branch_protector_ret = "pac_ret" 285 sanitize = { 286 integer_overflow = true 287 ubsan = true 288 boundary_sanitize = true 289 cfi = true 290 cfi_cross_dso = true 291 debug = false 292 } 293 294 subsystem_name = "filemanagement" 295 part_name = "file_api" 296 297 relative_install_dir = "module/file" 298 299 include_dirs = [ 300 "${src_path}/common/file_helper", 301 "${src_path}/mod_hash", 302 "${src_path}/mod_hash/class_hashstream", 303 ] 304 305 sources = [ 306 "src/common/file_helper/fd_guard.cpp", 307 "src/common/file_helper/hash_file.cpp", 308 "src/mod_hash/class_hashstream/hashstream_n_exporter.cpp", 309 "src/mod_hash/create_streamhash.cpp", 310 "src/mod_hash/hash.cpp", 311 "src/mod_hash/module.cpp", 312 ] 313 314 deps = [ 315 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 316 "${utils_path}/filemgmt_libn:filemgmt_libn", 317 "//third_party/openssl:libcrypto_shared", 318 ] 319 320 external_deps = [ 321 "bounds_checking_function:libsec_shared", 322 "hilog:libhilog", 323 "napi:ace_napi", 324 ] 325 defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 326} 327 328ohos_shared_library("file") { 329 cflags = [ 330 "-fvisibility=hidden", 331 "-fdata-sections", 332 "-ffunction-sections", 333 "-Oz", 334 ] 335 cflags_cc = [ 336 "-fvisibility-inlines-hidden", 337 "-Oz", 338 ] 339 branch_protector_ret = "pac_ret" 340 sanitize = { 341 integer_overflow = true 342 ubsan = true 343 boundary_sanitize = true 344 cfi = true 345 cfi_cross_dso = true 346 debug = false 347 } 348 349 subsystem_name = "filemanagement" 350 part_name = "file_api" 351 352 relative_install_dir = "module" 353 354 include_dirs = [ 355 "${arkui_napi_path}/interfaces/kits", 356 "src/common/napi", 357 "src/common/napi/n_async", 358 "src/common/file_helper", 359 "//third_party/node/src", 360 ] 361 362 sources = file_common_src 363 sources += [ 364 "src/common/ability_helper.cpp", 365 "src/mod_file/class_file/file_n_exporter.cpp", 366 "src/mod_file/common_func.cpp", 367 "src/mod_file/module.cpp", 368 ] 369 370 external_deps = [ 371 "ability_runtime:abilitykit_native", 372 "ability_runtime:extensionkit_native", 373 "bounds_checking_function:libsec_shared", 374 "common_event_service:cesfwk_innerkits", 375 "eventhandler:libeventhandler", 376 "hilog:libhilog", 377 "napi:ace_napi", 378 ] 379} 380 381ohos_shared_library("statfs") { 382 cflags = [ 383 "-fvisibility=hidden", 384 "-fdata-sections", 385 "-ffunction-sections", 386 "-Oz", 387 ] 388 cflags_cc = [ 389 "-fvisibility-inlines-hidden", 390 "-Oz", 391 ] 392 branch_protector_ret = "pac_ret" 393 sanitize = { 394 integer_overflow = true 395 ubsan = true 396 boundary_sanitize = true 397 cfi = true 398 cfi_cross_dso = true 399 debug = false 400 } 401 402 subsystem_name = "filemanagement" 403 part_name = "file_api" 404 405 relative_install_dir = "module" 406 407 sources = [ 408 "src/mod_statfs/statfs_n_exporter.cpp", 409 "src/mod_statfs/statfs_napi.cpp", 410 ] 411 412 deps = [ 413 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 414 "${utils_path}/filemgmt_libn:filemgmt_libn", 415 ] 416 417 external_deps = [ 418 "hilog:libhilog", 419 "napi:ace_napi", 420 ] 421} 422 423ohos_shared_library("statvfs") { 424 cflags = [ 425 "-fvisibility=hidden", 426 "-fdata-sections", 427 "-ffunction-sections", 428 "-Oz", 429 ] 430 cflags_cc = [ 431 "-fvisibility-inlines-hidden", 432 "-Oz", 433 ] 434 branch_protector_ret = "pac_ret" 435 sanitize = { 436 integer_overflow = true 437 ubsan = true 438 boundary_sanitize = true 439 cfi = true 440 cfi_cross_dso = true 441 debug = false 442 } 443 444 subsystem_name = "filemanagement" 445 part_name = "file_api" 446 447 relative_install_dir = "module/file" 448 449 sources = [ 450 "src/mod_statvfs/statvfs_n_exporter.cpp", 451 "src/mod_statvfs/statvfs_napi.cpp", 452 ] 453 454 deps = [ 455 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 456 "${utils_path}/filemgmt_libn:filemgmt_libn", 457 ] 458 459 external_deps = [ 460 "hilog:libhilog", 461 "napi:ace_napi", 462 ] 463} 464 465ohos_shared_library("environment") { 466 cflags = [ 467 "-fvisibility=hidden", 468 "-fdata-sections", 469 "-ffunction-sections", 470 "-Oz", 471 ] 472 cflags_cc = [ 473 "-fvisibility-inlines-hidden", 474 "-Oz", 475 ] 476 branch_protector_ret = "pac_ret" 477 sanitize = { 478 integer_overflow = true 479 ubsan = true 480 boundary_sanitize = true 481 cfi = true 482 cfi_cross_dso = true 483 debug = false 484 } 485 486 subsystem_name = "filemanagement" 487 part_name = "file_api" 488 489 relative_install_dir = "module/file" 490 491 sources = [ 492 "src/mod_environment/environment_n_exporter.cpp", 493 "src/mod_environment/environment_napi.cpp", 494 ] 495 496 deps = [ 497 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 498 "${utils_path}/filemgmt_libn:filemgmt_libn", 499 ] 500 501 external_deps = [ 502 "access_token:libaccesstoken_sdk", 503 "access_token:libtokenid_sdk", 504 "hilog:libhilog", 505 "init:libbegetutil", 506 "ipc:ipc_core", 507 "napi:ace_napi", 508 "os_account:os_account_innerkits", 509 ] 510} 511ohos_shared_library("securitylabel") { 512 branch_protector_ret = "pac_ret" 513 sanitize = { 514 integer_overflow = true 515 ubsan = true 516 boundary_sanitize = true 517 cfi = true 518 cfi_cross_dso = true 519 debug = false 520 } 521 522 subsystem_name = "filemanagement" 523 part_name = "file_api" 524 525 relative_install_dir = "module/file" 526 527 cflags = [ 528 "-fvisibility=hidden", 529 "-fdata-sections", 530 "-ffunction-sections", 531 "-Wno-format", 532 "-Oz", 533 ] 534 cflags_cc = [ 535 "-fvisibility-inlines-hidden", 536 "-Oz", 537 ] 538 539 sources = [ 540 "src/mod_securitylabel/securitylabel_n_exporter.cpp", 541 "src/mod_securitylabel/securitylabel_napi.cpp", 542 ] 543 544 public_configs = [ ":kits_public_config" ] 545 546 deps = [ 547 "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", 548 "${utils_path}/filemgmt_libn:filemgmt_libn", 549 ] 550 551 external_deps = [ 552 "access_token:libtokenid_sdk", 553 "hilog:libhilog", 554 "ipc:ipc_core", 555 "napi:ace_napi", 556 ] 557} 558 559ohos_shared_library("document") { 560 cflags = [ 561 "-fvisibility=hidden", 562 "-fdata-sections", 563 "-ffunction-sections", 564 "-Oz", 565 ] 566 cflags_cc = [ 567 "-fvisibility-inlines-hidden", 568 "-Oz", 569 ] 570 branch_protector_ret = "pac_ret" 571 sanitize = { 572 integer_overflow = true 573 ubsan = true 574 boundary_sanitize = true 575 cfi = true 576 cfi_cross_dso = true 577 debug = false 578 } 579 580 subsystem_name = "filemanagement" 581 part_name = "file_api" 582 583 relative_install_dir = "module" 584 585 include_dirs = [ 586 "${arkui_napi_path}/interfaces/kits", 587 "src/common/napi/n_async", 588 "//third_party/node/src", 589 ] 590 591 sources = [ 592 "src/common/napi/n_async/n_async_work_callback.cpp", 593 "src/common/napi/n_async/n_async_work_promise.cpp", 594 "src/common/napi/n_async/n_ref.cpp", 595 "src/common/napi/n_func_arg.cpp", 596 "src/common/napi/n_val.cpp", 597 "src/common/uni_error.cpp", 598 "src/mod_document/document_n_exporter.cpp", 599 "src/mod_document/document_napi.cpp", 600 ] 601 602 external_deps = [ 603 "hilog:libhilog", 604 "napi:ace_napi", 605 ] 606} 607 608group("build_kits_js") { 609 deps = [ 610 ":document", 611 ":environment", 612 ":file", 613 ":fileio", 614 ":fs", 615 ":hash", 616 ":securitylabel", 617 ":statfs", 618 ":statvfs", 619 ] 620} 621