From 13eb053a25a743d1e926850695c5322e3d94b3f4 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 15 Feb 2021 14:13:51 +0900 Subject: [PATCH] Build first-stage init in Soong The first-stage init has been built in Make due to some requirements (like placing it directly under the root directory rather than bin/, and creating mountpoints like /proc, etc.) that are not supported in Soong. However, Ie06dc5a93635ea8b1e18be517ed8615b6c82fee6 will make it possible to satisfy the requirements in Soong. The build of the boot image is done in Soong and we can create mount points using the `dirs` property and create a symlink /init that points to /bin/init_vendor using the `symlinks` property. To complete the picture of build everying in Soong, this change adds a Soong-version of the first-stage init. Note that the Soong-based boot image creation is currently only for the microdroid usecase. Therefore, the Android.mk-based first-stage init still remains and will be removed later. Bug: 178562516 Test: m init_first_stage_soong Change-Id: I278cb60a11d94fb48341fd3592be0652a25bdbfb --- init/Android.bp | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/init/Android.bp b/init/Android.bp index b0a59b1b8..5da8e360b 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -235,6 +235,119 @@ cc_binary { visibility: ["//packages/modules/Virtualization/microdroid"], } +// This currently is only for the VM usecase. +// TODO(jiyong): replace init_first_stage in Android.mk with this +cc_binary { + name: "init_first_stage_soong", + stem: "init_vendor", + + srcs: [ + "block_dev_initializer.cpp", + "devices.cpp", + "first_stage_console.cpp", + "first_stage_init.cpp", + "first_stage_main.cpp", + "first_stage_mount.cpp", + "reboot_utils.cpp", + "selabel.cpp", + "selinux.cpp", + "service_utils.cpp", + "snapuserd_transition.cpp", + "switch_root.cpp", + "uevent_listener.cpp", + "util.cpp", + ], + + static_libs: [ + "libc++fs", + "libfs_avb", + "libfs_mgr", + "libfec", + "libfec_rs", + "libsquashfs_utils", + "liblogwrap", + "libext4_utils", + "libcrypto_utils", + "libsparse", + "libavb", + "libkeyutils", + "liblp", + "libcutils", + "libbase", + "liblog", + "libcrypto_static", + "libdl", + "libz", + "libselinux", + "libcap", + "libgsi", + "libcom.android.sysprop.apex", + "liblzma", + "libunwindstack_no_dex", + "libbacktrace_no_dex", + "libmodprobe", + "libext2_uuid", + "libprotobuf-cpp-lite", + "libsnapshot_cow", + "libsnapshot_init", + "update_metadata-protos", + ], + + static_executable: true, + + cflags: [ + "-Wall", + "-Wextra", + "-Wno-unused-parameter", + "-Werror", + "-DALLOW_FIRST_STAGE_CONSOLE=0", + "-DALLOW_LOCAL_PROP_OVERRIDE=0", + "-DALLOW_PERMISSIVE_SELINUX=0", + "-DREBOOT_BOOTLOADER_ON_PANIC=0", + "-DWORLD_WRITABLE_KMSG=0", + "-DDUMP_ON_UMOUNT_FAILURE=0", + "-DSHUTDOWN_ZERO_TIMEOUT=0", + "-DLOG_UEVENTS=0", + "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number + ], + + product_variables: { + debuggable: { + cflags: [ + "-UALLOW_FIRST_STAGE_CONSOLE", + "-DALLOW_FIRST_STAGE_CONSOLE=1", + + "-UALLOW_LOCAL_PROP_OVERRIDE", + "-DALLOW_LOCAL_PROP_OVERRIDE=1", + + "-UALLOW_PERMISSIVE_SELINUX", + "-DALLOW_PERMISSIVE_SELINUX=1", + + "-UREBOOT_BOOTLOADER_ON_PANIC", + "-DREBOOT_BOOTLOADER_ON_PANIC=1", + + "-UWORLD_WRITABLE_KMSG", + "-DWORLD_WRITABLE_KMSG=1", + + "-UDUMP_ON_UMOUNT_FAILURE", + "-DDUMP_ON_UMOUNT_FAILURE=1", + ], + }, + + eng: { + cflags: [ + "-USHUTDOWN_ZERO_TIMEOUT", + "-DSHUTDOWN_ZERO_TIMEOUT=1", + ], + }, + }, + + sanitize: { + misc_undefined: ["signed-integer-overflow"], + hwaddress: false, + }, +} + // Tests // ------------------------------------------------------------------------------