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("//base/startup/appspawn/appspawn.gni")
15import("//build/ohos.gni")
16
17if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) {
18  ohos_shared_library("appspawn_sandbox") {
19    sources = [
20      "appspawn_mount_template.c",
21      "appspawn_permission.c",
22      "appspawn_sandbox.c",
23      "sandbox_cfgvar.c",
24      "sandbox_expand.c",
25      "sandbox_load.c",
26      "sandbox_manager.c",
27    ]
28
29    include_dirs = [
30      ".",
31      "${appspawn_path}/common",
32      "${appspawn_path}/standard",
33    ]
34
35    configs = [ "${appspawn_path}:appspawn_config" ]
36
37    defines = [ "APPSPAWN_SANDBOX_NEW" ]
38    deps = [
39      "${appspawn_path}/modules/module_engine:libappspawn_module_engine",
40      "${appspawn_path}/util:libappspawn_util",
41    ]
42    external_deps = [
43      "cJSON:cjson",
44      "c_utils:utils",
45      "hilog:libhilog",
46      "init:libbegetutil",
47    ]
48    if (build_selinux) {
49      defines += [ "WITH_SELINUX" ]
50      external_deps += [ "selinux_adapter:libhap_restorecon" ]
51    }
52
53    subsystem_name = "${subsystem_name}"
54    part_name = "${part_name}"
55    install_enable = true
56    if (target_cpu == "arm64" || target_cpu == "x86_64" ||
57        target_cpu == "riscv64") {
58      defines += [ "APPSPAWN_64" ]
59      module_install_dir = "lib64/appspawn/common"
60    } else {
61      module_install_dir = "lib/appspawn/common"
62    }
63
64    if (dlp_permission_enable) {
65      cflags_cc = [ "-DWITH_DLP" ]
66      external_deps += [ "dlp_permission_service:libdlp_fuse" ]
67    }
68  }
69} else {
70  ohos_shared_library("appspawn_sandbox") {
71    sources = [
72      "${appspawn_innerkits_path}/permission/appspawn_mount_permission.c",
73      "${appspawn_path}/common/appspawn_trace.cpp",
74      "appspawn_permission.c",
75      "sandbox_utils.cpp",
76    ]
77
78    include_dirs = [
79      ".",
80      "${appspawn_path}/common",
81      "${appspawn_path}/standard",
82      "${appspawn_innerkits_path}/client",
83      "${appspawn_innerkits_path}/permission",
84    ]
85
86    configs = [ "${appspawn_path}:appspawn_config" ]
87
88    defines = [ "APPSPAWN_CLIENT" ]
89    deps = [
90      "${appspawn_path}/modules/module_engine:libappspawn_module_engine",
91      "${appspawn_path}/util:libappspawn_util",
92    ]
93    external_deps = [
94      "cJSON:cjson",
95      "c_utils:utils",
96      "config_policy:configpolicy_util",
97      "hilog:libhilog",
98      "hitrace:hitrace_meter",
99      "init:libbegetutil",
100    ]
101    if (build_selinux) {
102      defines += [ "WITH_SELINUX" ]
103      external_deps += [ "selinux_adapter:libhap_restorecon" ]
104    }
105
106    subsystem_name = "${subsystem_name}"
107    part_name = "${part_name}"
108    install_enable = true
109    if (target_cpu == "arm64" || target_cpu == "x86_64" ||
110        target_cpu == "riscv64") {
111      defines += [ "APPSPAWN_64" ]
112      module_install_dir = "lib64/appspawn/common"
113    } else {
114      module_install_dir = "lib/appspawn/common"
115    }
116
117    if (dlp_permission_enable) {
118      cflags_cc = [ "-DWITH_DLP" ]
119      external_deps += [ "dlp_permission_service:libdlp_fuse" ]
120    }
121  }
122}
123