• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2025 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_atomicfile/atomicfile_n_exporter.cpp",
219      "src/mod_fs/class_randomaccessfile/randomaccessfile_n_exporter.cpp",
220      "src/mod_fs/class_readeriterator/readeriterator_n_exporter.cpp",
221      "src/mod_fs/class_stream/stream_n_exporter.cpp",
222      "src/mod_fs/class_tasksignal/task_signal_entity.cpp",
223      "src/mod_fs/class_tasksignal/task_signal_n_exporter.cpp",
224      "src/mod_fs/class_watcher/watcher_entity.cpp",
225      "src/mod_fs/class_watcher/watcher_n_exporter.cpp",
226      "src/mod_fs/properties/connectdfs.cpp",
227      "src/mod_fs/properties/copy.cpp",
228      "src/mod_fs/properties/copy_file.cpp",
229      "src/mod_fs/properties/copy_listener/trans_listener.cpp",
230      "src/mod_fs/properties/copydir.cpp",
231      "src/mod_fs/properties/create_randomaccessfile.cpp",
232      "src/mod_fs/properties/create_stream.cpp",
233      "src/mod_fs/properties/create_streamrw.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      "dfs_service:libdistributedfileutils",
261      "hisysevent:libhisysevent",
262      "hitrace:hitrace_meter",
263      "ipc:ipc_core",
264      "samgr:samgr_proxy",
265    ]
266    deps += [
267      "${file_api_path}/interfaces/kits/native:remote_uri_native",
268      "${file_api_path}/interfaces/kits/native:task_signal_native",
269      "${file_api_path}/interfaces/kits/rust:rust_file",
270    ]
271  }
272}
273
274ohos_shared_library("hash") {
275  cflags = [
276    "-fvisibility=hidden",
277    "-fdata-sections",
278    "-ffunction-sections",
279    "-Oz",
280  ]
281  cflags_cc = [
282    "-fvisibility-inlines-hidden",
283    "-Oz",
284  ]
285  branch_protector_ret = "pac_ret"
286  sanitize = {
287    integer_overflow = true
288    ubsan = true
289    boundary_sanitize = true
290    cfi = true
291    cfi_cross_dso = true
292    debug = false
293  }
294
295  subsystem_name = "filemanagement"
296  part_name = "file_api"
297
298  relative_install_dir = "module/file"
299
300  include_dirs = [
301    "${src_path}/common/file_helper",
302    "${src_path}/mod_hash",
303    "${src_path}/mod_hash/class_hashstream",
304  ]
305
306  sources = [
307    "src/common/file_helper/fd_guard.cpp",
308    "src/common/file_helper/hash_file.cpp",
309    "src/mod_hash/class_hashstream/hashstream_n_exporter.cpp",
310    "src/mod_hash/create_streamhash.cpp",
311    "src/mod_hash/hash.cpp",
312    "src/mod_hash/module.cpp",
313  ]
314
315  deps = [
316    "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
317    "${utils_path}/filemgmt_libn:filemgmt_libn",
318    "//third_party/openssl:libcrypto_shared",
319  ]
320
321  external_deps = [
322    "bounds_checking_function:libsec_shared",
323    "hilog:libhilog",
324    "napi:ace_napi",
325  ]
326  defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
327}
328
329ohos_shared_library("file") {
330  cflags = [
331    "-fvisibility=hidden",
332    "-fdata-sections",
333    "-ffunction-sections",
334    "-Oz",
335  ]
336  cflags_cc = [
337    "-fvisibility-inlines-hidden",
338    "-Oz",
339  ]
340  branch_protector_ret = "pac_ret"
341  sanitize = {
342    integer_overflow = true
343    ubsan = true
344    boundary_sanitize = true
345    cfi = true
346    cfi_cross_dso = true
347    debug = false
348  }
349
350  subsystem_name = "filemanagement"
351  part_name = "file_api"
352
353  relative_install_dir = "module"
354
355  include_dirs = [
356    "${arkui_napi_path}/interfaces/kits",
357    "src/common/napi",
358    "src/common/napi/n_async",
359    "src/common/file_helper",
360    "//third_party/node/src",
361  ]
362
363  sources = file_common_src
364  sources += [
365    "src/common/ability_helper.cpp",
366    "src/mod_file/class_file/file_n_exporter.cpp",
367    "src/mod_file/common_func.cpp",
368    "src/mod_file/module.cpp",
369  ]
370
371  external_deps = [
372    "ability_runtime:abilitykit_native",
373    "ability_runtime:extensionkit_native",
374    "bounds_checking_function:libsec_shared",
375    "common_event_service:cesfwk_innerkits",
376    "eventhandler:libeventhandler",
377    "hilog:libhilog",
378    "napi:ace_napi",
379  ]
380
381  if (file_api_read_optimize) {
382    defines = [ "WEARABLE_PRODUCT" ]
383  }
384}
385
386ohos_shared_library("statfs") {
387  cflags = [
388    "-fvisibility=hidden",
389    "-fdata-sections",
390    "-ffunction-sections",
391    "-Oz",
392  ]
393  cflags_cc = [
394    "-fvisibility-inlines-hidden",
395    "-Oz",
396  ]
397  branch_protector_ret = "pac_ret"
398  sanitize = {
399    integer_overflow = true
400    ubsan = true
401    boundary_sanitize = true
402    cfi = true
403    cfi_cross_dso = true
404    debug = false
405  }
406
407  subsystem_name = "filemanagement"
408  part_name = "file_api"
409
410  relative_install_dir = "module"
411
412  sources = [
413    "src/mod_statfs/statfs_n_exporter.cpp",
414    "src/mod_statfs/statfs_napi.cpp",
415  ]
416
417  deps = [
418    "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
419    "${utils_path}/filemgmt_libn:filemgmt_libn",
420  ]
421
422  external_deps = [
423    "hilog:libhilog",
424    "napi:ace_napi",
425  ]
426}
427
428ohos_shared_library("statvfs") {
429  cflags = [
430    "-fvisibility=hidden",
431    "-fdata-sections",
432    "-ffunction-sections",
433    "-Oz",
434  ]
435  cflags_cc = [
436    "-fvisibility-inlines-hidden",
437    "-Oz",
438  ]
439  branch_protector_ret = "pac_ret"
440  sanitize = {
441    integer_overflow = true
442    ubsan = true
443    boundary_sanitize = true
444    cfi = true
445    cfi_cross_dso = true
446    debug = false
447  }
448
449  subsystem_name = "filemanagement"
450  part_name = "file_api"
451
452  relative_install_dir = "module/file"
453
454  sources = [
455    "src/mod_statvfs/statvfs_n_exporter.cpp",
456    "src/mod_statvfs/statvfs_napi.cpp",
457  ]
458
459  deps = [
460    "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
461    "${utils_path}/filemgmt_libn:filemgmt_libn",
462  ]
463
464  external_deps = [
465    "hilog:libhilog",
466    "napi:ace_napi",
467  ]
468}
469
470ohos_shared_library("environment") {
471  cflags = [
472    "-fvisibility=hidden",
473    "-fdata-sections",
474    "-ffunction-sections",
475    "-Oz",
476  ]
477  cflags_cc = [
478    "-fvisibility-inlines-hidden",
479    "-Oz",
480  ]
481  branch_protector_ret = "pac_ret"
482  sanitize = {
483    integer_overflow = true
484    ubsan = true
485    boundary_sanitize = true
486    cfi = true
487    cfi_cross_dso = true
488    debug = false
489  }
490
491  subsystem_name = "filemanagement"
492  part_name = "file_api"
493
494  relative_install_dir = "module/file"
495
496  sources = [
497    "src/mod_environment/environment_n_exporter.cpp",
498    "src/mod_environment/environment_napi.cpp",
499  ]
500
501  deps = [
502    "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
503    "${utils_path}/filemgmt_libn:filemgmt_libn",
504  ]
505
506  external_deps = [
507    "access_token:libaccesstoken_sdk",
508    "access_token:libtokenid_sdk",
509    "hilog:libhilog",
510    "init:libbegetutil",
511    "ipc:ipc_core",
512    "napi:ace_napi",
513    "os_account:os_account_innerkits",
514  ]
515}
516ohos_shared_library("securitylabel") {
517  branch_protector_ret = "pac_ret"
518  sanitize = {
519    integer_overflow = true
520    ubsan = true
521    boundary_sanitize = true
522    cfi = true
523    cfi_cross_dso = true
524    debug = false
525  }
526
527  subsystem_name = "filemanagement"
528  part_name = "file_api"
529
530  relative_install_dir = "module/file"
531
532  cflags = [
533    "-fvisibility=hidden",
534    "-fdata-sections",
535    "-ffunction-sections",
536    "-Wno-format",
537    "-Oz",
538  ]
539  cflags_cc = [
540    "-fvisibility-inlines-hidden",
541    "-Oz",
542  ]
543
544  sources = [
545    "src/mod_securitylabel/securitylabel_n_exporter.cpp",
546    "src/mod_securitylabel/securitylabel_napi.cpp",
547  ]
548
549  public_configs = [ ":kits_public_config" ]
550
551  deps = [
552    "${utils_path}/filemgmt_libhilog:filemgmt_libhilog",
553    "${utils_path}/filemgmt_libn:filemgmt_libn",
554  ]
555
556  external_deps = [
557    "access_token:libtokenid_sdk",
558    "hilog:libhilog",
559    "ipc:ipc_core",
560    "napi:ace_napi",
561  ]
562}
563
564ohos_shared_library("document") {
565  cflags = [
566    "-fvisibility=hidden",
567    "-fdata-sections",
568    "-ffunction-sections",
569    "-Oz",
570  ]
571  cflags_cc = [
572    "-fvisibility-inlines-hidden",
573    "-Oz",
574  ]
575  branch_protector_ret = "pac_ret"
576  sanitize = {
577    integer_overflow = true
578    ubsan = true
579    boundary_sanitize = true
580    cfi = true
581    cfi_cross_dso = true
582    debug = false
583  }
584
585  subsystem_name = "filemanagement"
586  part_name = "file_api"
587
588  relative_install_dir = "module"
589
590  include_dirs = [
591    "${arkui_napi_path}/interfaces/kits",
592    "src/common/napi/n_async",
593    "//third_party/node/src",
594  ]
595
596  sources = [
597    "src/common/napi/n_async/n_async_work_callback.cpp",
598    "src/common/napi/n_async/n_async_work_promise.cpp",
599    "src/common/napi/n_async/n_ref.cpp",
600    "src/common/napi/n_func_arg.cpp",
601    "src/common/napi/n_val.cpp",
602    "src/common/uni_error.cpp",
603    "src/mod_document/document_n_exporter.cpp",
604    "src/mod_document/document_napi.cpp",
605  ]
606
607  external_deps = [
608    "hilog:libhilog",
609    "napi:ace_napi",
610  ]
611}
612
613group("build_kits_js") {
614  deps = [
615    ":document",
616    ":environment",
617    ":file",
618    ":fileio",
619    ":fs",
620    ":hash",
621    ":securitylabel",
622    ":statfs",
623    ":statvfs",
624  ]
625}
626