Loading cmd/soong_ui/main.go +28 −40 Original line number Diff line number Diff line Loading @@ -334,39 +334,33 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config { name string description string action build.BuildAction buildDependencies bool set bool }{{ name: "all-modules", description: "Build action: build from the top of the source tree.", action: build.BUILD_MODULES, buildDependencies: true, }, { // buildDependencies is set to true as mm is being deprecated. This is redirecting to mma build // command behaviour. Once it has soaked for a while, the build command is deleted from here once // it has been removed from the envsetup.sh. // This is redirecting to mma build command behaviour. Once it has soaked for a // while, the build command is deleted from here once it has been removed from the // envsetup.sh. name: "modules-in-a-dir-no-deps", description: "Build action: builds all of the modules in the current directory without their dependencies.", action: build.BUILD_MODULES_IN_A_DIRECTORY, buildDependencies: true, }, { // buildDependencies is set to true as mmm is being deprecated. This is redirecting to mmma build // command behaviour. Once it has soaked for a while, the build command is deleted from here once // it has been removed from the envsetup.sh. // This is redirecting to mmma build command behaviour. Once it has soaked for a // while, the build command is deleted from here once it has been removed from the // envsetup.sh. name: "modules-in-dirs-no-deps", description: "Build action: builds all of the modules in the supplied directories without their dependencies.", action: build.BUILD_MODULES_IN_DIRECTORIES, buildDependencies: true, }, { name: "modules-in-a-dir", description: "Build action: builds all of the modules in the current directory and their dependencies.", action: build.BUILD_MODULES_IN_A_DIRECTORY, buildDependencies: true, }, { name: "modules-in-dirs", description: "Build action: builds all of the modules in the supplied directories and their dependencies.", action: build.BUILD_MODULES_IN_DIRECTORIES, buildDependencies: true, }} for i, flag := range buildActionFlags { flags.BoolVar(&buildActionFlags[i].set, flag.name, false, flag.description) Loading @@ -386,12 +380,10 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config { // is specified. buildActionCount := 0 var buildAction build.BuildAction buildDependency := false for _, flag := range buildActionFlags { if flag.set { buildActionCount++ buildAction = flag.action buildDependency = flag.buildDependencies } } if buildActionCount != 1 { Loading @@ -403,7 +395,7 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config { // Remove the build action flags from the args as they are not recognized by the config. args = args[numBuildActionFlags:] return build.NewBuildActionConfig(buildAction, *dir, buildDependency, ctx, args...) return build.NewBuildActionConfig(buildAction, *dir, ctx, args...) } func make(ctx build.Context, config build.Config, _ []string, logsDir string) { Loading @@ -425,17 +417,13 @@ func make(ctx build.Context, config build.Config, _ []string, logsDir string) { if _, ok := config.Environment().Get("ONE_SHOT_MAKEFILE"); ok { writer := ctx.Writer fmt.Fprintln(writer, "! The variable `ONE_SHOT_MAKEFILE` is deprecated, and will be removed shortly.") fmt.Fprintln(writer, "! The variable `ONE_SHOT_MAKEFILE` is obsolete.") fmt.Fprintln(writer, "!") fmt.Fprintln(writer, "! If you're using `mm`, you'll need to run `source build/envsetup.sh` to update.") fmt.Fprintln(writer, "!") fmt.Fprintln(writer, "! Otherwise, either specify a module name with m, or use mma / MODULES-IN-...") fmt.Fprintln(writer, "") select { case <-time.After(30 * time.Second): case <-ctx.Done(): return } ctx.Fatal("done") } toBuild := build.BuildAll Loading ui/build/config.go +6 −18 Original line number Diff line number Diff line Loading @@ -253,13 +253,13 @@ func NewConfig(ctx Context, args ...string) Config { // NewBuildActionConfig returns a build configuration based on the build action. The arguments are // processed based on the build action and extracts any arguments that belongs to the build action. func NewBuildActionConfig(action BuildAction, dir string, buildDependencies bool, ctx Context, args ...string) Config { return NewConfig(ctx, getConfigArgs(action, dir, buildDependencies, ctx, args)...) func NewBuildActionConfig(action BuildAction, dir string, ctx Context, args ...string) Config { return NewConfig(ctx, getConfigArgs(action, dir, ctx, args)...) } // getConfigArgs processes the command arguments based on the build action and creates a set of new // arguments to be accepted by Config. func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx Context, args []string) []string { func getConfigArgs(action BuildAction, dir string, ctx Context, args []string) []string { // The next block of code verifies that the current directory is the root directory of the source // tree. It then finds the relative path of dir based on the root directory of the source tree // and verify that dir is inside of the source tree. Loading Loading @@ -295,7 +295,6 @@ func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx C configArgs = removeFromList("GET-INSTALL-PATH", configArgs) } var buildFiles []string var targets []string switch action { Loading @@ -312,20 +311,11 @@ func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx C if buildFile == "" { ctx.Fatalf("Build file not found for %s directory", relDir) } buildFiles = []string{buildFile} targets = []string{convertToTarget(filepath.Dir(buildFile), targetNamePrefix)} case BUILD_MODULES_IN_DIRECTORIES: newConfigArgs, dirs := splitArgs(configArgs) configArgs = newConfigArgs targets, buildFiles = getTargetsFromDirs(ctx, relDir, dirs, targetNamePrefix) } // This is to support building modules without building their dependencies. Soon, this will be // deprecated. if !buildDependencies && len(buildFiles) > 0 { if err := os.Setenv("ONE_SHOT_MAKEFILE", strings.Join(buildFiles, " ")); err != nil { ctx.Fatalf("Unable to set ONE_SHOT_MAKEFILE environment variable: %v", err) } targets = getTargetsFromDirs(ctx, relDir, dirs, targetNamePrefix) } // Tidy only override all other specified targets. Loading Loading @@ -435,7 +425,7 @@ func splitArgs(args []string) (newArgs []string, dirs []string) { // directory from the dirs list does not exist, a fatal error is raised. relDir is related to the // source root tree where the build action command was invoked. Each directory is validated if the // build file can be found and follows the format "dir1:target1,target2,...". Target is optional. func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePrefix string) (targets []string, buildFiles []string) { func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePrefix string) (targets []string) { for _, dir := range dirs { // The directory may have specified specific modules to build. ":" is the separator to separate // the directory and the list of modules. Loading Loading @@ -466,20 +456,18 @@ func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePre if !hasBuildFile(ctx, dir) { ctx.Fatalf("Couldn't locate a build file from %s directory", dir) } buildFiles = append(buildFiles, filepath.Join(dir, "Android.mk")) } else { buildFile := findBuildFile(ctx, dir) if buildFile == "" { ctx.Fatalf("Build file not found for %s directory", dir) } newTargets = []string{convertToTarget(filepath.Dir(buildFile), targetNamePrefix)} buildFiles = append(buildFiles, buildFile) } targets = append(targets, newTargets...) } return targets, buildFiles return targets } func (c *configImpl) parseArgs(ctx Context, args []string) { Loading ui/build/config_test.go +155 −355 Original line number Diff line number Diff line Loading @@ -363,9 +363,6 @@ func TestConfigGetTargets(t *testing.T) { // Expected targets from the function. expectedTargets []string // Expected build from the build system. expectedBuildFiles []string // Expecting error from running test case. errStr string }{{ Loading @@ -375,7 +372,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3"}, curDir: "0", expectedTargets: []string{"MODULES-IN-0-1-2-3"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, build file does not exist", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -397,7 +393,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:"}, curDir: "0", expectedTargets: []string{"MODULES-IN-0-1-2-3"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, two targets specified", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -405,7 +400,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2"}, curDir: "0", expectedTargets: []string{"t1", "t2"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, no targets and has a comma", dirsInTrees: []string{"0/1/2/3"}, Loading Loading @@ -434,7 +428,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2,t3,t4,t5,t6,t7,t8,t9,t10"}, curDir: "0", expectedTargets: []string{"t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", "t10"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, one target specified, build file does not exist", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -456,7 +449,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3"}, curDir: "0", expectedTargets: []string{"MODULES-IN-0-1-2"}, expectedBuildFiles: []string{"0/1/2/Android.mk"}, }, { description: "multiple targets dir specified, targets specified", dirsInTrees: []string{"0/1/2/3", "0/3/4"}, Loading @@ -464,7 +456,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2", "3/4:t3,t4,t5"}, curDir: "0", expectedTargets: []string{"t1", "t2", "t3", "t4", "t5"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk", "0/3/4/Android.mk"}, }, { description: "multiple targets dir specified, one directory has targets specified", dirsInTrees: []string{"0/1/2/3", "0/3/4"}, Loading @@ -472,7 +463,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2", "3/4"}, curDir: "0", expectedTargets: []string{"t1", "t2", "MODULES-IN-0-3-4"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk", "0/3/4/Android.mk"}, }, { description: "two dirs specified, only one dir exist", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -487,7 +477,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"0/1/2/3:t1,t2", "0/3/4"}, curDir: ".", expectedTargets: []string{"t1", "t2", "MODULES-IN-0-3-4"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk", "0/3/4/Android.mk"}, }, { description: "no directories specified", dirsInTrees: []string{"0/1/2/3", "0/3/4"}, Loading Loading @@ -518,13 +507,10 @@ func TestConfigGetTargets(t *testing.T) { r := setTop(t, topDir) defer r() targets, buildFiles := getTargetsFromDirs(ctx, tt.curDir, tt.dirs, "MODULES-IN-") targets := getTargetsFromDirs(ctx, tt.curDir, tt.dirs, "MODULES-IN-") if !reflect.DeepEqual(targets, tt.expectedTargets) { t.Errorf("expected %v, got %v for targets", tt.expectedTargets, targets) } if !reflect.DeepEqual(buildFiles, tt.expectedBuildFiles) { t.Errorf("expected %v, got %v for build files", tt.expectedBuildFiles, buildFiles) } // If the execution reached here and there was an expected error code, the unit test case failed. if tt.errStr != "" { Loading Loading @@ -732,14 +718,11 @@ type buildActionTestCase struct { // Expected arguments to be in Config instance. expectedArgs []string // Expected environment variables to be set. expectedEnvVars []envVar // Expecting error from running test case. expectedErrStr string } func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction, buildDependencies bool) { func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction) { ctx := testContext() defer logger.Recover(func(err error) { Loading @@ -753,7 +736,6 @@ func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction, // Environment variables to set it to blank on every test case run. resetEnvVars := []string{ "ONE_SHOT_MAKEFILE", "WITH_TIDY_ONLY", } Loading Loading @@ -807,17 +789,11 @@ func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction, t.Fatalf("failed to create %s file: %v", srcDirFileCheck, err) } args := getConfigArgs(action, tt.curDir, buildDependencies, ctx, tt.args) args := getConfigArgs(action, tt.curDir, ctx, tt.args) if !reflect.DeepEqual(tt.expectedArgs, args) { t.Fatalf("expected %v, got %v for config arguments", tt.expectedArgs, args) } for _, env := range tt.expectedEnvVars { if val := os.Getenv(env.name); val != env.value { t.Errorf("expecting %s, got %s for environment variable %s", env.value, val, env.name) } } // If the execution reached here and there was an expected error code, the unit test case failed. if tt.expectedErrStr != "" { t.Errorf("expecting error %s", tt.expectedErrStr) Loading @@ -833,7 +809,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { 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"}, Loading @@ -842,7 +817,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { 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"}, Loading @@ -851,7 +825,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { 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"}, Loading @@ -860,7 +833,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { curDir: "0/2", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{}, }, { description: "normal execution in symlink root source tree, no args", dirsInTrees: []string{"0/1/2", "0/2", "0/3"}, Loading @@ -870,94 +842,10 @@ func TestGetConfigArgsBuildModules(t *testing.T) { curDir: "0/2", 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{{ description: "normal execution in a directory", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/2/Android.mk"}, args: []string{"-j", "-k", "showcommands", "fake-module"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"-j", "-k", "showcommands", "fake-module", "MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/Android.mk"}}, }, { description: "makefile in parent directory", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/Android.mk"}, args: []string{}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/Android.mk"}}, }, { description: "build file not found", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{}, args: []string{}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/Android.mk"}}, expectedErrStr: "Build file not found for 0/1/2 directory", }, { description: "build action executed at root directory", dirsInTrees: []string{}, buildFiles: []string{}, args: []string{}, curDir: ".", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "GET-INSTALL-PATH specified,", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/Android.mk"}, args: []string{"GET-INSTALL-PATH"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"GET-INSTALL-PATH-IN-0-1"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/Android.mk"}}, }, { description: "tidy only environment variable specified,", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/Android.mk"}, args: []string{"GET-INSTALL-PATH"}, curDir: "0/1/2", tidyOnly: "true", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/Android.mk"}}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIR without their dependencies, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_A_DIRECTORY, false) testGetConfigArgs(t, tt, BUILD_MODULES) }) } } Loading @@ -971,7 +859,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"fake-module", "MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{}, }, { description: "build file in parent directory", dirsInTrees: []string{"0/1/2"}, Loading @@ -980,7 +867,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1"}, expectedEnvVars: []envVar{}, }, { description: "build file in parent directory, multiple module names passed in", Loading @@ -990,7 +876,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"fake-module1", "fake-module2", "fake-module3", "MODULES-IN-0-1"}, expectedEnvVars: []envVar{}, }, { description: "build file in 2nd level parent directory", dirsInTrees: []string{"0/1/2"}, Loading @@ -999,7 +884,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0"}, expectedEnvVars: []envVar{}, }, { description: "build action executed at root directory", dirsInTrees: []string{}, Loading @@ -1009,7 +893,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{}, }, { description: "build action executed at root directory in symlink", dirsInTrees: []string{}, Loading @@ -1019,7 +902,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{}, }, { description: "build file not found", dirsInTrees: []string{"0/1/2"}, Loading @@ -1028,7 +910,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{}, expectedErrStr: "Build file not found for 0/1/2 directory", }, { description: "GET-INSTALL-PATH specified,", Loading @@ -1038,7 +919,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"-j", "-k", "GET-INSTALL-PATH-IN-0-1"}, expectedEnvVars: []envVar{}, }, { description: "tidy only environment variable specified,", dirsInTrees: []string{"0/1/2"}, Loading @@ -1047,7 +927,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "true", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{}, }, { description: "normal execution in root directory with args", dirsInTrees: []string{}, Loading @@ -1056,69 +935,10 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "", tidyOnly: "", expectedArgs: []string{"-j", "-k", "fake_module"}, expectedEnvVars: []envVar{}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIR, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_A_DIRECTORY, true) }) } } // TODO: Remove this test case once mmm shell build command has been deprecated. func TestGetConfigArgsBuildModulesInDirectoriesNoDeps(t *testing.T) { tests := []buildActionTestCase{{ description: "normal execution in a directory", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"3.1/:t1,t2", "3.2/:t3,t4", "3.3/:t5,t6"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"t1", "t2", "t3", "t4", "t5", "t6"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }, { description: "GET-INSTALL-PATH specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"GET-INSTALL-PATH", "3.1/", "3.2/", "3.3/:t6"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"GET-INSTALL-PATH-IN-0-1-2-3.1", "GET-INSTALL-PATH-IN-0-1-2-3.2", "t6"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }, { description: "tidy only environment variable specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"GET-INSTALL-PATH", "3.1/", "3.2/", "3.3/:t6"}, curDir: "0/1/2", tidyOnly: "1", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }, { description: "normal execution from top dir directory", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"0/1/2/3.1", "0/1/2/3.2/:t3,t4", "0/1/2/3.3/:t5,t6"}, curDir: ".", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "t3", "t4", "t5", "t6"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIRS_NO_DEPS, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_DIRECTORIES, false) testGetConfigArgs(t, tt, BUILD_MODULES_IN_A_DIRECTORY) }) } } Loading @@ -1132,10 +952,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-2-3.3"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "GET-INSTALL-PATH specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3"}, Loading @@ -1144,10 +960,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: "0/1", tidyOnly: "", expectedArgs: []string{"GET-INSTALL-PATH-IN-0-1-2-3.1", "GET-INSTALL-PATH-IN-0-1-2-3.2", "GET-INSTALL-PATH-IN-0-1"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "tidy only environment variable specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, Loading @@ -1156,10 +968,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: "0/1/2", tidyOnly: "1", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "normal execution from top dir directory", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"}, Loading @@ -1169,10 +977,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-3", "MODULES-IN-0-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "normal execution from top dir directory in symlink", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"}, Loading @@ -1182,14 +986,10 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-3", "MODULES-IN-0-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIRS, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_DIRECTORIES, true) testGetConfigArgs(t, tt, BUILD_MODULES_IN_DIRECTORIES) }) } } ui/build/kati.go +0 −3 Original line number Diff line number Diff line Loading @@ -42,9 +42,6 @@ func genKatiSuffix(ctx Context, config Config) { if args := config.KatiArgs(); len(args) > 0 { katiSuffix += "-" + spaceSlashReplacer.Replace(strings.Join(args, "_")) } if oneShot, ok := config.Environment().Get("ONE_SHOT_MAKEFILE"); ok { katiSuffix += "-" + spaceSlashReplacer.Replace(oneShot) } // If the suffix is too long, replace it with a md5 hash and write a // file that contains the original suffix. Loading Loading
cmd/soong_ui/main.go +28 −40 Original line number Diff line number Diff line Loading @@ -334,39 +334,33 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config { name string description string action build.BuildAction buildDependencies bool set bool }{{ name: "all-modules", description: "Build action: build from the top of the source tree.", action: build.BUILD_MODULES, buildDependencies: true, }, { // buildDependencies is set to true as mm is being deprecated. This is redirecting to mma build // command behaviour. Once it has soaked for a while, the build command is deleted from here once // it has been removed from the envsetup.sh. // This is redirecting to mma build command behaviour. Once it has soaked for a // while, the build command is deleted from here once it has been removed from the // envsetup.sh. name: "modules-in-a-dir-no-deps", description: "Build action: builds all of the modules in the current directory without their dependencies.", action: build.BUILD_MODULES_IN_A_DIRECTORY, buildDependencies: true, }, { // buildDependencies is set to true as mmm is being deprecated. This is redirecting to mmma build // command behaviour. Once it has soaked for a while, the build command is deleted from here once // it has been removed from the envsetup.sh. // This is redirecting to mmma build command behaviour. Once it has soaked for a // while, the build command is deleted from here once it has been removed from the // envsetup.sh. name: "modules-in-dirs-no-deps", description: "Build action: builds all of the modules in the supplied directories without their dependencies.", action: build.BUILD_MODULES_IN_DIRECTORIES, buildDependencies: true, }, { name: "modules-in-a-dir", description: "Build action: builds all of the modules in the current directory and their dependencies.", action: build.BUILD_MODULES_IN_A_DIRECTORY, buildDependencies: true, }, { name: "modules-in-dirs", description: "Build action: builds all of the modules in the supplied directories and their dependencies.", action: build.BUILD_MODULES_IN_DIRECTORIES, buildDependencies: true, }} for i, flag := range buildActionFlags { flags.BoolVar(&buildActionFlags[i].set, flag.name, false, flag.description) Loading @@ -386,12 +380,10 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config { // is specified. buildActionCount := 0 var buildAction build.BuildAction buildDependency := false for _, flag := range buildActionFlags { if flag.set { buildActionCount++ buildAction = flag.action buildDependency = flag.buildDependencies } } if buildActionCount != 1 { Loading @@ -403,7 +395,7 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config { // Remove the build action flags from the args as they are not recognized by the config. args = args[numBuildActionFlags:] return build.NewBuildActionConfig(buildAction, *dir, buildDependency, ctx, args...) return build.NewBuildActionConfig(buildAction, *dir, ctx, args...) } func make(ctx build.Context, config build.Config, _ []string, logsDir string) { Loading @@ -425,17 +417,13 @@ func make(ctx build.Context, config build.Config, _ []string, logsDir string) { if _, ok := config.Environment().Get("ONE_SHOT_MAKEFILE"); ok { writer := ctx.Writer fmt.Fprintln(writer, "! The variable `ONE_SHOT_MAKEFILE` is deprecated, and will be removed shortly.") fmt.Fprintln(writer, "! The variable `ONE_SHOT_MAKEFILE` is obsolete.") fmt.Fprintln(writer, "!") fmt.Fprintln(writer, "! If you're using `mm`, you'll need to run `source build/envsetup.sh` to update.") fmt.Fprintln(writer, "!") fmt.Fprintln(writer, "! Otherwise, either specify a module name with m, or use mma / MODULES-IN-...") fmt.Fprintln(writer, "") select { case <-time.After(30 * time.Second): case <-ctx.Done(): return } ctx.Fatal("done") } toBuild := build.BuildAll Loading
ui/build/config.go +6 −18 Original line number Diff line number Diff line Loading @@ -253,13 +253,13 @@ func NewConfig(ctx Context, args ...string) Config { // NewBuildActionConfig returns a build configuration based on the build action. The arguments are // processed based on the build action and extracts any arguments that belongs to the build action. func NewBuildActionConfig(action BuildAction, dir string, buildDependencies bool, ctx Context, args ...string) Config { return NewConfig(ctx, getConfigArgs(action, dir, buildDependencies, ctx, args)...) func NewBuildActionConfig(action BuildAction, dir string, ctx Context, args ...string) Config { return NewConfig(ctx, getConfigArgs(action, dir, ctx, args)...) } // getConfigArgs processes the command arguments based on the build action and creates a set of new // arguments to be accepted by Config. func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx Context, args []string) []string { func getConfigArgs(action BuildAction, dir string, ctx Context, args []string) []string { // The next block of code verifies that the current directory is the root directory of the source // tree. It then finds the relative path of dir based on the root directory of the source tree // and verify that dir is inside of the source tree. Loading Loading @@ -295,7 +295,6 @@ func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx C configArgs = removeFromList("GET-INSTALL-PATH", configArgs) } var buildFiles []string var targets []string switch action { Loading @@ -312,20 +311,11 @@ func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx C if buildFile == "" { ctx.Fatalf("Build file not found for %s directory", relDir) } buildFiles = []string{buildFile} targets = []string{convertToTarget(filepath.Dir(buildFile), targetNamePrefix)} case BUILD_MODULES_IN_DIRECTORIES: newConfigArgs, dirs := splitArgs(configArgs) configArgs = newConfigArgs targets, buildFiles = getTargetsFromDirs(ctx, relDir, dirs, targetNamePrefix) } // This is to support building modules without building their dependencies. Soon, this will be // deprecated. if !buildDependencies && len(buildFiles) > 0 { if err := os.Setenv("ONE_SHOT_MAKEFILE", strings.Join(buildFiles, " ")); err != nil { ctx.Fatalf("Unable to set ONE_SHOT_MAKEFILE environment variable: %v", err) } targets = getTargetsFromDirs(ctx, relDir, dirs, targetNamePrefix) } // Tidy only override all other specified targets. Loading Loading @@ -435,7 +425,7 @@ func splitArgs(args []string) (newArgs []string, dirs []string) { // directory from the dirs list does not exist, a fatal error is raised. relDir is related to the // source root tree where the build action command was invoked. Each directory is validated if the // build file can be found and follows the format "dir1:target1,target2,...". Target is optional. func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePrefix string) (targets []string, buildFiles []string) { func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePrefix string) (targets []string) { for _, dir := range dirs { // The directory may have specified specific modules to build. ":" is the separator to separate // the directory and the list of modules. Loading Loading @@ -466,20 +456,18 @@ func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePre if !hasBuildFile(ctx, dir) { ctx.Fatalf("Couldn't locate a build file from %s directory", dir) } buildFiles = append(buildFiles, filepath.Join(dir, "Android.mk")) } else { buildFile := findBuildFile(ctx, dir) if buildFile == "" { ctx.Fatalf("Build file not found for %s directory", dir) } newTargets = []string{convertToTarget(filepath.Dir(buildFile), targetNamePrefix)} buildFiles = append(buildFiles, buildFile) } targets = append(targets, newTargets...) } return targets, buildFiles return targets } func (c *configImpl) parseArgs(ctx Context, args []string) { Loading
ui/build/config_test.go +155 −355 Original line number Diff line number Diff line Loading @@ -363,9 +363,6 @@ func TestConfigGetTargets(t *testing.T) { // Expected targets from the function. expectedTargets []string // Expected build from the build system. expectedBuildFiles []string // Expecting error from running test case. errStr string }{{ Loading @@ -375,7 +372,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3"}, curDir: "0", expectedTargets: []string{"MODULES-IN-0-1-2-3"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, build file does not exist", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -397,7 +393,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:"}, curDir: "0", expectedTargets: []string{"MODULES-IN-0-1-2-3"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, two targets specified", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -405,7 +400,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2"}, curDir: "0", expectedTargets: []string{"t1", "t2"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, no targets and has a comma", dirsInTrees: []string{"0/1/2/3"}, Loading Loading @@ -434,7 +428,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2,t3,t4,t5,t6,t7,t8,t9,t10"}, curDir: "0", expectedTargets: []string{"t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", "t10"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk"}, }, { description: "one target dir specified, one target specified, build file does not exist", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -456,7 +449,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3"}, curDir: "0", expectedTargets: []string{"MODULES-IN-0-1-2"}, expectedBuildFiles: []string{"0/1/2/Android.mk"}, }, { description: "multiple targets dir specified, targets specified", dirsInTrees: []string{"0/1/2/3", "0/3/4"}, Loading @@ -464,7 +456,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2", "3/4:t3,t4,t5"}, curDir: "0", expectedTargets: []string{"t1", "t2", "t3", "t4", "t5"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk", "0/3/4/Android.mk"}, }, { description: "multiple targets dir specified, one directory has targets specified", dirsInTrees: []string{"0/1/2/3", "0/3/4"}, Loading @@ -472,7 +463,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"1/2/3:t1,t2", "3/4"}, curDir: "0", expectedTargets: []string{"t1", "t2", "MODULES-IN-0-3-4"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk", "0/3/4/Android.mk"}, }, { description: "two dirs specified, only one dir exist", dirsInTrees: []string{"0/1/2/3"}, Loading @@ -487,7 +477,6 @@ func TestConfigGetTargets(t *testing.T) { dirs: []string{"0/1/2/3:t1,t2", "0/3/4"}, curDir: ".", expectedTargets: []string{"t1", "t2", "MODULES-IN-0-3-4"}, expectedBuildFiles: []string{"0/1/2/3/Android.mk", "0/3/4/Android.mk"}, }, { description: "no directories specified", dirsInTrees: []string{"0/1/2/3", "0/3/4"}, Loading Loading @@ -518,13 +507,10 @@ func TestConfigGetTargets(t *testing.T) { r := setTop(t, topDir) defer r() targets, buildFiles := getTargetsFromDirs(ctx, tt.curDir, tt.dirs, "MODULES-IN-") targets := getTargetsFromDirs(ctx, tt.curDir, tt.dirs, "MODULES-IN-") if !reflect.DeepEqual(targets, tt.expectedTargets) { t.Errorf("expected %v, got %v for targets", tt.expectedTargets, targets) } if !reflect.DeepEqual(buildFiles, tt.expectedBuildFiles) { t.Errorf("expected %v, got %v for build files", tt.expectedBuildFiles, buildFiles) } // If the execution reached here and there was an expected error code, the unit test case failed. if tt.errStr != "" { Loading Loading @@ -732,14 +718,11 @@ type buildActionTestCase struct { // Expected arguments to be in Config instance. expectedArgs []string // Expected environment variables to be set. expectedEnvVars []envVar // Expecting error from running test case. expectedErrStr string } func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction, buildDependencies bool) { func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction) { ctx := testContext() defer logger.Recover(func(err error) { Loading @@ -753,7 +736,6 @@ func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction, // Environment variables to set it to blank on every test case run. resetEnvVars := []string{ "ONE_SHOT_MAKEFILE", "WITH_TIDY_ONLY", } Loading Loading @@ -807,17 +789,11 @@ func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction, t.Fatalf("failed to create %s file: %v", srcDirFileCheck, err) } args := getConfigArgs(action, tt.curDir, buildDependencies, ctx, tt.args) args := getConfigArgs(action, tt.curDir, ctx, tt.args) if !reflect.DeepEqual(tt.expectedArgs, args) { t.Fatalf("expected %v, got %v for config arguments", tt.expectedArgs, args) } for _, env := range tt.expectedEnvVars { if val := os.Getenv(env.name); val != env.value { t.Errorf("expecting %s, got %s for environment variable %s", env.value, val, env.name) } } // If the execution reached here and there was an expected error code, the unit test case failed. if tt.expectedErrStr != "" { t.Errorf("expecting error %s", tt.expectedErrStr) Loading @@ -833,7 +809,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { 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"}, Loading @@ -842,7 +817,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { 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"}, Loading @@ -851,7 +825,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { 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"}, Loading @@ -860,7 +833,6 @@ func TestGetConfigArgsBuildModules(t *testing.T) { curDir: "0/2", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{}, }, { description: "normal execution in symlink root source tree, no args", dirsInTrees: []string{"0/1/2", "0/2", "0/3"}, Loading @@ -870,94 +842,10 @@ func TestGetConfigArgsBuildModules(t *testing.T) { curDir: "0/2", 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{{ description: "normal execution in a directory", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/2/Android.mk"}, args: []string{"-j", "-k", "showcommands", "fake-module"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"-j", "-k", "showcommands", "fake-module", "MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/Android.mk"}}, }, { description: "makefile in parent directory", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/Android.mk"}, args: []string{}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/Android.mk"}}, }, { description: "build file not found", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{}, args: []string{}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/Android.mk"}}, expectedErrStr: "Build file not found for 0/1/2 directory", }, { description: "build action executed at root directory", dirsInTrees: []string{}, buildFiles: []string{}, args: []string{}, curDir: ".", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "GET-INSTALL-PATH specified,", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/Android.mk"}, args: []string{"GET-INSTALL-PATH"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"GET-INSTALL-PATH-IN-0-1"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/Android.mk"}}, }, { description: "tidy only environment variable specified,", dirsInTrees: []string{"0/1/2"}, buildFiles: []string{"0/1/Android.mk"}, args: []string{"GET-INSTALL-PATH"}, curDir: "0/1/2", tidyOnly: "true", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/Android.mk"}}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIR without their dependencies, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_A_DIRECTORY, false) testGetConfigArgs(t, tt, BUILD_MODULES) }) } } Loading @@ -971,7 +859,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"fake-module", "MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{}, }, { description: "build file in parent directory", dirsInTrees: []string{"0/1/2"}, Loading @@ -980,7 +867,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1"}, expectedEnvVars: []envVar{}, }, { description: "build file in parent directory, multiple module names passed in", Loading @@ -990,7 +876,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"fake-module1", "fake-module2", "fake-module3", "MODULES-IN-0-1"}, expectedEnvVars: []envVar{}, }, { description: "build file in 2nd level parent directory", dirsInTrees: []string{"0/1/2"}, Loading @@ -999,7 +884,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0"}, expectedEnvVars: []envVar{}, }, { description: "build action executed at root directory", dirsInTrees: []string{}, Loading @@ -1009,7 +893,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{}, }, { description: "build action executed at root directory in symlink", dirsInTrees: []string{}, Loading @@ -1019,7 +902,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{}, expectedEnvVars: []envVar{}, }, { description: "build file not found", dirsInTrees: []string{"0/1/2"}, Loading @@ -1028,7 +910,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2"}, expectedEnvVars: []envVar{}, expectedErrStr: "Build file not found for 0/1/2 directory", }, { description: "GET-INSTALL-PATH specified,", Loading @@ -1038,7 +919,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"-j", "-k", "GET-INSTALL-PATH-IN-0-1"}, expectedEnvVars: []envVar{}, }, { description: "tidy only environment variable specified,", dirsInTrees: []string{"0/1/2"}, Loading @@ -1047,7 +927,6 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "0/1/2", tidyOnly: "true", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{}, }, { description: "normal execution in root directory with args", dirsInTrees: []string{}, Loading @@ -1056,69 +935,10 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) { curDir: "", tidyOnly: "", expectedArgs: []string{"-j", "-k", "fake_module"}, expectedEnvVars: []envVar{}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIR, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_A_DIRECTORY, true) }) } } // TODO: Remove this test case once mmm shell build command has been deprecated. func TestGetConfigArgsBuildModulesInDirectoriesNoDeps(t *testing.T) { tests := []buildActionTestCase{{ description: "normal execution in a directory", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"3.1/:t1,t2", "3.2/:t3,t4", "3.3/:t5,t6"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"t1", "t2", "t3", "t4", "t5", "t6"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }, { description: "GET-INSTALL-PATH specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"GET-INSTALL-PATH", "3.1/", "3.2/", "3.3/:t6"}, curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"GET-INSTALL-PATH-IN-0-1-2-3.1", "GET-INSTALL-PATH-IN-0-1-2-3.2", "t6"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }, { description: "tidy only environment variable specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"GET-INSTALL-PATH", "3.1/", "3.2/", "3.3/:t6"}, curDir: "0/1/2", tidyOnly: "1", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }, { description: "normal execution from top dir directory", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/2/3.3/Android.bp"}, args: []string{"0/1/2/3.1", "0/1/2/3.2/:t3,t4", "0/1/2/3.3/:t5,t6"}, curDir: ".", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "t3", "t4", "t5", "t6"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: "0/1/2/3.1/Android.mk 0/1/2/3.2/Android.mk 0/1/2/3.3/Android.mk"}}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIRS_NO_DEPS, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_DIRECTORIES, false) testGetConfigArgs(t, tt, BUILD_MODULES_IN_A_DIRECTORY) }) } } Loading @@ -1132,10 +952,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: "0/1/2", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-2-3.3"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "GET-INSTALL-PATH specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3"}, Loading @@ -1144,10 +960,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: "0/1", tidyOnly: "", expectedArgs: []string{"GET-INSTALL-PATH-IN-0-1-2-3.1", "GET-INSTALL-PATH-IN-0-1-2-3.2", "GET-INSTALL-PATH-IN-0-1"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "tidy only environment variable specified", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/2/3.3"}, Loading @@ -1156,10 +968,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: "0/1/2", tidyOnly: "1", expectedArgs: []string{"tidy_only"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "normal execution from top dir directory", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"}, Loading @@ -1169,10 +977,6 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-3", "MODULES-IN-0-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }, { description: "normal execution from top dir directory in symlink", dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"}, Loading @@ -1182,14 +986,10 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) { curDir: ".", tidyOnly: "", expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-3", "MODULES-IN-0-2"}, expectedEnvVars: []envVar{ envVar{ name: "ONE_SHOT_MAKEFILE", value: ""}}, }} for _, tt := range tests { t.Run("build action BUILD_MODULES_IN_DIRS, "+tt.description, func(t *testing.T) { testGetConfigArgs(t, tt, BUILD_MODULES_IN_DIRECTORIES, true) testGetConfigArgs(t, tt, BUILD_MODULES_IN_DIRECTORIES) }) } }
ui/build/kati.go +0 −3 Original line number Diff line number Diff line Loading @@ -42,9 +42,6 @@ func genKatiSuffix(ctx Context, config Config) { if args := config.KatiArgs(); len(args) > 0 { katiSuffix += "-" + spaceSlashReplacer.Replace(strings.Join(args, "_")) } if oneShot, ok := config.Environment().Get("ONE_SHOT_MAKEFILE"); ok { katiSuffix += "-" + spaceSlashReplacer.Replace(oneShot) } // If the suffix is too long, replace it with a md5 hash and write a // file that contains the original suffix. Loading