mma in dirs w/o Android.(mk|bp) in ancestor dir

Many Android.bp files are now no longer needed (since they
are all scanned and subdirs are deprecated), so there are many
places in a tree where they aren't hit.

This still suffers from one bug, given this directory structure:
 A/B/Android.bp
 A/B/C/D/Android.bp
 A/B/C/
 A/B/C/E/Android.bp

if you call 'mma' from 'A/B/C', then it will make
MODULES-IN-A-B.

However, for now, this change makes it so given the following
directory structure:
 A/B/C/D/Android.bp
 A/B/C/
 A/B/C/E/Android.bp

if you call 'mma' from 'A/B/C', then it will make
MODULES-IN-A-B-C as expected (since there are no makefiles in
parent directories). This is the expected behavior in this case
and it is common in directories where Android.bps have been
removed (since they only referenced subdirs) or outside of
git projects.

The reason why this usecase is supported is so that given this:
A/B/C/D/Android.bp
A/B/C/D/include/D/foo.h

You can, from A/B/C/D/include/D/ (for instance) do an mma, and
it will still make the modules defined in A/B/C/D/ which are
presumably related to this.

This change doesn't fix mm or other binaries. In the long term,
either we should just consider mma to make the current directory
(and not look for parent directories for the above 'feature') or
we should move more of the complexity in the build system itself
so that it can intelligently find the first parent directory
which contains a makefile in a subdirectory.

Fixes: 65407300
Test: mma from following dirs
    system/tools/hidl/test/hash_test/bad/hash/1.0 MODULES-IN-system-tools-hidl-test-hash_test
    system/tools/hidl/test/hash_test/             MODULES-IN-system-tools-hidl-test-hash_test
    system/                                       MODULES-IN-system
    hardware/ril/                                 MODULES-IN-hardware-ril

Change-Id: I072d3f382d40cd360ec3d14f8f5b060a4bde9289
This commit is contained in:
Steven Moreland 2018-06-13 15:31:59 -07:00
parent 504656816d
commit 3b99ecfbab

View file

@ -742,6 +742,7 @@ function findmakefile()
\cd ..
done
\cd $HERE
return 1
}
function mm()
@ -869,7 +870,7 @@ function mma()
echo "Couldn't locate the top of the tree. Try setting TOP."
return 1
fi
local M=$(findmakefile)
local M=$(findmakefile || echo $(realpath $PWD)/Android.mk)
# Remove the path to top as the makefilepath needs to be relative
local M=`echo $M|sed 's:'$T'/::'`
local MODULES_IN_PATHS=MODULES-IN-$(dirname ${M})