From 9e813dd28f1ab10e6eb63ba82b8d6811702dfa92 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Fri, 24 Jun 2022 13:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=83=A8=E4=BB=B6=E5=90=8Din?= =?UTF-8?q?it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mupceet --- bundle.json | 14 +-- device_info/BUILD.gn | 92 +++++++------- interfaces/innerkits/BUILD.gn | 15 +++ .../innerkits/init_module_engine/BUILD.gn | 117 ++++++++++-------- interfaces/kits/BUILD.gn | 20 +-- services/begetctl/BUILD.gn | 15 +-- services/init/lite/bundle.json | 10 +- services/loopevent/BUILD.gn | 10 ++ services/modules/BUILD.gn | 76 ++++++------ services/param/BUILD.gn | 1 - test/BUILD.gn | 29 +++++ test/unittest/BUILD.gn | 8 -- ueventd/BUILD.gn | 30 +++-- watchdog/BUILD.gn | 22 ++-- 14 files changed, 264 insertions(+), 195 deletions(-) create mode 100644 test/BUILD.gn diff --git a/bundle.json b/bundle.json index 0a78a8b2d..e8b438b32 100755 --- a/bundle.json +++ b/bundle.json @@ -40,16 +40,11 @@ "//base/startup/init_lite/ueventd:startup_ueventd", "//base/startup/init_lite/watchdog:watchdog", "//base/startup/init_lite/services/begetctl:begetctl_cmd", - "//base/startup/init_lite/services/loopevent:loopevent", - "//base/startup/init_lite/services/modules:modules", + "//base/startup/init_lite/services/loopevent:loopeventgroup", + "//base/startup/init_lite/services/modules:modulesgroup", "//base/startup/init_lite/services/param:parameter", - "//base/startup/init_lite/interfaces/innerkits:libbegetutil", - "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy", - "//base/startup/init_lite/interfaces/innerkits/file:libfile", - "//base/startup/init_lite/interfaces/innerkits/socket:libsocket", - "//base/startup/init_lite/interfaces/innerkits/init_module_engine:init_module_engine", + "//base/startup/init_lite/interfaces/innerkits:innergroup", "//base/startup/init_lite/device_info:device_info_group", - "//base/startup/init_lite/test/exec_test:exectest", "//base/startup/init_lite/interfaces/kits:kitsgroup" ], "inner_kits": [ @@ -95,8 +90,7 @@ } ], "test": [ - "//base/startup/init_lite/test/unittest:init_test", - "//base/startup/init_lite/test/fuzztest:fuzztest" + "//base/startup/init_lite/test:testgroup" ] } } diff --git a/device_info/BUILD.gn b/device_info/BUILD.gn index 6fe9212d8..b9a32135a 100644 --- a/device_info/BUILD.gn +++ b/device_info/BUILD.gn @@ -11,59 +11,61 @@ # See the License for the specific language governing permissions and # limitations under the License. import("//base/startup/init_lite/begetd.gni") -import("//build/ohos.gni") -import("//build/ohos/sa_profile/sa_profile.gni") +if (!defined(ohos_lite)) { + import("//build/ohos.gni") + import("//build/ohos/sa_profile/sa_profile.gni") -ohos_sa_profile("device_info_profile") { - sources = [ "etc/3902.xml" ] - part_name = "init" -} + ohos_sa_profile("device_info_profile") { + sources = [ "etc/3902.xml" ] + part_name = "init" + } -ohos_prebuilt_etc("device_info.cfg") { - source = "etc/deviceinfoservice.cfg" - relative_install_dir = "init" - part_name = "init" -} + ohos_prebuilt_etc("device_info.cfg") { + source = "etc/deviceinfoservice.cfg" + relative_install_dir = "init" + part_name = "init" + } -ohos_shared_library("deviceinfoservice") { - sources = [ - "//base/startup/init_lite/interfaces/innerkits/syspara/param_comm.c", - "device_info_stub.cpp", - ] + ohos_shared_library("deviceinfoservice") { + sources = [ + "//base/startup/init_lite/interfaces/innerkits/syspara/param_comm.c", + "device_info_stub.cpp", + ] - include_dirs = [ - ".", - "//base/startup/init_lite/services/include/param", - "//base/startup/init_lite/interfaces/innerkits/include", - "//base/startup/init_lite/interfaces/innerkits/include/syspara", - "//base/startup/init_lite/interfaces/innerkits/syspara", - "//base/startup/init_lite/interfaces/hals", - ] - defines = [ - "INIT_AGENT", - "_GNU_SOURCE", - "USE_MBEDTLS", - ] - deps = [ - "//base/startup/init_lite/interfaces/innerkits:libbegetutil", - "//third_party/bounds_checking_function:libsec_shared", - "//third_party/mbedtls:mbedtls_shared", - ] + include_dirs = [ + ".", + "//base/startup/init_lite/services/include/param", + "//base/startup/init_lite/interfaces/innerkits/include", + "//base/startup/init_lite/interfaces/innerkits/include/syspara", + "//base/startup/init_lite/interfaces/innerkits/syspara", + "//base/startup/init_lite/interfaces/hals", + ] + defines = [ + "INIT_AGENT", + "_GNU_SOURCE", + "USE_MBEDTLS", + ] + deps = [ + "//base/startup/init_lite/interfaces/innerkits:libbegetutil", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + ] - external_deps = [ - "access_token:libaccesstoken_sdk", - "hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - "utils_base:utils", - ] - install_images = [ "system" ] - part_name = "init" + external_deps = [ + "access_token:libaccesstoken_sdk", + "hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + "utils_base:utils", + ] + install_images = [ "system" ] + part_name = "init" + } } group("device_info_group") { - if (enable_ohos_startup_init_feature_deviceinfo) { + if (!defined(ohos_lite) && enable_ohos_startup_init_feature_deviceinfo) { deps = [ ":device_info.cfg", ":device_info_profile", diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 0549cdb50..2d80c8f5f 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -139,6 +139,9 @@ if (defined(ohos_lite)) { head_files = [ "//base/startup/init_lite/interfaces/innerkits/include/syspara" ] } + + group("libbeget_proxy") { + } } else { import("//build/ohos.gni") modulemgr_sources = [ @@ -281,3 +284,15 @@ if (defined(ohos_lite)) { part_name = "init" } } + +group("innergroup") { + deps = [ ":libbegetutil" ] + if (!defined(ohos_lite)) { + deps += [ + ":libbeget_proxy", + "file:libfile", + "init_module_engine:modulegroup", + "socket:libsocket", + ] + } +} diff --git a/interfaces/innerkits/init_module_engine/BUILD.gn b/interfaces/innerkits/init_module_engine/BUILD.gn index 9d3940e17..91f7b559a 100755 --- a/interfaces/innerkits/init_module_engine/BUILD.gn +++ b/interfaces/innerkits/init_module_engine/BUILD.gn @@ -11,70 +11,77 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/ohos.gni") -import("//build/ohos/native_stub/native_stub.gni") +if (defined(ohos_lite)) { + group("libinit_module_engine") { + } +} else { + import("//build/ohos.gni") + import("//build/ohos/native_stub/native_stub.gni") -# -# exported include directories -# -config("init_module_engine_exported_config") { - visibility = [ ":*" ] - include_dirs = [ - "include/", - "//base/startup/init_lite/services/include", - "//base/startup/init_lite/interfaces/innerkits/include", - "//base/startup/init_lite/services/log", - ] -} + # + # exported include directories + # + config("init_module_engine_exported_config") { + visibility = [ ":*" ] + include_dirs = [ + "include/", + "//base/startup/init_lite/services/include", + "//base/startup/init_lite/interfaces/innerkits/include", + "//base/startup/init_lite/services/log", + ] + } -# -# innerkits for module development -# -ohos_native_stub_library("libinit_module_engine") { - output_extension = "so" - public_configs = [ ":init_module_engine_exported_config" ] - stub_description_file = "./stub/libinit.stub.json" -} + # + # innerkits for module development + # + ohos_native_stub_library("libinit_module_engine") { + output_extension = "so" + public_configs = [ ":init_module_engine_exported_config" ] + stub_description_file = "./stub/libinit.stub.json" + } -# -# For init linking, -# export symbols defined in this json files only -# -ohos_native_stub_versionscript("libinit_stub_versionscript") { - stub_description_file = "./stub/libinit.stub.json" -} + # + # For init linking, + # export symbols defined in this json files only + # + ohos_native_stub_versionscript("libinit_stub_versionscript") { + stub_description_file = "./stub/libinit.stub.json" + } -# -# Generate empty library with symlink name to satisfy init loading required libraries -# -ohos_native_stub_library("libinit_stub_empty") { - output_extension = "so" - stub_description_file = "./stub/libinit.stub.empty.json" - part_name = "init" - install_enable = true - symlink_target_name = [ "libinit_module_engine.so" ] -} + # + # Generate empty library with symlink name to satisfy init loading required libraries + # + ohos_native_stub_library("libinit_stub_empty") { + output_extension = "so" + stub_description_file = "./stub/libinit.stub.empty.json" + part_name = "init" + install_enable = true + symlink_target_name = [ "libinit_module_engine.so" ] + } -config("init_module_engine_sources_config") { - include_dirs = [ - "//base/startup/init_lite/interfaces/innerkits/init_module_engine/include", - "//base/startup/init_lite/interfaces/innerkits/include", - "//base/startup/init_lite/services/include", - "//base/startup/init_lite/services/log", - ] -} + config("init_module_engine_sources_config") { + include_dirs = [ + "//base/startup/init_lite/interfaces/innerkits/init_module_engine/include", + "//base/startup/init_lite/interfaces/innerkits/include", + "//base/startup/init_lite/services/include", + "//base/startup/init_lite/services/log", + ] + } -ohos_source_set("init_module_engine_sources") { - sources = [ "init_modulemgr.c" ] - public_configs = [ ":init_module_engine_sources_config" ] + ohos_source_set("init_module_engine_sources") { + sources = [ "init_modulemgr.c" ] + public_configs = [ ":init_module_engine_sources_config" ] + } } # # init module engine all modules # -group("init_module_engine") { - deps = [ - ":libinit_module_engine", - ":libinit_stub_empty", - ] +group("modulegroup") { + if (!defined(ohos_lite)) { + deps = [ + ":libinit_module_engine", + ":libinit_stub_empty", + ] + } } diff --git a/interfaces/kits/BUILD.gn b/interfaces/kits/BUILD.gn index 325f2cad2..3d4e7753a 100755 --- a/interfaces/kits/BUILD.gn +++ b/interfaces/kits/BUILD.gn @@ -14,15 +14,17 @@ import("//build/ohos.gni") group("kitsgroup") { - deps = [ - "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy", - "//base/startup/init_lite/interfaces/innerkits:libbegetutil", - ] - deps += [ "syscap:deviceinfo_ndk" ] - if (support_jsapi) { - deps += [ - "jskits:deviceinfo", - "jskits:systemparameter", + if (!defined(ohos_lite)) { + deps = [ + "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy", + "//base/startup/init_lite/interfaces/innerkits:libbegetutil", ] + deps += [ "syscap:deviceinfo_ndk" ] + if (support_jsapi) { + deps += [ + "jskits:deviceinfo", + "jskits:systemparameter", + ] + } } } diff --git a/services/begetctl/BUILD.gn b/services/begetctl/BUILD.gn index fa8ffda8e..67005f5aa 100755 --- a/services/begetctl/BUILD.gn +++ b/services/begetctl/BUILD.gn @@ -54,12 +54,6 @@ if (defined(ohos_lite)) { "//third_party/bounds_checking_function:libsec_static", ] } - group("begetctl_cmd") { - if (enable_ohos_startup_init_feature_begetctl_liteos && - ohos_kernel_type != "liteos_m") { - deps = [ ":begetctl" ] - } - } } else { import("//build/ohos.gni") @@ -207,8 +201,15 @@ if (defined(ohos_lite)) { install_enable = true part_name = "init" } +} - group("begetctl_cmd") { +group("begetctl_cmd") { + if (defined(ohos_lite)) { + if (enable_ohos_startup_init_feature_begetctl_liteos && + ohos_kernel_type != "liteos_m") { + deps = [ ":begetctl" ] + } + } else { deps = [ ":begetctl", ":param", diff --git a/services/init/lite/bundle.json b/services/init/lite/bundle.json index 40b589424..b3c37cfdd 100644 --- a/services/init/lite/bundle.json +++ b/services/init/lite/bundle.json @@ -29,11 +29,13 @@ }, "build": { "sub_component": [ - "//base/startup/init_lite/interfaces/innerkits:libbegetutil", "//base/startup/init_lite/services:startup_init", + "//base/startup/init_lite/ueventd:startup_ueventd", + "//base/startup/init_lite/watchdog:watchdog", "//base/startup/init_lite/services/begetctl:begetctl_cmd", - "//base/startup/init_lite/watchdog:init_watchdog", - "//base/startup/init_lite/ueventd:ueventd" + "//base/startup/init_lite/services/loopevent:loopeventgroup", + "//base/startup/init_lite/services/modules:modulesgroup", + "//base/startup/init_lite/services/param:parameter" ], "inner_kits": [ { @@ -52,7 +54,7 @@ } ], "test": [ - "//base/startup/init_lite/services:startup_init" + "//base/startup/init_lite/test:testgroup" ] } } diff --git a/services/loopevent/BUILD.gn b/services/loopevent/BUILD.gn index 248a969d3..428012ab3 100644 --- a/services/loopevent/BUILD.gn +++ b/services/loopevent/BUILD.gn @@ -63,3 +63,13 @@ if (defined(ohos_lite)) { subsystem_name = "startup" } } + +group("loopeventgroup") { + if (defined(ohos_lite)) { + if (ohos_kernel_type == "linux") { + deps = [ ":loopevent" ] + } + } else { + deps = [ ":loopevent" ] + } +} diff --git a/services/modules/BUILD.gn b/services/modules/BUILD.gn index 6df99eb2d..c0b4af8d8 100755 --- a/services/modules/BUILD.gn +++ b/services/modules/BUILD.gn @@ -11,48 +11,54 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//base/startup/init_lite/begetd.gni") -import("//build/ohos.gni") +if (!defined(ohos_lite)) { + import("//base/startup/init_lite/begetd.gni") + import("//build/ohos.gni") -ohos_shared_library("bootchart") { - sources = [ "bootchart/bootchart.c" ] + ohos_shared_library("bootchart") { + sources = [ "bootchart/bootchart.c" ] - include_dirs = [ - ".", - "//base/startup/init_lite/services/include/param", - ] + include_dirs = [ + ".", + "//base/startup/init_lite/services/include/param", + ] - deps = [ - "//base/startup/init_lite/services/param/base:parameterbase", - "//base/startup/init_lite/services/utils:libinit_utils", - "//third_party/bounds_checking_function:libsec_static", - "//third_party/cJSON:cjson_static", - ] + deps = [ + "//base/startup/init_lite/services/param/base:parameterbase", + "//base/startup/init_lite/services/utils:libinit_utils", + "//third_party/bounds_checking_function:libsec_static", + "//third_party/cJSON:cjson_static", + ] - external_deps = [ "init:libinit_module_engine" ] + external_deps = [ "init:libinit_module_engine" ] - part_name = "init" - if (target_cpu == "arm64") { - module_install_dir = "lib64/init" - } else { - module_install_dir = "lib/init" + part_name = "init" + if (target_cpu == "arm64") { + module_install_dir = "lib64/init" + } else { + module_install_dir = "lib/init" + } + } + + config("libbootchart_static_config") { + include_dirs = [ "." ] + } + + ohos_source_set("libbootchart_static") { + sources = [ "bootchart/bootchart_static.c" ] + public_configs = [ ":libbootchart_static_config" ] + public_configs += [ "//base/startup/init_lite/interfaces/innerkits/init_module_engine:init_module_engine_exported_config" ] } } -config("libbootchart_static_config") { - include_dirs = [ "." ] -} - -ohos_source_set("libbootchart_static") { - sources = [ "bootchart/bootchart_static.c" ] - public_configs = [ ":libbootchart_static_config" ] - public_configs += [ "//base/startup/init_lite/interfaces/innerkits/init_module_engine:init_module_engine_exported_config" ] -} - -group("modules") { - deps = [ ":bootchart" ] -} - group("static_modules") { - deps = [ ":libbootchart_static" ] + if (!defined(ohos_lite)) { + deps = [ ":libbootchart_static" ] + } +} + +group("modulesgroup") { + if (!defined(ohos_lite)) { + deps = [ ":bootchart" ] + } } diff --git a/services/param/BUILD.gn b/services/param/BUILD.gn index fdc000cad..2163b3deb 100755 --- a/services/param/BUILD.gn +++ b/services/param/BUILD.gn @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import("//base/startup/init_lite/begetd.gni") -import("//build/ohos.gni") group("parameter") { deps = [] diff --git a/test/BUILD.gn b/test/BUILD.gn new file mode 100644 index 000000000..e80d52fda --- /dev/null +++ b/test/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) 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/init_lite/begetd.gni") + +group("testgroup") { + testonly = true + if (!defined(ohos_lite)) { + deps = [ + "exec_test:exectest", + "fuzztest:fuzztest", + "moduletest:paramtestmodule", + "unittest:init_unittest", + ] + } else { + if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") { + deps = [ "unittest/lite:init_test" ] + } + } +} diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 5c3266a25..6b78d1cde 100755 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -276,11 +276,3 @@ ohos_unittest("init_unittest") { "init/service_unittest.cpp", ] } - -group("init_test") { - testonly = true - deps = [ - ":init_unittest", - "//base/startup/init_lite/test/moduletest:paramtestmodule", - ] -} diff --git a/ueventd/BUILD.gn b/ueventd/BUILD.gn index 3bcf1d162..051a407ef 100644 --- a/ueventd/BUILD.gn +++ b/ueventd/BUILD.gn @@ -52,17 +52,6 @@ if (defined(ohos_lite)) { outputs = [ "$root_out_dir/etc/ueventd.config" ] } } - - group("ueventd") { - if (ohos_kernel_type == "linux") { - deps = [ - ":ueventd.config", - ":ueventd_linux", - ] - } else { - deps = [] - } - } } else { import("//build/ohos.gni") service_ueventd_sources = [ @@ -150,3 +139,22 @@ if (defined(ohos_lite)) { ] } } + +group("startup_ueventd") { + if (defined(ohos_lite)) { + if (ohos_kernel_type == "linux") { + deps = [ + ":ueventd.config", + ":ueventd_linux", + ] + } else { + deps = [] + } + } else { + deps = [ + "//base/startup/init_lite/ueventd:libueventd_ramdisk_static", + "//base/startup/init_lite/ueventd:ueventd", + "//base/startup/init_lite/ueventd:ueventd.config", + ] + } +} diff --git a/watchdog/BUILD.gn b/watchdog/BUILD.gn index 5fdf44043..4c25e147b 100644 --- a/watchdog/BUILD.gn +++ b/watchdog/BUILD.gn @@ -11,10 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -group("watchdog") { - deps = [ ":watchdog_service" ] -} - if (defined(ohos_lite)) { executable("watchdog_service") { sources = [ @@ -33,12 +29,6 @@ if (defined(ohos_lite)) { defines += [ "LINUX_WATCHDOG" ] } } - - group("init_watchdog") { - if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { - deps = [ ":watchdog_service" ] - } - } } else { import("//build/ohos.gni") ohos_executable("watchdog_service") { @@ -54,3 +44,15 @@ if (defined(ohos_lite)) { part_name = "init" } } + +group("watchdog") { + if (defined(ohos_lite)) { + if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { + deps = [ ":watchdog_service" ] + } else { + deps = [] + } + } else { + deps = [ ":watchdog_service" ] + } +}