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    if (appspawn_seccomp_privilege) {
60      cflags += [ "-DSECCOMP_PRIVILEGE" ]
61    }
62    external_deps += [ "init:seccomp" ]
63  }
64
65  if (!defined(global_parts_info) ||
66      defined(global_parts_info.security_security_component_manager)) {
67    defines += [ "SECURITY_COMPONENT_ENABLE" ]
68    external_deps += [ "security_component_manager:libsecurity_component_sdk" ]
69  }
70
71  if (!defined(global_parts_info) ||
72      defined(global_parts_info.security_code_signature)) {
73    defines += [ "CODE_SIGNATURE_ENABLE" ]
74    external_deps += [ "code_signature:libcode_sign_attr_utils" ]
75  }
76
77  if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) {
78    defines += [ "APPSPAWN_SANDBOX_NEW" ]
79  }
80
81  subsystem_name = "${subsystem_name}"
82  part_name = "${part_name}"
83  install_enable = true
84  if (target_cpu == "arm64" || target_cpu == "x86_64" ||
85      target_cpu == "riscv64") {
86    module_install_dir = "lib64/appspawn/common"
87  } else {
88    module_install_dir = "lib/appspawn/common"
89  }
90}
91