Build recovery with Soong.

Fixes: 110380063
Test: `mmma -j bootable/recovery` with aosp_taimen-userdebug
Test: Build and boot into recovery on taimen. Check the basic
      functionalities (`Apply update from ADB`, `View recovery logs`,
      `Run graphics test`).
Test: Run recovery_unit_test and recovery_component_test on marlin.
Test: Modify `recovery.cpp` locally to trigger the call to
      is_battery_ok(). Check that the battery info is reported
      correctly.
Test: `build/soong/build_test.bash --dist`
Change-Id: I391eb201d57c760e457ba2bf2410ceb72596795c
This commit is contained in:
Tao Bao 2018-08-07 14:38:51 -07:00
parent afa16480aa
commit 5fc72a103b
4 changed files with 140 additions and 189 deletions

View file

@ -26,6 +26,34 @@ cc_defaults {
], ],
} }
cc_library {
name: "librecovery_ui",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"device.cpp",
"screen_ui.cpp",
"ui.cpp",
"vr_ui.cpp",
"wear_ui.cpp"
],
static_libs: [
"libminui",
"libotautil",
],
shared_libs: [
"libbase",
"libpng",
"libz",
],
}
// Generic device that uses ScreenRecoveryUI. // Generic device that uses ScreenRecoveryUI.
cc_library_static { cc_library_static {
name: "librecovery_ui_default", name: "librecovery_ui_default",
@ -68,6 +96,78 @@ cc_library_static {
], ],
} }
cc_defaults {
name: "librecovery_defaults",
defaults: [
"recovery_defaults",
],
shared_libs: [
"libasyncio",
"libbase",
"libbootloader_message",
"libcrypto",
"libcrypto_utils",
"libcutils",
"libext4_utils",
"libfs_mgr",
"libfusesideload",
"libhidl-gen-utils",
"liblog",
"libpng",
"libselinux",
"libsparse",
"libtinyxml2",
"libutils",
"libz",
"libziparchive",
],
static_libs: [
"libminadbd",
"libminui",
"libverifier",
"libotautil",
"libvintf_recovery",
"libvintf",
// TODO(b/80132328): Remove the dependency on static health HAL.
"libhealthd.default",
"android.hardware.health@2.0-impl",
"android.hardware.health@2.0",
"android.hardware.health@1.0",
"android.hardware.health@1.0-convert",
"libhealthstoragedefault",
"libhidltransport",
"libhidlbase",
"libhwbinder_noltopgo",
"libbatterymonitor",
],
}
cc_library_static {
name: "librecovery",
recovery_available: true,
defaults: [
"librecovery_defaults",
],
srcs: [
"adb_install.cpp",
"fsck_unshare_blocks.cpp",
"fuse_sdcard_provider.cpp",
"install.cpp",
"recovery.cpp",
"roots.cpp",
],
include_dirs: [
"system/vold",
],
}
cc_library_static { cc_library_static {
name: "libverifier", name: "libverifier",
recovery_available: true, recovery_available: true,
@ -92,6 +192,37 @@ cc_library_static {
], ],
} }
cc_binary {
name: "recovery",
recovery: true,
defaults: [
"librecovery_defaults",
],
srcs: [
"logging.cpp",
"recovery_main.cpp",
],
shared_libs: [
"librecovery_ui",
],
static_libs: [
"librecovery",
"librecovery_ui_default",
],
required: [
"e2fsdroid.recovery",
"librecovery_ui_ext",
"mke2fs.conf",
"mke2fs.recovery",
"recovery_deps",
],
}
// The dynamic executable that runs after /data mounts. // The dynamic executable that runs after /data mounts.
cc_binary { cc_binary {
name: "recovery-persist", name: "recovery-persist",

View file

@ -23,11 +23,6 @@ RECOVERY_FSTAB_VERSION := 2
# librecovery_ui_default, which uses ScreenRecoveryUI. # librecovery_ui_default, which uses ScreenRecoveryUI.
TARGET_RECOVERY_UI_LIB ?= librecovery_ui_default TARGET_RECOVERY_UI_LIB ?= librecovery_ui_default
recovery_common_cflags := \
-Wall \
-Werror \
-DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
# librecovery_ui_ext (shared library) # librecovery_ui_ext (shared library)
# =================================== # ===================================
include $(CLEAR_VARS) include $(CLEAR_VARS)
@ -49,169 +44,16 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libbase \ libbase \
liblog \ liblog \
librecovery_ui librecovery_ui.recovery
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
# librecovery_ui (shared library) # recovery_deps: A phony target that's depended on by `recovery`, which
# =============================== # builds additional modules conditionally based on Makefile variables.
include $(CLEAR_VARS) # ======================================================================
LOCAL_SRC_FILES := \
device.cpp \
screen_ui.cpp \
ui.cpp \
vr_ui.cpp \
wear_ui.cpp
LOCAL_MODULE := librecovery_ui
LOCAL_CFLAGS := $(recovery_common_cflags)
LOCAL_MULTILIB := first
ifeq ($(TARGET_IS_64_BIT),true)
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib64
else
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib
endif
LOCAL_STATIC_LIBRARIES := \
libminui \
libotautil \
LOCAL_SHARED_LIBRARIES := \
libbase \
libpng \
libz \
include $(BUILD_SHARED_LIBRARY)
# librecovery_ui (static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
device.cpp \
screen_ui.cpp \
ui.cpp \
vr_ui.cpp \
wear_ui.cpp
LOCAL_MODULE := librecovery_ui
LOCAL_CFLAGS := $(recovery_common_cflags)
LOCAL_STATIC_LIBRARIES := \
libminui \
libotautil \
LOCAL_SHARED_LIBRARIES := \
libbase \
libpng \
libz \
include $(BUILD_STATIC_LIBRARY)
# Health HAL dependency
health_hal_static_libraries := \
android.hardware.health@2.0-impl \
android.hardware.health@2.0 \
android.hardware.health@1.0 \
android.hardware.health@1.0-convert \
libhealthstoragedefault \
libhidltransport \
libhidlbase \
libhwbinder_noltopgo \
libvndksupport \
libbatterymonitor
librecovery_static_libraries := \
libfusesideload \
libminadbd \
libminui \
libverifier \
libotautil \
$(health_hal_static_libraries) \
libvintf_recovery \
libvintf \
librecovery_shared_libraries := \
libasyncio \
libbase \
libbootloader_message \
libcrypto \
libcrypto_utils \
libcutils \
libext4_utils \
libfs_mgr \
libhidl-gen-utils \
liblog \
libpng \
libselinux \
libtinyxml2 \
libutils \
libz \
libziparchive \
# librecovery (static library)
# ===============================
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_SRC_FILES := \ LOCAL_MODULE := recovery_deps
adb_install.cpp \
fsck_unshare_blocks.cpp \
fuse_sdcard_provider.cpp \
install.cpp \
recovery.cpp \
roots.cpp \
LOCAL_C_INCLUDES := \
system/vold \
LOCAL_CFLAGS := $(recovery_common_cflags)
LOCAL_MODULE := librecovery
LOCAL_STATIC_LIBRARIES := \
$(librecovery_static_libraries)
LOCAL_SHARED_LIBRARIES := \
$(librecovery_shared_libraries)
include $(BUILD_STATIC_LIBRARY)
# recovery (static executable)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
logging.cpp \
recovery_main.cpp \
LOCAL_MODULE := recovery
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
# Cannot link with LLD: undefined symbol: UsbNoPermissionsLongHelpText
# http://b/77543887, lld does not handle -Wl,--gc-sections as well as ld.
LOCAL_USE_CLANG_LLD := false
LOCAL_CFLAGS := $(recovery_common_cflags)
LOCAL_STATIC_LIBRARIES := \
librecovery \
librecovery_ui_default \
$(librecovery_static_libraries)
LOCAL_SHARED_LIBRARIES := \
librecovery_ui \
$(librecovery_shared_libraries)
LOCAL_HAL_STATIC_LIBRARIES := libhealthd
LOCAL_REQUIRED_MODULES := \
e2fsdroid.recovery \
mke2fs.recovery \
mke2fs.conf
ifeq ($(TARGET_USERIMAGES_USE_F2FS),true) ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
ifeq ($(HOST_OS),linux) ifeq ($(HOST_OS),linux)
@ -235,31 +77,7 @@ LOCAL_REQUIRED_MODULES += \
recovery-refresh recovery-refresh
endif endif
LOCAL_REQUIRED_MODULES += \ include $(BUILD_PHONY_PACKAGE)
librecovery_ui_ext
# TODO(b/110380063): Explicitly install the following shared libraries to recovery, until `recovery`
# module is built with Soong (with `recovery: true` flag).
LOCAL_REQUIRED_MODULES += \
libasyncio.recovery \
libbase.recovery \
libbootloader_message.recovery \
libcrypto.recovery \
libcrypto_utils.recovery \
libcutils.recovery \
libext4_utils.recovery \
libfs_mgr.recovery \
libhidl-gen-utils.recovery \
liblog.recovery \
libpng.recovery \
libselinux.recovery \
libsparse.recovery \
libtinyxml2.recovery \
libutils.recovery \
libz.recovery \
libziparchive.recovery \
include $(BUILD_EXECUTABLE)
include \ include \
$(LOCAL_PATH)/boot_control/Android.mk \ $(LOCAL_PATH)/boot_control/Android.mk \

View file

@ -14,6 +14,7 @@
cc_library { cc_library {
name: "libfusesideload", name: "libfusesideload",
recovery_available: true,
cflags: [ cflags: [
"-D_XOPEN_SOURCE", "-D_XOPEN_SOURCE",
@ -30,7 +31,7 @@ cc_library {
"include", "include",
], ],
static_libs: [ shared_libs: [
"libbase", "libbase",
"libcrypto", "libcrypto",
], ],

View file

@ -28,6 +28,7 @@ cc_defaults {
cc_library_static { cc_library_static {
name: "libminadbd", name: "libminadbd",
recovery_available: true,
defaults: [ defaults: [
"minadbd_defaults", "minadbd_defaults",