Skip to content

Commit

Permalink
Rework busybox build process, remove compressed includes
Browse files Browse the repository at this point in the history
Like the kernel, use an output folder to generate includes

Signed-off-by: Tanguy Pruvot <[email protected]>

Change-Id: I988675b071c7a9a959598734fdaff1fdda4e274f
  • Loading branch information
tpruvot committed Jul 21, 2014
1 parent 6a06a10 commit 3862b5f
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 23,286 deletions.
100 changes: 57 additions & 43 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,64 @@ LOCAL_CFLAGS += -DBIONIC_L
endif
include $(BUILD_STATIC_LIBRARY)

#####################################################################

# Execute make prepare for normal config & static lib (recovery)

LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)

# Explicitly set an architecture specific CONFIG_CROSS_COMPILER_PREFIX
ifeq ($(TARGET_ARCH),arm)
BUSYBOX_CROSS_COMPILER_PREFIX := "arm-eabi-"
BUSYBOX_CROSS_COMPILER_PREFIX := arm-eabi-
endif
ifeq ($(TARGET_ARCH),x86)
BUSYBOX_CROSS_COMPILER_PREFIX := "i686-linux-android-"
BUSYBOX_CROSS_COMPILER_PREFIX := i686-linux-android-
endif
ifeq ($(TARGET_ARCH),mips)
BUSYBOX_CROSS_COMPILER_PREFIX := mipsel-linux-android-
endif

# Each profile require a compressed usage/config, outside the source tree for git history
# We keep the uncompressed headers in local include-<profile> to track config changes.
# TODO: generate includes in out/
KERNEL_MODULES_DIR ?= /system/lib/modules

# BB_INCLUDES_OUT := $(TARGET_OUT_INTERMEDIATES)/include
# $(BB_INCLUDES_OUT):
# mkdir -p $(ANDROID_BUILD_TOP)/$(BB_INCLUDES_OUT)
bb_gen := $(TARGET_OUT_INTERMEDIATES)/busybox

# Execute make clean, make prepare and copy profiles required for normal & static lib (recovery)
LOCAL_MODULE := busybox_prepare_full
LOCAL_MODULE_TAGS := eng debug
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(bb_gen)/full
LOCAL_SRC_FILES := .config-full
$(LOCAL_MODULE):
@echo -e ${CL_GRN}"Prepare config for busybox binary"${CL_RST}
@rm -rf $(bb_gen)/full
@mkdir -p $(bb_gen)/full/include
cat $(BB_PATH)/.config-full > $(bb_gen)/full/.config
@echo "CONFIG_CROSS_COMPILER_PREFIX=\"$(BUSYBOX_CROSS_COMPILER_PREFIX)\"" >> $(bb_gen)/full/.config
cd $(BB_PATH) && make prepare O=$(bb_gen)/full

include $(BUILD_PREBUILT)

LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)

KERNEL_MODULES_DIR ?= /system/lib/modules
BUSYBOX_CONFIG := minimal full
$(BUSYBOX_CONFIG):
@echo -e ${CL_PFX}"prepare config for busybox $@ profile"${CL_RST}
@cd $(BB_PATH) && make clean
@cd $(BB_PATH) && git clean -f -- ./include-$@/
cp $(BB_PATH)/.config-$@ $(BB_PATH)/.config
echo "CONFIG_CROSS_COMPILER_PREFIX=\"$(BUSYBOX_CROSS_COMPILER_PREFIX)\"" >> $(BB_PATH)/.config
cd $(BB_PATH) && make prepare
@#cp $(BB_PATH)/.config $(BB_PATH)/.config-$@
@mkdir -p $(BB_PATH)/include-$@
cp $(BB_PATH)/include/*.h $(BB_PATH)/include-$@/
@rm $(BB_PATH)/include/usage_compressed.h
@rm $(BB_PATH)/include/autoconf.h
@rm -f $(BB_PATH)/.config-old

busybox_prepare: $(BUSYBOX_CONFIG)
LOCAL_MODULE := busybox_prepare
bb_gen := $(TARGET_OUT_INTERMEDIATES)/busybox

LOCAL_MODULE := busybox_prepare_minimal
LOCAL_MODULE_TAGS := eng debug
include $(BUILD_STATIC_LIBRARY)
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(bb_gen)/minimal
LOCAL_SRC_FILES := .config-minimal
$(LOCAL_MODULE):
@echo -e ${CL_GRN}"Prepare config for libbusybox"${CL_RST}
@rm -rf $(bb_gen)/minimal
@mkdir -p $(bb_gen)/minimal/include
cat $(BB_PATH)/.config-minimal > $(bb_gen)/minimal/.config
@echo "CONFIG_CROSS_COMPILER_PREFIX=\"$(BUSYBOX_CROSS_COMPILER_PREFIX)\"" >> $(bb_gen)/minimal/.config
cd $(BB_PATH) && make prepare O=$(bb_gen)/minimal

include $(BUILD_PREBUILT)

#####################################################################

LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)
Expand All @@ -76,11 +90,12 @@ KERNEL_MODULES_DIR ?= /system/lib/modules

SUBMAKE := make -s -C $(BB_PATH) CC=$(CC)

BUSYBOX_SRC_FILES = $(shell cat $(BB_PATH)/busybox-$(BUSYBOX_CONFIG).sources) \
BUSYBOX_SRC_FILES = \
$(shell cat $(BB_PATH)/busybox-$(BUSYBOX_CONFIG).sources) \
libbb/android.c

ifeq ($(TARGET_ARCH),arm)
BUSYBOX_SRC_FILES += \
BUSYBOX_SRC_FILES += \
android/libc/arch-arm/syscalls/adjtimex.S \
android/libc/arch-arm/syscalls/getsid.S \
android/libc/arch-arm/syscalls/stime.S \
Expand All @@ -90,7 +105,7 @@ ifeq ($(TARGET_ARCH),arm)
endif

ifeq ($(TARGET_ARCH),x86)
BUSYBOX_SRC_FILES += \
BUSYBOX_SRC_FILES += \
android/libc/arch-x86/syscalls/adjtimex.S \
android/libc/arch-x86/syscalls/getsid.S \
android/libc/arch-x86/syscalls/stime.S \
Expand All @@ -100,7 +115,7 @@ ifeq ($(TARGET_ARCH),x86)
endif

ifeq ($(TARGET_ARCH),mips)
BUSYBOX_SRC_FILES += \
BUSYBOX_SRC_FILES += \
android/libc/arch-mips/syscalls/adjtimex.S \
android/libc/arch-mips/syscalls/getsid.S \
android/libc/arch-mips/syscalls/stime.S \
Expand All @@ -110,7 +125,6 @@ ifeq ($(TARGET_ARCH),mips)
endif

BUSYBOX_C_INCLUDES = \
$(BB_PATH)/include-$(BUSYBOX_CONFIG) \
$(BB_PATH)/include $(BB_PATH)/libbb \
bionic/libc/private \
bionic/libm/include \
Expand All @@ -128,17 +142,17 @@ BUSYBOX_CFLAGS = \
-DANDROID \
-fno-strict-aliasing \
-fno-builtin-stpcpy \
-include include-$(BUSYBOX_CONFIG)/autoconf.h \
-include $(bb_gen)/$(BUSYBOX_CONFIG)/include/autoconf.h \
-D'CONFIG_DEFAULT_MODULES_DIR="$(KERNEL_MODULES_DIR)"' \
-D'BB_VER="$(strip $(shell $(SUBMAKE) kernelversion)) $(BUSYBOX_SUFFIX)"' -DBB_BT=AUTOCONF_TIMESTAMP

# to handle differences in ICS/JB (ipv6)
ifeq ($(BIONIC_ICS),true)
BUSYBOX_CFLAGS += -DBIONIC_ICS
BUSYBOX_CFLAGS += -DBIONIC_ICS
endif

ifeq ($(BIONIC_L),true)
BUSYBOX_CFLAGS += -DBIONIC_L
BUSYBOX_CFLAGS += -DBIONIC_L
endif


Expand All @@ -147,7 +161,7 @@ endif
BUSYBOX_CONFIG:=minimal
BUSYBOX_SUFFIX:=static
LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
LOCAL_C_INCLUDES := $(BUSYBOX_C_INCLUDES)
LOCAL_C_INCLUDES := $(bb_gen)/minimal/include $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := -Dmain=busybox_driver $(BUSYBOX_CFLAGS)
LOCAL_CFLAGS += \
-DRECOVERY_VERSION \
Expand All @@ -161,7 +175,7 @@ LOCAL_CFLAGS += \
LOCAL_MODULE := libbusybox
LOCAL_MODULE_TAGS := eng debug
LOCAL_STATIC_LIBRARIES := libcutils libc libm libselinux libsepol
$(LOCAL_MODULE): busybox_prepare
LOCAL_ADDITIONAL_DEPENDENCIES := busybox_prepare_minimal
include $(BUILD_STATIC_LIBRARY)


Expand All @@ -176,15 +190,15 @@ LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
ifeq ($(BIONIC_ICS),true)
LOCAL_SRC_FILES += android/libc/__set_errno.c
endif
LOCAL_C_INCLUDES := $(BUSYBOX_C_INCLUDES)
LOCAL_C_INCLUDES := $(bb_gen)/full/include $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := $(BUSYBOX_CFLAGS)
LOCAL_LDFLAGS += -Wl,--no-fatal-warnings
LOCAL_MODULE := busybox
LOCAL_MODULE_TAGS := eng debug
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_SHARED_LIBRARIES := libc libcutils libm
LOCAL_STATIC_LIBRARIES := libclearsilverregex libuclibcrpc libselinux libsepol
$(LOCAL_MODULE): busybox_prepare
LOCAL_ADDITIONAL_DEPENDENCIES := busybox_prepare_full
include $(BUILD_EXECUTABLE)

BUSYBOX_LINKS := $(shell cat $(BB_PATH)/busybox-$(BUSYBOX_CONFIG).links)
Expand All @@ -193,7 +207,7 @@ exclude := nc
SYMLINKS := $(addprefix $(TARGET_OUT_OPTIONAL_EXECUTABLES)/,$(filter-out $(exclude),$(notdir $(BUSYBOX_LINKS))))
$(SYMLINKS): BUSYBOX_BINARY := $(LOCAL_MODULE)
$(SYMLINKS): $(LOCAL_INSTALLED_MODULE)
@echo "Symlink: $@ -> $(BUSYBOX_BINARY)"
@echo -e ${CL_CYN}"Symlink:"${CL_RST}" $@ -> $(BUSYBOX_BINARY)"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf $(BUSYBOX_BINARY) $@
Expand All @@ -214,7 +228,7 @@ include $(CLEAR_VARS)
BUSYBOX_CONFIG:=full
BUSYBOX_SUFFIX:=static
LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
LOCAL_C_INCLUDES := $(BUSYBOX_C_INCLUDES)
LOCAL_C_INCLUDES := $(bb_gen)/full/include $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := $(BUSYBOX_CFLAGS)
LOCAL_CFLAGS += \
-Dgetusershell=busybox_getusershell \
Expand All @@ -233,5 +247,5 @@ LOCAL_STATIC_LIBRARIES := libclearsilverregex libc libcutils libm libuclibcrpc l
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
$(LOCAL_MODULE): busybox_prepare
LOCAL_ADDITIONAL_DEPENDENCIES := busybox_prepare_full
include $(BUILD_EXECUTABLE)
11 changes: 8 additions & 3 deletions CleanSpec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/busybox_prepare_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/include/busybox-*)
$(call add-clean-step, rm -f $(PRODUCT_OUT)/utilities/busybox)
$(call add-clean-step, rm -f $(PRODUCT_OUT)/symbols/system/xbin/busybox)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/busybox)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/ETC/busybox_*)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/busybox_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbusybox_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/UTILITY_EXECUTABLES/static_busybox_intermediates)

$(call add-clean-step, rm $(PRODUCT_OUT)/symbols/system/xbin/busybox)
$(call add-clean-step, rm -f external/busybox/.config)
$(call add-clean-step, cd external/busybox && git clean -f -- include*)

# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
Expand Down
18 changes: 8 additions & 10 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ Note about this Android Variant :

WARNING : THIS IS A BIONIC VERSION OF BUSYBOX, DO NOT USE "make" IN THIS TREE

This tree has multiple configurations,
This tree has multiple configurations (busybox and recovery lib),

- select the wanted config profile (full or minimal) :
cp .config-full .config
- lunch your device to prepare the environment
- edit the wanted config profile (.config-full or .config-minimal)

- type "make menuconfig" to update .config
- type "make prepare" to generate include/ files
- copy the generated files in include-full/ or include-minimal/
- type "mma" in external/busybox to build with the dependencies

(there is a script to copy files inside these directories)
Finally copy $OUT/obj/busybox/full/.config to .config-full without
the CONFIG_CROSS_COMPILER_PREFIX line ! to stay compatible with x86 targets

finally copy .config to .config-full or .config-minimal

please also check busybox-profile.links and busybox-profile.sources
If you add or remove some applets,
please also update busybox-profile.links and busybox-profile.sources

----------------

Expand Down
21 changes: 0 additions & 21 deletions android_config.sh

This file was deleted.

1 change: 0 additions & 1 deletion include-full/NUM_APPLETS.h

This file was deleted.

Loading

0 comments on commit 3862b5f

Please sign in to comment.