• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_path}/common/appspawn_trace.cpp",
20    "appspawn_adapter.cpp",
21    "appspawn_cgroup.c",
22    "appspawn_common.c",
23    "appspawn_namespace.c",
24    "appspawn_silk.c",
25  ]
26  if (appspawn_use_encaps == true) {
27    sources += [ "appspawn_encaps.c" ]
28  }
29  if (is_debug || build_variant == "root") {
30    sources += [ "appspawn_begetctl.c" ]
31  }
32
33  include_dirs = [
34    ".",
35    "${appspawn_path}/common",
36    "${appspawn_path}/standard",
37  ]
38  cflags = []
39  deps = [
40    "${appspawn_path}/modules/module_engine:libappspawn_module_engine",
41    "${appspawn_path}/util:libappspawn_util",
42  ]
43  defines = [ "GRAPHIC_PERMISSION_CHECK" ]
44  external_deps = [
45    "access_token:libtokenid_sdk",
46    "access_token:libtokensetproc_shared",
47    "cJSON:cjson",
48    "c_utils:utils",
49    "config_policy:configpolicy_util",
50    "hilog:libhilog",
51    "init:libbegetutil",
52    "netmanager_base:netsys_client",
53  ]
54
55  if (appspawn_hitrace_option == true) {
56    defines += [ "APPSPAWN_HITRACE_OPTION" ]
57    external_deps += [ "hitrace:libhitrace_option" ]
58  }
59
60  if (build_selinux) {
61    defines += [ "WITH_SELINUX" ]
62    external_deps += [
63      "selinux:libselinux",
64      "selinux_adapter:libhap_restorecon",
65    ]
66  }
67  if (build_seccomp) {
68    defines += [ "WITH_SECCOMP" ]
69    if (appspawn_seccomp_privilege) {
70      cflags += [ "-DSECCOMP_PRIVILEGE" ]
71    }
72    if (appspawn_custom_sandbox) {
73      cflags += [ "-DCUSTOM_SANDBOX" ]
74    }
75    if (appspawn_support_local_debugger) {
76      cflags += [ "-DSUPPORT_LOCAL_DEBUGGER" ]
77    }
78    external_deps += [ "init:seccomp" ]
79  }
80
81  if (!defined(ohos_lite)) {
82    external_deps += [ "hitrace:hitrace_meter" ]
83  }
84
85  if (!defined(global_parts_info) ||
86      defined(global_parts_info.security_security_component_manager)) {
87    defines += [ "SECURITY_COMPONENT_ENABLE" ]
88    external_deps += [ "security_component_manager:libsecurity_component_sdk" ]
89  }
90
91  if (!defined(global_parts_info) ||
92      defined(global_parts_info.security_code_signature)) {
93    defines += [ "CODE_SIGNATURE_ENABLE" ]
94    external_deps += [ "code_signature:libcode_sign_attr_utils" ]
95  }
96
97  if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) {
98    defines += [ "APPSPAWN_SANDBOX_NEW" ]
99  }
100
101  if (appspawn_support_nosharefs) {
102    defines += [ "APPSPAWN_SUPPORT_NOSHAREFS" ]
103  }
104  if (appspawn_allow_internet_permission) {
105    defines += [ "APPSPAWN_ALLOW_INTERNET_PERMISSION" ]
106  }
107  if (appspawn_report_event) {
108    defines += [ "APPSPAWN_HISYSEVENT" ]
109    external_deps += [ "hisysevent:libhisysevent" ]
110    include_dirs += [ "${appspawn_path}/modules/sysevent" ]
111    sources += [ "${appspawn_path}/modules/sysevent/hisysevent_adapter.cpp" ]
112  }
113
114  subsystem_name = "${subsystem_name}"
115  part_name = "${part_name}"
116  install_enable = true
117  if (target_cpu == "arm64" || target_cpu == "x86_64" ||
118      target_cpu == "riscv64") {
119    module_install_dir = "lib64/appspawn/common"
120  } else {
121    module_install_dir = "lib/appspawn/common"
122  }
123}
124