Improve mmm behavior when targets are specified.

When target directories are specified, mmm now scans their parent
direcotries to when searching for build config files. Also make it look
more like mm as minor refactoring.

Bug: 62899341
Test: Manual builds.
Change-Id: Ic9c081090e1baeb0849508e9086f2976b108c0ee
This commit is contained in:
Jaewoong Jung 2019-01-02 13:36:48 -08:00
parent 632d154393
commit b6112cdcc5
1 changed files with 21 additions and 13 deletions

View File

@ -765,6 +765,9 @@ function findmakefile()
{ {
local TOPFILE=build/make/core/envsetup.mk local TOPFILE=build/make/core/envsetup.mk
local HERE=$PWD local HERE=$PWD
if [ "$1" ]; then
\cd $1
fi;
local T= local T=
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
T=`PWD= /bin/pwd` T=`PWD= /bin/pwd`
@ -845,24 +848,29 @@ function mmm()
# Remove the leading ./ and trailing / if any exists. # Remove the leading ./ and trailing / if any exists.
DIR=${DIR#./} DIR=${DIR#./}
DIR=${DIR%/} DIR=${DIR%/}
if [ -f $DIR/Android.mk -o -f $DIR/Android.bp ]; then local M
local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '` if [ "$DIR_MODULES" = "" ]; then
local TO_CHOP=`expr $TO_CHOP + 1` M=$(findmakefile $DIR)
local START=`PWD= /bin/pwd` else
local MDIR=`echo $START | cut -c${TO_CHOP}-` # Only check the target directory if a module is specified.
if [ "$MDIR" = "" ] ; then if [ -f $DIR/Android.mk -o -f $DIR/Android.bp ]; then
MDIR=$DIR local HERE=$PWD
else cd $DIR
MDIR=$MDIR/$DIR M=`PWD= /bin/pwd`
M=$M/Android.mk
cd $HERE
fi fi
MDIR=${MDIR%/.} fi
if [ "$M" ]; then
# Remove the path to top as the makefilepath needs to be relative
local M=`echo $M|sed 's:'$T'/::'`
if [ "$DIR_MODULES" = "" ]; then if [ "$DIR_MODULES" = "" ]; then
MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$MDIR" MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$(dirname ${M})"
GET_INSTALL_PATHS="$GET_INSTALL_PATHS GET-INSTALL-PATH-IN-$MDIR" GET_INSTALL_PATHS="$GET_INSTALL_PATHS GET-INSTALL-PATH-IN-$(dirname ${M})"
else else
MODULES="$MODULES $DIR_MODULES" MODULES="$MODULES $DIR_MODULES"
fi fi
MAKEFILE="$MAKEFILE $MDIR/Android.mk" MAKEFILE="$MAKEFILE $M"
else else
case $DIR in case $DIR in
showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";; showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;