1# Copyright (c) 2021-2022 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. 13import("//base/startup/appspawn/appspawn.gni") 14import("//build/ohos.gni") 15import("//build/ohos/native_stub/native_stub.gni") 16 17config("appspawn_server_config") { 18 visibility = [ ":*" ] 19 include_dirs = [ 20 "${appspawn_path}/common", 21 "${appspawn_path}/standard", 22 "${appspawn_path}/modules/common", 23 "${appspawn_path}/modules/modulemgr", 24 "${appspawn_path}/modules/sysevent", 25 ] 26 27 cflags = [] 28 if (build_selinux) { 29 cflags += [ "-DWITH_SELINUX" ] 30 } 31 32 if (build_seccomp) { 33 cflags += [ "-DWITH_SECCOMP" ] 34 if (appspawn_seccomp_privilege) { 35 cflags += [ "-DSECCOMP_PRIVILEGE" ] 36 } 37 } 38 configs = [ "${appspawn_path}:appspawn_config" ] 39} 40 41ohos_executable("appspawn") { 42 sources = [ 43 "${appspawn_path}/common/appspawn_server.c", 44 "${appspawn_path}/common/appspawn_trace.cpp", 45 "${appspawn_path}/modules/common/appspawn_dfx_dump.cpp", 46 "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", 47 "${appspawn_path}/standard/appspawn_appmgr.c", 48 "${appspawn_path}/standard/appspawn_kickdog.c", 49 "${appspawn_path}/standard/appspawn_main.c", 50 "${appspawn_path}/standard/appspawn_msgmgr.c", 51 "${appspawn_path}/standard/appspawn_service.c", 52 ] 53 if (!defined(ohos_lite)) { 54 sources += [ 55 "${appspawn_path}/standard/appspawn_reclaim.h", 56 "${appspawn_path}/standard/appspawn_reclaim.cpp", 57 ] 58 } 59 60 defines = [] 61 if (target_cpu == "arm64") { 62 defines += [ "PRE_DLOPEN_ARKWEB_LIB" ] 63 } 64 configs = [ 65 ":appspawn_server_config", 66 "${appspawn_path}:appspawn_config", 67 ] 68 deps = [ 69 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 70 "${appspawn_path}/util:libappspawn_util", 71 ] 72 if (asan_detector || is_asan) { 73 defines += [ "ASAN_DETECTOR" ] 74 } 75 if (is_debug || build_variant == "root") { 76 defines += [ "DEBUG_BEGETCTL_BOOT" ] 77 } 78 if (appspawn_support_prefork) { 79 defines += [ "APPSPAWN_SUPPORT_PREFORK" ] 80 } 81 82 external_deps = [ 83 "cJSON:cjson", 84 "c_utils:utils", 85 "config_policy:configpolicy_util", 86 "ffrt:libffrt", 87 "hilog:libhilog", 88 "hitrace:hitrace_meter", 89 "init:libbegetutil", 90 ] 91 if (!defined(ohos_lite)) { 92 external_deps += [ "ace_engine:ace_forward_compatibility" ] 93 } 94 95 if (enable_appspawn_dump_catcher) { 96 external_deps += [ "faultloggerd:libdfx_dumpcatcher" ] 97 } 98 99 if (appspawn_report_event) { 100 defines += [ "APPSPAWN_HISYSEVENT" ] 101 external_deps += [ "hisysevent:libhisysevent" ] 102 sources += [ 103 "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp", 104 "${appspawn_path}/modules/sysevent/hisysevent_adapter.cpp", 105 ] 106 } 107 if (build_selinux) { 108 defines += [ "WITH_SELINUX" ] 109 external_deps += [ 110 "selinux:libselinux", 111 "selinux_adapter:libhap_restorecon", 112 ] 113 } 114 cflags = [] 115 116 if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { 117 defines += [ "APPSPAWN_SANDBOX_NEW" ] 118 } 119 120 #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] 121 if (!defined(global_parts_info) || 122 defined(global_parts_info.security_code_signature)) { 123 defines += [ "CODE_SIGNATURE_ENABLE" ] 124 external_deps += [ "code_signature:libcode_sign_attr_utils" ] 125 } 126 127 version_script = get_label_info( 128 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 129 "target_gen_dir") + "/" + get_label_info( 130 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 131 "name") + stub_version_script_suffix 132 133 install_enable = true 134 subsystem_name = "${subsystem_name}" 135 part_name = "${part_name}" 136} 137 138ohos_shared_library("appspawn_helper") { 139 sources = [ "${appspawn_path}/common/appspawn_server.c" ] 140 defines = [ "APPSPAWN_HELPER" ] 141 configs = [ 142 ":appspawn_server_config", 143 "${appspawn_path}:appspawn_config", 144 ] 145 cflags = [ 146 "-fvisibility=hidden", 147 "-fstack-protector-all", 148 ] 149 external_deps = [ 150 "hilog:libhilog", 151 "init:libbegetutil", 152 ] 153 154 install_enable = true 155 subsystem_name = "${subsystem_name}" 156 part_name = "${part_name}" 157} 158 159ohos_prebuilt_etc("appspawn.rc") { 160 source = "appspawn.cfg" 161 relative_install_dir = "init" 162 subsystem_name = "${subsystem_name}" 163 part_name = "${part_name}" 164} 165 166ohos_executable("pid_ns_init") { 167 sources = [ "${appspawn_path}/standard/pid_ns_init.c" ] 168 install_enable = true 169 subsystem_name = "${subsystem_name}" 170 part_name = "${part_name}" 171} 172 173# to support cjappspawn 174ohos_executable("cjappspawn") { 175 sources = [ 176 "${appspawn_path}/common/appspawn_server.c", 177 "${appspawn_path}/common/appspawn_trace.cpp", 178 "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", 179 "${appspawn_path}/standard/appspawn_appmgr.c", 180 "${appspawn_path}/standard/appspawn_kickdog.c", 181 "${appspawn_path}/standard/appspawn_main.c", 182 "${appspawn_path}/standard/appspawn_msgmgr.c", 183 "${appspawn_path}/standard/appspawn_service.c", 184 ] 185 186 defines = [ "CJAPP_SPAWN" ] 187 configs = [ 188 ":appspawn_server_config", 189 "${appspawn_path}:appspawn_config", 190 ] 191 deps = [ 192 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 193 "${appspawn_path}/util:libappspawn_util", 194 ] 195 if (asan_detector || is_asan) { 196 defines += [ "ASAN_DETECTOR" ] 197 } 198 199 external_deps = [ 200 "cJSON:cjson", 201 "c_utils:utils", 202 "config_policy:configpolicy_util", 203 "ffrt:libffrt", 204 "hilog:libhilog", 205 "hitrace:hitrace_meter", 206 "init:libbegetutil", 207 ] 208 209 if (build_selinux) { 210 defines += [ "WITH_SELINUX" ] 211 external_deps += [ 212 "selinux:libselinux", 213 "selinux_adapter:libhap_restorecon", 214 ] 215 } 216 cflags = [] 217 218 if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { 219 defines += [ "APPSPAWN_SANDBOX_NEW" ] 220 } 221 222 #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] 223 if (!defined(global_parts_info) || 224 defined(global_parts_info.security_code_signature)) { 225 defines += [ "CODE_SIGNATURE_ENABLE" ] 226 external_deps += [ "code_signature:libcode_sign_attr_utils" ] 227 } 228 229 version_script = get_label_info( 230 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 231 "target_gen_dir") + "/" + get_label_info( 232 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 233 "name") + stub_version_script_suffix 234 235 install_enable = true 236 subsystem_name = "${subsystem_name}" 237 part_name = "${part_name}" 238} 239 240# to support nativespawn 241ohos_executable("nativespawn") { 242 sources = [ 243 "${appspawn_path}/common/appspawn_server.c", 244 "${appspawn_path}/common/appspawn_trace.cpp", 245 "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", 246 "${appspawn_path}/standard/appspawn_appmgr.c", 247 "${appspawn_path}/standard/appspawn_kickdog.c", 248 "${appspawn_path}/standard/appspawn_main.c", 249 "${appspawn_path}/standard/appspawn_msgmgr.c", 250 "${appspawn_path}/standard/appspawn_service.c", 251 ] 252 253 defines = [ "NATIVE_SPAWN" ] 254 configs = [ 255 ":appspawn_server_config", 256 "${appspawn_path}:appspawn_config", 257 ] 258 deps = [ 259 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 260 "${appspawn_path}/util:libappspawn_util", 261 ] 262 if (asan_detector || is_asan) { 263 defines += [ "ASAN_DETECTOR" ] 264 } 265 266 external_deps = [ 267 "cJSON:cjson", 268 "c_utils:utils", 269 "config_policy:configpolicy_util", 270 "ffrt:libffrt", 271 "hilog:libhilog", 272 "hitrace:hitrace_meter", 273 "init:libbegetutil", 274 ] 275 276 if (build_selinux) { 277 defines += [ "WITH_SELINUX" ] 278 external_deps += [ 279 "selinux:libselinux", 280 "selinux_adapter:libhap_restorecon", 281 ] 282 } 283 cflags = [] 284 285 if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { 286 defines += [ "APPSPAWN_SANDBOX_NEW" ] 287 } 288 289 #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] 290 if (!defined(global_parts_info) || 291 defined(global_parts_info.security_code_signature)) { 292 defines += [ "CODE_SIGNATURE_ENABLE" ] 293 external_deps += [ "code_signature:libcode_sign_attr_utils" ] 294 } 295 296 version_script = get_label_info( 297 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 298 "target_gen_dir") + "/" + get_label_info( 299 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 300 "name") + stub_version_script_suffix 301 302 install_enable = true 303 subsystem_name = "${subsystem_name}" 304 part_name = "${part_name}" 305} 306 307ohos_prebuilt_etc("cjappspawn.rc") { 308 source = "cjappspawn.cfg" 309 relative_install_dir = "init" 310 subsystem_name = "${subsystem_name}" 311 part_name = "${part_name}" 312} 313 314ohos_prebuilt_etc("nativespawn.rc") { 315 source = "nativespawn.cfg" 316 relative_install_dir = "init" 317 subsystem_name = "${subsystem_name}" 318 part_name = "${part_name}" 319} 320 321# to support nwebspawn 322ohos_executable("nwebspawn") { 323 sources = [ 324 "${appspawn_path}/common/appspawn_server.c", 325 "${appspawn_path}/common/appspawn_trace.cpp", 326 "${appspawn_path}/modules/common/appspawn_dfx_dump.cpp", 327 "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", 328 "${appspawn_path}/standard/appspawn_appmgr.c", 329 "${appspawn_path}/standard/appspawn_kickdog.c", 330 "${appspawn_path}/standard/appspawn_main.c", 331 "${appspawn_path}/standard/appspawn_msgmgr.c", 332 "${appspawn_path}/standard/appspawn_service.c", 333 ] 334 335 defines = ["NWEB_SPAWN"] 336 configs = [ 337 ":appspawn_server_config", 338 "${appspawn_path}:appspawn_config", 339 ] 340 deps = [ 341 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 342 "${appspawn_path}/util:libappspawn_util", 343 ] 344 if (asan_detector || is_asan) { 345 defines += [ "ASAN_DETECTOR" ] 346 } 347 if (is_debug || build_variant == "root") { 348 defines += [ "DEBUG_BEGETCTL_BOOT" ] 349 } 350 if (appspawn_support_prefork) { 351 defines += [ "APPSPAWN_SUPPORT_PREFORK" ] 352 } 353 354 external_deps = [ 355 "cJSON:cjson", 356 "c_utils:utils", 357 "config_policy:configpolicy_util", 358 "ffrt:libffrt", 359 "hilog:libhilog", 360 "hitrace:hitrace_meter", 361 "init:libbegetutil", 362 ] 363 if (enable_appspawn_dump_catcher) { 364 external_deps += [ "faultloggerd:libdfx_dumpcatcher" ] 365 } 366 367 if (appspawn_report_event) { 368 defines += [ "APPSPAWN_HISYSEVENT" ] 369 external_deps += [ "hisysevent:libhisysevent" ] 370 sources += [ 371 "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp", 372 "${appspawn_path}/modules/sysevent/hisysevent_adapter.cpp", 373 ] 374 } 375 if (build_selinux) { 376 defines += [ "WITH_SELINUX" ] 377 external_deps += [ 378 "selinux:libselinux", 379 "selinux_adapter:libhap_restorecon", 380 ] 381 } 382 cflags = [] 383 384 if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { 385 defines += [ "APPSPAWN_SANDBOX_NEW" ] 386 } 387 388 #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] 389 if (defined(global_parts_info) && 390 defined(global_parts_info.security_code_signature)) { 391 defines += [ "CODE_SIGNATURE_ENABLE" ] 392 external_deps += [ "code_signature:libcode_sign_attr_utils" ] 393 } 394 395 version_script = get_label_info( 396 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 397 "target_gen_dir") + "/" + get_label_info( 398 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 399 "name") + stub_version_script_suffix 400 401 install_enable = true 402 subsystem_name = "${subsystem_name}" 403 part_name = "${part_name}" 404} 405 406# to support hybridspawn 407ohos_executable("hybridspawn") { 408 sources = [ 409 "${appspawn_path}/common/appspawn_server.c", 410 "${appspawn_path}/common/appspawn_trace.cpp", 411 "${appspawn_path}/modules/common/appspawn_dfx_dump.cpp", 412 "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", 413 "${appspawn_path}/standard/appspawn_appmgr.c", 414 "${appspawn_path}/standard/appspawn_kickdog.c", 415 "${appspawn_path}/standard/appspawn_main.c", 416 "${appspawn_path}/standard/appspawn_msgmgr.c", 417 "${appspawn_path}/standard/appspawn_service.c", 418 ] 419 420 defines = [ "HYBRID_SPAWN" ] 421 configs = [ 422 ":appspawn_server_config", 423 "${appspawn_path}:appspawn_config", 424 ] 425 deps = [ 426 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 427 "${appspawn_path}/util:libappspawn_util", 428 ] 429 if (asan_detector || is_asan) { 430 defines += [ "ASAN_DETECTOR" ] 431 } 432 if (is_debug || build_variant == "root") { 433 defines += [ "DEBUG_BEGETCTL_BOOT" ] 434 } 435 if (appspawn_support_prefork) { 436 defines += [ "APPSPAWN_SUPPORT_PREFORK" ] 437 } 438 439 external_deps = [ 440 "cJSON:cjson", 441 "c_utils:utils", 442 "config_policy:configpolicy_util", 443 "ffrt:libffrt", 444 "hilog:libhilog", 445 "hitrace:hitrace_meter", 446 "init:libbegetutil", 447 ] 448 if (enable_appspawn_dump_catcher) { 449 external_deps += [ "faultloggerd:libdfx_dumpcatcher" ] 450 } 451 452 if (appspawn_report_event) { 453 defines += [ "APPSPAWN_HISYSEVENT" ] 454 external_deps += [ "hisysevent:libhisysevent" ] 455 sources += [ 456 "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp", 457 "${appspawn_path}/modules/sysevent/hisysevent_adapter.cpp", 458 ] 459 } 460 if (build_selinux) { 461 defines += [ "WITH_SELINUX" ] 462 external_deps += [ 463 "selinux:libselinux", 464 "selinux_adapter:libhap_restorecon", 465 ] 466 } 467 cflags = [] 468 469 if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { 470 defines += [ "APPSPAWN_SANDBOX_NEW" ] 471 } 472 473 #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] 474 if (defined(global_parts_info) && 475 defined(global_parts_info.security_code_signature)) { 476 defines += [ "CODE_SIGNATURE_ENABLE" ] 477 external_deps += [ "code_signature:libcode_sign_attr_utils" ] 478 } 479 480 version_script = get_label_info( 481 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 482 "target_gen_dir") + "/" + get_label_info( 483 "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", 484 "name") + stub_version_script_suffix 485 486 install_enable = true 487 subsystem_name = "${subsystem_name}" 488 part_name = "${part_name}" 489} 490