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