From 8642525726b3f3d11e64d0abf52af803f4e308ce Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 26 May 2016 15:32:15 -0700 Subject: [PATCH] Fix mm and mmm in Android.bp directories mm and mmm were not parsing out/soong/Android.mk, so they were ignoring all modules defined in an Android.bp file. Always include out/soong/Android.mk when ONE_SHOT_MAKEFILE is set, and convert the mm and mmm functions to build MODULES-IN-$DIR instead of all_modules so that only the subset of modules defined in out/soong/Android.mk for the requested directory are built. Bug: 28986194 Change-Id: I6e1ff8cacfc668a4154a0d5937450db840bb7a6b --- buildspec.mk.default | 2 +- core/envsetup.mk | 2 +- core/main.mk | 2 +- envsetup.sh | 31 ++++++++++++++++++++++--------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/buildspec.mk.default b/buildspec.mk.default index 3224d1a0f..714344ca4 100644 --- a/buildspec.mk.default +++ b/buildspec.mk.default @@ -105,4 +105,4 @@ endif # variable will be changed. After you have modified this file with the new # changes (see buildspec.mk.default), update this to the new value from # buildspec.mk.default. -BUILD_ENV_SEQUENCE_NUMBER := 10 +BUILD_ENV_SEQUENCE_NUMBER := 11 diff --git a/core/envsetup.mk b/core/envsetup.mk index 1a79ce238..ad5eb3044 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -20,7 +20,7 @@ include $(BUILD_SYSTEM)/version_defaults.mk # people who haven't re-run those will have to do so before they # can build. Make sure to also update the corresponding value in # buildspec.mk.default and envsetup.sh. -CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10 +CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 11 # --------------------------------------------------------------- # The product defaults to generic on hardware diff --git a/core/main.mk b/core/main.mk index 56be9ae33..9866dff1b 100644 --- a/core/main.mk +++ b/core/main.mk @@ -515,7 +515,7 @@ endif ifneq ($(ONE_SHOT_MAKEFILE),) # We've probably been invoked by the "mm" shell function # with a subdirectory's makefile. -include $(ONE_SHOT_MAKEFILE) +include $(SOONG_ANDROID_MK) $(call filter-soong-makefiles,$(ONE_SHOT_MAKEFILE)) # Change CUSTOM_MODULES to include only modules that were # defined by this makefile; this will install all of those # modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE diff --git a/envsetup.sh b/envsetup.sh index 3393b7531..3f6131830 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -290,7 +290,7 @@ function set_stuff_for_environment() function set_sequence_number() { - export BUILD_ENV_SEQUENCE_NUMBER=10 + export BUILD_ENV_SEQUENCE_NUMBER=11 } function settitle() @@ -749,7 +749,7 @@ function findmakefile() T= while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do T=`PWD= /bin/pwd` - if [ -f "$T/Android.mk" ]; then + if [ -f "$T/Android.mk" -o -f "$T/Android.bp" ]; then echo $T/Android.mk \cd $HERE return @@ -791,7 +791,9 @@ function mm() MODULES= ARGS=GET-INSTALL-PATH else - MODULES=all_modules + MODULES=MODULES-IN-$(dirname ${M}) + # Convert "/" to "-". + MODULES=${MODULES//\//-} ARGS=$@ fi if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then @@ -809,18 +811,25 @@ function mmm() if [ "$T" ]; then local MAKEFILE= local MODULES= + local MODULES_IN_PATHS= local ARGS= local DIR TO_CHOP + local DIR_MODULES local GET_INSTALL_PATH= local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') for DIR in $DIRS ; do - MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` - if [ "$MODULES" = "" ]; then - MODULES=all_modules - fi + DIR_MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'` - if [ -f $DIR/Android.mk ]; then + # Remove the leading ./ and trailing / if any exists. + DIR=${DIR#./} + DIR=${DIR%/} + if [ -f $DIR/Android.mk -o -f $DIR/Android.bp ]; then + if [ "$DIR_MODULES" = "" ]; then + MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$DIR" + else + MODULES="$MODULES $DIR_MODULES" + fi local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '` local TO_CHOP=`expr $TO_CHOP + 1` local START=`PWD= /bin/pwd` @@ -847,11 +856,15 @@ function mmm() if [ -n "$GET_INSTALL_PATH" ]; then ARGS=$GET_INSTALL_PATH MODULES= + MODULES_IN_PATHS= fi if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then MODULES=tidy_only + MODULES_IN_PATHS= fi - ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS + # Convert "/" to "-". + MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} + ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $MODULES_IN_PATHS $ARGS else echo "Couldn't locate the top of the tree. Try setting TOP." return 1