diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/dexpreopt_bootjars.go | 4 | ||||
| -rw-r--r-- | java/dexpreopt_config.go | 2 | ||||
| -rw-r--r-- | java/dexpreopt_test.go | 5 | ||||
| -rw-r--r-- | java/java_test.go | 10 | ||||
| -rw-r--r-- | java/kotlin_test.go | 7 | ||||
| -rw-r--r-- | java/plugin_test.go | 5 | ||||
| -rw-r--r-- | java/robolectric.go | 16 | ||||
| -rw-r--r-- | java/sdk_test.go | 14 |
8 files changed, 39 insertions, 24 deletions
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index dff9543e4..2c78d7362 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -523,14 +523,14 @@ func buildBootImageVariantsForAndroidOs(ctx android.ModuleContext, image *bootIm } // buildBootImageVariantsForBuildOs generates rules to build the boot image variants for the -// android.BuildOs OsType, i.e. the type of OS on which the build is being running. +// config.BuildOS OsType, i.e. the type of OS on which the build is being running. // // The files need to be generated into their predefined location because they are used from there // both within Soong and outside, e.g. for ART based host side testing and also for use by some // cloud based tools. However, they are not needed by callers of this function and so the paths do // not need to be returned from this func, unlike the buildBootImageVariantsForAndroidOs func. func buildBootImageVariantsForBuildOs(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) { - buildBootImageForOsType(ctx, image, profile, android.BuildOs) + buildBootImageForOsType(ctx, image, profile, ctx.Config().BuildOS) } // buildBootImageForOsType takes a bootImageConfig, a profile file and an android.OsType diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index b13955fba..1507aaf00 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -32,7 +32,7 @@ func dexpreoptTargets(ctx android.PathContext) []android.Target { } } // We may also need the images on host in order to run host-based tests. - for _, target := range ctx.Config().Targets[android.BuildOs] { + for _, target := range ctx.Config().Targets[ctx.Config().BuildOS] { targets = append(targets, target) } diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go index b25deceac..8dc7b798a 100644 --- a/java/dexpreopt_test.go +++ b/java/dexpreopt_test.go @@ -16,6 +16,7 @@ package java import ( "fmt" + "runtime" "testing" "android/soong/android" @@ -173,9 +174,9 @@ func enabledString(enabled bool) string { } func TestDex2oatToolDeps(t *testing.T) { - if android.BuildOs != android.Linux { + if runtime.GOOS != "linux" { // The host binary paths checked below are build OS dependent. - t.Skipf("Unsupported build OS %s", android.BuildOs) + t.Skipf("Unsupported build OS %s", runtime.GOOS) } preparers := android.GroupFixturePreparers( diff --git a/java/java_test.go b/java/java_test.go index 0f9965d03..b6780c20c 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -441,7 +441,7 @@ func TestBinary(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() bar := ctx.ModuleForTests("bar", buildOS+"_common") barJar := bar.Output("bar.jar").Output.String() @@ -478,7 +478,7 @@ func TestTest(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() foo := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost) @@ -523,7 +523,7 @@ func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) { } // check that -g is not overridden for host modules - buildOS := android.BuildOs.String() + buildOS := result.Config.BuildOS.String() hostBinary := result.ModuleForTests("host_binary", buildOS+"_common") hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"] if strings.Contains(hostJavaFlags, "-g:source,lines") { @@ -1371,7 +1371,7 @@ func TestDataNativeBinaries(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() test := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost) entries := android.AndroidMkEntriesForTest(t, ctx, test)[0] @@ -1387,7 +1387,7 @@ func TestDefaultInstallable(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() module := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost) assertDeepEquals(t, "Default installable value should be true.", proptools.BoolPtr(true), module.properties.Installable) diff --git a/java/kotlin_test.go b/java/kotlin_test.go index fd2f3ca61..db3069693 100644 --- a/java/kotlin_test.go +++ b/java/kotlin_test.go @@ -15,10 +15,11 @@ package java import ( - "android/soong/android" "strconv" "strings" "testing" + + "android/soong/android" ) func TestKotlin(t *testing.T) { @@ -114,7 +115,7 @@ func TestKapt(t *testing.T) { t.Run("", func(t *testing.T) { ctx, _ := testJava(t, bp) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() kapt := ctx.ModuleForTests("foo", "android_common").Rule("kapt") kotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc") @@ -182,7 +183,7 @@ func TestKapt(t *testing.T) { android.FixtureMergeEnv(env), ).RunTestWithBp(t, bp) - buildOS := android.BuildOs.String() + buildOS := result.Config.BuildOS.String() kapt := result.ModuleForTests("foo", "android_common").Rule("kapt") javac := result.ModuleForTests("foo", "android_common").Description("javac") diff --git a/java/plugin_test.go b/java/plugin_test.go index c7913d3db..dc29b1c3e 100644 --- a/java/plugin_test.go +++ b/java/plugin_test.go @@ -15,7 +15,6 @@ package java import ( - "android/soong/android" "testing" ) @@ -58,7 +57,7 @@ func TestPlugin(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() javac := ctx.ModuleForTests("foo", "android_common").Rule("javac") turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine") @@ -98,7 +97,7 @@ func TestPluginGeneratesApi(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() javac := ctx.ModuleForTests("foo", "android_common").Rule("javac") turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine") diff --git a/java/robolectric.go b/java/robolectric.go index a37a118f6..a0c9c7fcd 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -83,6 +83,9 @@ type robolectricTest struct { testConfig android.Path data android.Paths + + forceOSType android.OsType + forceArchType android.ArchType } func (r *robolectricTest) TestSuites() []string { @@ -115,6 +118,9 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { } func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { + r.forceOSType = ctx.Config().BuildOS + r.forceArchType = ctx.Config().BuildArch + r.testConfig = tradefed.AutoGenRobolectricTestConfig(ctx, r.testProperties.Test_config, r.testProperties.Test_config_template, r.testProperties.Test_suites, r.testProperties.Auto_gen_config) @@ -345,7 +351,7 @@ func RobolectricTestFactory() android.Module { func (r *robolectricTest) InstallBypassMake() bool { return true } func (r *robolectricTest) InstallInTestcases() bool { return true } func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) { - return &android.BuildOs, &android.BuildArch + return &r.forceOSType, &r.forceArchType } func robolectricRuntimesFactory() android.Module { @@ -366,6 +372,9 @@ type robolectricRuntimes struct { props robolectricRuntimesProperties runtimes []android.InstallPath + + forceOSType android.OsType + forceArchType android.ArchType } func (r *robolectricRuntimes) TestSuites() []string { @@ -385,6 +394,9 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont return } + r.forceOSType = ctx.Config().BuildOS + r.forceArchType = ctx.Config().BuildArch + files := android.PathsForModuleSrc(ctx, r.props.Jars) androidAllDir := android.PathForModuleInstall(ctx, "android-all") @@ -417,5 +429,5 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont func (r *robolectricRuntimes) InstallBypassMake() bool { return true } func (r *robolectricRuntimes) InstallInTestcases() bool { return true } func (r *robolectricRuntimes) InstallForceOS() (*android.OsType, *android.ArchType) { - return &android.BuildOs, &android.BuildArch + return &r.forceOSType, &r.forceArchType } diff --git a/java/sdk_test.go b/java/sdk_test.go index bb595a54e..6d6213011 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -255,9 +255,11 @@ func TestClasspath(t *testing.T) { ` + testcase.properties + ` }` - variant := "android_common" - if testcase.host == android.Host { - variant = android.BuildOs.String() + "_common" + variant := func(result *android.TestResult) string { + if testcase.host == android.Host { + return result.Config.BuildOS.String() + "_common" + } + return "android_common" } convertModulesToPaths := func(cp []string) []string { @@ -312,7 +314,7 @@ func TestClasspath(t *testing.T) { } checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) { - foo := result.ModuleForTests("foo", variant) + foo := result.ModuleForTests("foo", variant(result)) javac := foo.Rule("javac") var deps []string @@ -376,7 +378,7 @@ func TestClasspath(t *testing.T) { checkClasspath(t, result, true /* isJava8 */) if testcase.host != android.Host { - aidl := result.ModuleForTests("foo", variant).Rule("aidl") + aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl") android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.") } @@ -389,7 +391,7 @@ func TestClasspath(t *testing.T) { checkClasspath(t, result, false /* isJava8 */) if testcase.host != android.Host { - aidl := result.ModuleForTests("foo", variant).Rule("aidl") + aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl") android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.") } |