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
17ohos_shared_library("appspawn_common") {
18  sources = [
19    "appspawn_adapter.cpp",
20    "appspawn_cgroup.c",
21    "appspawn_common.c",
22    "appspawn_namespace.c",
23    "appspawn_silk.c",
24  ]
25  if (is_debug || build_variant == "root") {
26    sources += [ "appspawn_begetctl.c" ]
27  }
28
29  include_dirs = [
30    ".",
31    "${appspawn_path}/common",
32    "${appspawn_path}/standard",
33  ]
34  cflags = []
35  deps = [
36    "${appspawn_path}/modules/module_engine:libappspawn_module_engine",
37    "${appspawn_path}/util:libappspawn_util",
38  ]
39  defines = [ "GRAPHIC_PERMISSION_CHECK" ]
40  external_deps = [
41    "access_token:libtokenid_sdk",
42    "access_token:libtokensetproc_shared",
43    "cJSON:cjson",
44    "c_utils:utils",
45    "config_policy:configpolicy_util",
46    "hilog:libhilog",
47    "init:libbegetutil",
48    "netmanager_base:netsys_client",
49  ]
50  if (build_selinux) {
51    defines += [ "WITH_SELINUX" ]
52    external_deps += [
53      "selinux:libselinux",
54      "selinux_adapter:libhap_restorecon",
55    ]
56  }
57  if (build_seccomp) {
58    defines += [ "WITH_SECCOMP" ]
59    external_deps += [ "init:seccomp" ]
60  }
61
62  if (!defined(global_parts_info) ||
63      defined(global_parts_info.security_security_component_manager)) {
64    defines += [ "SECURITY_COMPONENT_ENABLE" ]
65    external_deps += [ "security_component_manager:libsecurity_component_sdk" ]
66  }
67
68  if (!defined(global_parts_info) ||
69      defined(global_parts_info.security_code_signature)) {
70    defines += [ "CODE_SIGNATURE_ENABLE" ]
71    external_deps += [ "code_signature:libcode_sign_attr_utils" ]
72  }
73
74  if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) {
75    defines += [ "APPSPAWN_SANDBOX_NEW" ]
76  }
77
78  subsystem_name = "${subsystem_name}"
79  part_name = "${part_name}"
80  install_enable = true
81  if (target_cpu == "arm64" || target_cpu == "x86_64" ||
82      target_cpu == "riscv64") {
83    module_install_dir = "lib64/appspawn/common"
84  } else {
85    module_install_dir = "lib/appspawn/common"
86  }
87}
88