Merge "Soong: Add BUILD_MODULES build action in soong_ui."

This commit is contained in:
Treehugger Robot 2019-06-21 03:11:34 +00:00 committed by Gerrit Code Review
commit 45cdb71290
3 changed files with 51 additions and 1 deletions

View file

@ -337,7 +337,7 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config {
}{{
name: "all-modules",
description: "Build action: build from the top of the source tree.",
action: build.BUILD_MODULES_IN_A_DIRECTORY,
action: build.BUILD_MODULES,
buildDependencies: true,
}, {
name: "modules-in-a-dir-no-deps",

View file

@ -71,6 +71,9 @@ const (
// Builds all of the modules and their dependencies of a list of specified directories. All specified
// directories are relative to the root directory of the source tree.
BUILD_MODULES_IN_DIRECTORIES
// Build a list of specified modules. If none was specified, simply build the whole source tree.
BUILD_MODULES
)
// checkTopDir validates that the current directory is at the root directory of the source tree.
@ -290,6 +293,8 @@ func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx C
var targets []string
switch action {
case BUILD_MODULES:
// No additional processing is required when building a list of specific modules or all modules.
case BUILD_MODULES_IN_A_DIRECTORY:
// If dir is the root source tree, all the modules are built of the source tree are built so
// no need to find the build file.

View file

@ -763,6 +763,51 @@ func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction,
}
}
func TestGetConfigArgsBuildModules(t *testing.T) {
tests := []buildActionTestCase{{
description: "normal execution from the root source tree directory",
dirsInTrees: []string{"0/1/2", "0/2", "0/3"},
buildFiles: []string{"0/1/2/Android.mk", "0/2/Android.bp", "0/3/Android.mk"},
args: []string{"-j", "fake_module", "fake_module2"},
curDir: ".",
tidyOnly: "",
expectedArgs: []string{"-j", "fake_module", "fake_module2"},
expectedEnvVars: []envVar{},
}, {
description: "normal execution in deep directory",
dirsInTrees: []string{"0/1/2", "0/2", "0/3", "1/2/3/4/5/6/7/8/9/1/2/3/4/5/6"},
buildFiles: []string{"0/1/2/Android.mk", "0/2/Android.bp", "1/2/3/4/5/6/7/8/9/1/2/3/4/5/6/Android.mk"},
args: []string{"-j", "fake_module", "fake_module2", "-k"},
curDir: "1/2/3/4/5/6/7/8/9",
tidyOnly: "",
expectedArgs: []string{"-j", "fake_module", "fake_module2", "-k"},
expectedEnvVars: []envVar{},
}, {
description: "normal execution in deep directory, no targets",
dirsInTrees: []string{"0/1/2", "0/2", "0/3", "1/2/3/4/5/6/7/8/9/1/2/3/4/5/6"},
buildFiles: []string{"0/1/2/Android.mk", "0/2/Android.bp", "1/2/3/4/5/6/7/8/9/1/2/3/4/5/6/Android.mk"},
args: []string{"-j", "-k"},
curDir: "1/2/3/4/5/6/7/8/9",
tidyOnly: "",
expectedArgs: []string{"-j", "-k"},
expectedEnvVars: []envVar{},
}, {
description: "normal execution in root source tree, no args",
dirsInTrees: []string{"0/1/2", "0/2", "0/3"},
buildFiles: []string{"0/1/2/Android.mk", "0/2/Android.bp"},
args: []string{},
curDir: "1/2/3/4/5/6/7/8/9",
tidyOnly: "",
expectedArgs: []string{},
expectedEnvVars: []envVar{},
}}
for _, tt := range tests {
t.Run("build action BUILD_MODULES with dependencies, "+tt.description, func(t *testing.T) {
testGetConfigArgs(t, tt, BUILD_MODULES, true)
})
}
}
// TODO: Remove this test case once mm shell build command has been deprecated.
func TestGetConfigArgsBuildModulesInDirecotoryNoDeps(t *testing.T) {
tests := []buildActionTestCase{{