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