From 95a47feaf39ce17847247d4876a7ab88706b64b9 Mon Sep 17 00:00:00 2001 From: Jaesoo Lee Date: Fri, 3 Mar 2017 13:07:39 +0900 Subject: added a new build module for statically linked toybox (toybox_static) In order to enable modprobe in recovery mode (for Treble), this change add a target for building statically linked toybox (toybox_static). The binary is installed in /sbin of root file system along with symbolic link to it for 'modprobe'. Bug: 35633646 Test: Build and tested it works in recovery Change-Id: I589c4a248e135c6c0e25aadd063717c87369ef40 --- Android.mk | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/Android.mk b/Android.mk index b0c6ae44..92c8e42b 100644 --- a/Android.mk +++ b/Android.mk @@ -44,9 +44,7 @@ LOCAL_PATH := $(call my-dir) # # If you just want to use it as "toybox x" rather than "x", you can stop now. # # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS. -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ +common_SRC_FILES := \ lib/args.c \ lib/dirtree.c \ lib/getmountlist.c \ @@ -210,7 +208,7 @@ LOCAL_SRC_FILES := \ toys/posix/wc.c \ toys/posix/xargs.c \ -LOCAL_CFLAGS += \ +common_CFLAGS := \ -std=c99 \ -Os \ -Wno-char-subscripts \ @@ -226,7 +224,16 @@ toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null) toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android -LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"' + +common_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"' + +############################################ +# toybox for /system +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(common_SRC_FILES) + +LOCAL_CFLAGS := $(common_CFLAGS) LOCAL_CLANG := true @@ -395,3 +402,33 @@ ALL_TOOLS := \ LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);) include $(BUILD_EXECUTABLE) + +############################################ +# static version to be installed in recovery + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(common_SRC_FILES) + +LOCAL_CFLAGS := $(common_CFLAGS) + +LOCAL_CLANG := true + +LOCAL_STATIC_LIBRARIES := liblog libcutils libselinux libcrypto libm libc + +# libc++_static is needed by static liblog +LOCAL_CXX_STL := libc++_static + +LOCAL_MODULE := toybox_static + +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)/sbin + +LOCAL_FORCE_STATIC_EXECUTABLE := true + +ALL_TOOLS := \ + modprobe \ + +# Install the symlinks. +LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);) + +include $(BUILD_EXECUTABLE) -- cgit v1.2.3