# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//base/startup/appspawn/appspawn.gni") import("//build/ohos.gni") import("//build/ohos/native_stub/native_stub.gni") config("appspawn_server_config") { visibility = [ ":*" ] include_dirs = [ "${appspawn_path}/common", "${appspawn_path}/standard", "${appspawn_path}/modules/common", "${appspawn_path}/modules/modulemgr", "${appspawn_path}/modules/sysevent", ] cflags = [] if (build_selinux) { cflags += [ "-DWITH_SELINUX" ] } if (build_seccomp) { cflags += [ "-DWITH_SECCOMP" ] } configs = [ "${appspawn_path}:appspawn_config" ] } ohos_executable("appspawn") { sources = [ "${appspawn_path}/common/appspawn_server.c", "${appspawn_path}/common/appspawn_trace.cpp", "${appspawn_path}/modules/common/appspawn_dfx_dump.cpp", "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", "${appspawn_path}/standard/appspawn_appmgr.c", "${appspawn_path}/standard/appspawn_kickdog.c", "${appspawn_path}/standard/appspawn_main.c", "${appspawn_path}/standard/appspawn_msgmgr.c", "${appspawn_path}/standard/appspawn_service.c", "${appspawn_path}/standard/nwebspawn_launcher.c", ] defines = [] configs = [ ":appspawn_server_config", "${appspawn_path}:appspawn_config", ] deps = [ "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", "${appspawn_path}/util:libappspawn_util", ] if (asan_detector || is_asan) { defines += [ "ASAN_DETECTOR" ] } if (is_debug || build_variant == "root") { defines += [ "DEBUG_BEGETCTL_BOOT" ] } external_deps = [ "c_utils:utils", "config_policy:configpolicy_util", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbegetutil", ] if (enable_appspawn_dump_catcher) { external_deps += [ "faultloggerd:libdfx_dumpcatcher" ] } if (appspawn_use_encaps) { defines += [ "USE_ENCAPS" ] } if (appspawn_report_event) { defines += [ "APPSPAWN_HISYSEVENT" ] external_deps += [ "hisysevent:libhisysevent" ] sources += [ "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp" ] } if (build_selinux) { defines += [ "WITH_SELINUX" ] external_deps += [ "selinux:libselinux", "selinux_adapter:libhap_restorecon", ] } cflags = [] #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (!defined(global_parts_info) || defined(global_parts_info.security_code_signature)) { defines += [ "CODE_SIGNATURE_ENABLE" ] external_deps += [ "code_signature:libcode_sign_attr_utils" ] } version_script = get_label_info( "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", "target_gen_dir") + "/" + get_label_info( "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", "name") + stub_version_script_suffix install_enable = true subsystem_name = "${subsystem_name}" part_name = "${part_name}" } ohos_shared_library("appspawn_helper") { sources = [ "${appspawn_path}/common/appspawn_server.c" ] defines = [ "APPSPAWN_HELPER" ] configs = [ ":appspawn_server_config", "${appspawn_path}:appspawn_config", ] cflags = [ "-fvisibility=hidden", "-fstack-protector-all", ] external_deps = [ "hilog:libhilog", "init:libbegetutil", ] install_enable = true subsystem_name = "${subsystem_name}" part_name = "${part_name}" } ohos_prebuilt_etc("appspawn.rc") { source = "appspawn.cfg" relative_install_dir = "init" subsystem_name = "${subsystem_name}" part_name = "${part_name}" } ohos_executable("pid_ns_init") { sources = [ "${appspawn_path}/standard/pid_ns_init.c" ] install_enable = true subsystem_name = "${subsystem_name}" part_name = "${part_name}" } # to support cjappspawn ohos_executable("cjappspawn") { sources = [ "${appspawn_path}/common/appspawn_server.c", "${appspawn_path}/common/appspawn_trace.cpp", "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", "${appspawn_path}/standard/appspawn_appmgr.c", "${appspawn_path}/standard/appspawn_kickdog.c", "${appspawn_path}/standard/appspawn_main.c", "${appspawn_path}/standard/appspawn_msgmgr.c", "${appspawn_path}/standard/appspawn_service.c", "${appspawn_path}/standard/nwebspawn_launcher.c", ] defines = [ "CJAPP_SPAWN" ] configs = [ ":appspawn_server_config", "${appspawn_path}:appspawn_config", ] deps = [ "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", "${appspawn_path}/util:libappspawn_util", ] if (asan_detector || is_asan) { defines += [ "ASAN_DETECTOR" ] } external_deps = [ "c_utils:utils", "config_policy:configpolicy_util", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbegetutil", ] if (appspawn_report_event) { defines += [ "APPSPAWN_HISYSEVENT" ] external_deps += [ "hisysevent:libhisysevent" ] sources += [ "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp" ] } if (build_selinux) { defines += [ "WITH_SELINUX" ] external_deps += [ "selinux:libselinux", "selinux_adapter:libhap_restorecon", ] } cflags = [] #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (!defined(global_parts_info) || defined(global_parts_info.security_code_signature)) { defines += [ "CODE_SIGNATURE_ENABLE" ] external_deps += [ "code_signature:libcode_sign_attr_utils" ] } version_script = get_label_info( "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", "target_gen_dir") + "/" + get_label_info( "${appspawn_path}/modules/module_engine:libappspawn_stub_versionscript", "name") + stub_version_script_suffix install_enable = true subsystem_name = "${subsystem_name}" part_name = "${part_name}" } ohos_prebuilt_etc("cjappspawn.rc") { source = "cjappspawn.cfg" relative_install_dir = "init" subsystem_name = "${subsystem_name}" part_name = "${part_name}" }