From caeaa08f9dcf011c71ef28278e616a425262f1fc Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 23 Sep 2015 16:08:55 -0700 Subject: [PATCH] Re-implement mma/mmma using make goals. Previously we use command line variable BUILD_MODULES_IN_PATHS which causes kati to regenerate build.ninja if any variable value changes. TODO: Remove the old rules of BUILD_MODULES_IN_PATHS in build/core/main.mk and ninja.mk once users have re-sourced envsetup.sh. Probably in a few weeks. Caveat: With this change, if a user sources the new envsetup.sh, mma/mmma won't work in old branches from the same shell. Bug: 24309760 Change-Id: I212e82aeebaaa2bd4114e2066f1995da8886b5e2 --- core/base_rules.mk | 9 +++++++++ envsetup.sh | 20 +++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 72278ce29..d96502d9b 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -255,6 +255,15 @@ $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name) .PHONY: $(my_register_name) $(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE) +# Set up phony targets that covers all modules under the given paths. +# This allows us to build everything in given paths by running mmma/mma. +my_path_components := $(subst /,$(space),$(LOCAL_PATH)) +my_path_prefix := MODULES-IN +$(foreach c, $(my_path_components),\ + $(eval my_path_prefix := $(my_path_prefix)/$(c))\ + $(eval .PHONY : $(my_path_prefix))\ + $(eval $(my_path_prefix) : $(my_register_name))) + ########################################################### ## Module installation rule ########################################################### diff --git a/envsetup.sh b/envsetup.sh index fcf3b47e5..1ff5f4a64 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -751,7 +751,7 @@ function mmm() MAKEFILE="$MAKEFILE $MFILE" else case $DIR in - showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";; + showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";; GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;; *) echo "No Android.mk in $DIR."; return 1;; esac @@ -780,7 +780,7 @@ function mma() return 1 fi local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'` - $DRV make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD" + $DRV make -C $T -f build/core/main.mk $@ MODULES-IN/$MY_PWD fi } @@ -798,23 +798,25 @@ function mmma() MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'` fi local DIR= - local MODULE_PATHS= + local MODULES_IN_PATHS= local ARGS= for DIR in $DIRS ; do if [ -d $DIR ]; then - if [ "$MY_PWD" = "" ]; then - MODULE_PATHS="$MODULE_PATHS $DIR" - else - MODULE_PATHS="$MODULE_PATHS $MY_PWD/$DIR" + # Remove the leading ./ and trailing / if any exists. + DIR=${DIR#./} + DIR=${DIR%/} + if [ "$MY_PWD" != "" ]; then + DIR=$MY_PWD/$DIR fi + MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN/$DIR" else case $DIR in - showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";; + showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";; *) echo "Couldn't find directory $DIR"; return 1;; esac fi done - $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS" + $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS $MODULES_IN_PATHS else echo "Couldn't locate the top of the tree. Try setting TOP." return 1