diff options
| -rw-r--r-- | android/Android.bp | 1 | ||||
| -rw-r--r-- | android/compliance_metadata.go | 37 | ||||
| -rw-r--r-- | android/config.go | 6 | ||||
| -rw-r--r-- | android/container.go | 4 | ||||
| -rw-r--r-- | android/nothing.go | 34 | ||||
| -rw-r--r-- | android/test_asserts.go | 17 | ||||
| -rw-r--r-- | android/util.go | 14 | ||||
| -rw-r--r-- | android/variable.go | 1 | ||||
| -rw-r--r-- | cc/cc.go | 5 | ||||
| -rw-r--r-- | cc/library.go | 12 | ||||
| -rw-r--r-- | filesystem/android_device.go | 18 | ||||
| -rw-r--r-- | filesystem/filesystem.go | 3 | ||||
| -rw-r--r-- | golang/golang_test.go | 2 | ||||
| -rw-r--r-- | java/aar.go | 5 | ||||
| -rw-r--r-- | java/app.go | 5 | ||||
| -rw-r--r-- | java/app_test.go | 70 | ||||
| -rw-r--r-- | java/builder.go | 2 | ||||
| -rw-r--r-- | java/config/config.go | 3 | ||||
| -rw-r--r-- | java/dex.go | 10 | ||||
| -rw-r--r-- | java/kotlin.go | 2 | ||||
| -rw-r--r-- | java/legacy_core_platform_api_usage.go | 3 | ||||
| -rw-r--r-- | java/lint.go | 2 | ||||
| -rw-r--r-- | java/robolectric.go | 37 | ||||
| -rw-r--r-- | java/robolectric_test.go | 5 | ||||
| -rw-r--r-- | ui/build/build.go | 11 | ||||
| -rw-r--r-- | ui/build/kati.go | 12 |
26 files changed, 243 insertions, 78 deletions
diff --git a/android/Android.bp b/android/Android.bp index bb16856dc..d27a8facf 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -79,6 +79,7 @@ bootstrap_go_package { "namespace.go", "neverallow.go", "ninja_deps.go", + "nothing.go", "notices.go", "onceper.go", "override_module.go", diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go index 0b876c3bf..2f11df6e0 100644 --- a/android/compliance_metadata.go +++ b/android/compliance_metadata.go @@ -236,8 +236,8 @@ var ( blueprint.RuleParams{ Command: `rm -rf $out && ` + `${sqlite3} $out ".import --csv $in modules" && ` + - `${sqlite3} $out ".import --csv ${make_metadata} make_metadata" && ` + - `${sqlite3} $out ".import --csv ${make_modules} make_modules"`, + `([ -z "${make_metadata}" ] || ${sqlite3} $out ".import --csv ${make_metadata} make_metadata") && ` + + `([ -z "${make_modules}" ] || ${sqlite3} $out ".import --csv ${make_modules} make_modules")`, CommandDeps: []string{"${sqlite3}"}, }, "make_metadata", "make_modules") ) @@ -307,24 +307,29 @@ func (c *complianceMetadataSingleton) GenerateBuildActions(ctx SingletonContext) modulesCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "soong-modules.csv") WriteFileRuleVerbatim(ctx, modulesCsv, buffer.String()) - // Metadata generated in Make - makeMetadataCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-metadata.csv") - makeModulesCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-modules.csv") + var implicits []Path + args := make(map[string]string) + + if ctx.Config().KatiEnabled() { + // Metadata generated in Make + makeMetadataCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-metadata.csv") + makeModulesCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-modules.csv") + implicits = append(implicits, makeMetadataCsv, makeModulesCsv) + args["make_metadata"] = makeMetadataCsv.String() + args["make_modules"] = makeModulesCsv.String() + } else { + args["make_metadata"] = "" + args["make_modules"] = "" + } // Import metadata from Make and Soong to sqlite3 database complianceMetadataDb := PathForOutput(ctx, "compliance-metadata", deviceProduct, "compliance-metadata.db") ctx.Build(pctx, BuildParams{ - Rule: importCsv, - Input: modulesCsv, - Implicits: []Path{ - makeMetadataCsv, - makeModulesCsv, - }, - Output: complianceMetadataDb, - Args: map[string]string{ - "make_metadata": makeMetadataCsv.String(), - "make_modules": makeModulesCsv.String(), - }, + Rule: importCsv, + Input: modulesCsv, + Implicits: implicits, + Output: complianceMetadataDb, + Args: args, }) // Phony rule "compliance-metadata.db". "m compliance-metadata.db" to create the compliance metadata database. diff --git a/android/config.go b/android/config.go index 00d5e2c6a..e9cb2cd31 100644 --- a/android/config.go +++ b/android/config.go @@ -768,11 +768,7 @@ func (c *config) SetAllowMissingDependencies() { // BlueprintToolLocation returns the directory containing build system tools // from Blueprint, like soong_zip and merge_zips. func (c *config) HostToolDir() string { - if c.KatiEnabled() { - return filepath.Join(c.outDir, "host", c.PrebuiltOS(), "bin") - } else { - return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin") - } + return filepath.Join(c.outDir, "host", c.PrebuiltOS(), "bin") } func (c *config) HostToolPath(ctx PathContext, tool string) Path { diff --git a/android/container.go b/android/container.go index 99e6a3075..830d474e9 100644 --- a/android/container.go +++ b/android/container.go @@ -198,9 +198,7 @@ var unstableInfoProvider = blueprint.NewProvider[unstableInfo]() func determineUnstableModule(mctx ModuleContext) bool { module := mctx.Module() - // TODO(b/383559945) Remove "framework-minus-apex_jarjar-sharded" once - // we remove this module. - unstableModule := module.Name() == "framework-minus-apex" || module.Name() == "framework-minus-apex_jarjar-sharded" + unstableModule := module.Name() == "framework-minus-apex" if installable, ok := module.(InstallableModule); ok { for _, staticDepTag := range installable.StaticDependencyTags() { mctx.VisitDirectDepsWithTag(staticDepTag, func(dep Module) { diff --git a/android/nothing.go b/android/nothing.go new file mode 100644 index 000000000..18bf85b28 --- /dev/null +++ b/android/nothing.go @@ -0,0 +1,34 @@ +// Copyright 2025 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package android + +func init() { + RegisterParallelSingletonType("nothing_singleton", nothingSingletonFactory) +} + +func nothingSingletonFactory() Singleton { + return ¬hingSingleton{} +} + +type nothingSingleton struct{} + +func (s *nothingSingleton) GenerateBuildActions(ctx SingletonContext) { + rule := NewRuleBuilder(pctx, ctx) + rule.SetPhonyOutput() + rule.Command(). + Text("echo Successfully read the makefiles."). + ImplicitOutput(PathForPhony(ctx, "nothing")) + rule.Build("nothing", "nothing") +} diff --git a/android/test_asserts.go b/android/test_asserts.go index c33ade5a2..22472c5c2 100644 --- a/android/test_asserts.go +++ b/android/test_asserts.go @@ -33,6 +33,23 @@ func AssertSame(t *testing.T, message string, expected interface{}, actual inter } } +// AssertSame checks if the expected and actual values are equal and if they are not then +// it reports an error prefixed with the supplied message and including a reason for why it failed. +func AssertSameArray[T comparable](t *testing.T, message string, expected []T, actual []T) { + t.Helper() + if len(actual) != len(expected) { + t.Errorf("%s: expected %d (%v), actual (%d) %v", message, len(expected), expected, len(actual), actual) + return + } + for i := range actual { + if actual[i] != expected[i] { + t.Errorf("%s: expected %d-th, %v (%v), actual %v (%v)", + message, i, expected[i], expected, actual[i], actual) + return + } + } +} + // AssertBoolEquals checks if the expected and actual values are equal and if they are not then it // reports an error prefixed with the supplied message and including a reason for why it failed. func AssertBoolEquals(t *testing.T, message string, expected bool, actual bool) { diff --git a/android/util.go b/android/util.go index 3fc4608e0..30d8ec6b3 100644 --- a/android/util.go +++ b/android/util.go @@ -308,6 +308,20 @@ func FilterList(list []string, filter []string) (remainder []string, filtered [] return } +// FilterListByPrefixes performs the same splitting as FilterList does, but treats the passed +// filters as prefixes +func FilterListByPrefix(list []string, filter []string) (remainder []string, filtered []string) { + for _, l := range list { + if HasAnyPrefix(l, filter) { + filtered = append(filtered, l) + } else { + remainder = append(remainder, l) + } + } + + return +} + // FilterListPred returns the elements of the given list for which the predicate // returns true. Order is kept. func FilterListPred(list []string, pred func(s string) bool) (filtered []string) { diff --git a/android/variable.go b/android/variable.go index ec842740f..6e46e9dab 100644 --- a/android/variable.go +++ b/android/variable.go @@ -162,6 +162,7 @@ type variableProperties struct { Optimize struct { Enabled *bool } + Aaptflags []string } Uml struct { @@ -92,6 +92,7 @@ type LinkerInfo struct { type BinaryDecoratorInfo struct{} type LibraryDecoratorInfo struct { ExportIncludeDirs proptools.Configurable[[]string] + InjectBsslHash bool } type LibraryInfo struct { @@ -2220,7 +2221,9 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { case *binaryDecorator: ccInfo.LinkerInfo.BinaryDecoratorInfo = &BinaryDecoratorInfo{} case *libraryDecorator: - ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{} + ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{ + InjectBsslHash: Bool(c.linker.(*libraryDecorator).Properties.Inject_bssl_hash), + } case *testBinary: ccInfo.LinkerInfo.TestBinaryInfo = &TestBinaryInfo{ Gtest: decorator.testDecorator.gtest(), diff --git a/cc/library.go b/cc/library.go index c9114fdd7..5c2cb5db2 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1195,7 +1195,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, library.linkSAbiDumpFiles(ctx, deps, objs, fileName, unstrippedOutputFile) var transitiveStaticLibrariesForOrdering depset.DepSet[android.Path] - if static := ctx.GetDirectDepsWithTag(staticVariantTag); len(static) > 0 { + if static := ctx.GetDirectDepsProxyWithTag(staticVariantTag); len(static) > 0 { s, _ := android.OtherModuleProvider(ctx, static[0], StaticLibraryInfoProvider) transitiveStaticLibrariesForOrdering = s.TransitiveStaticLibrariesForOrdering } @@ -2409,13 +2409,11 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu inject *bool, fileName string) android.ModuleOutPath { // TODO(b/137267623): Remove this in favor of a cc_genrule when they support operating on shared libraries. injectBoringSSLHash := Bool(inject) - ctx.VisitDirectDeps(func(dep android.Module) { + ctx.VisitDirectDepsProxy(func(dep android.ModuleProxy) { if tag, ok := ctx.OtherModuleDependencyTag(dep).(libraryDependencyTag); ok && tag.static() { - if cc, ok := dep.(*Module); ok { - if library, ok := cc.linker.(*libraryDecorator); ok { - if Bool(library.Properties.Inject_bssl_hash) { - injectBoringSSLHash = true - } + if ccInfo, ok := android.OtherModuleProvider(ctx, dep, CcInfoProvider); ok && ccInfo.LinkerInfo.LibraryDecoratorInfo != nil { + if ccInfo.LinkerInfo.LibraryDecoratorInfo.InjectBsslHash { + injectBoringSSLHash = true } } } diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 19e93ae8f..666aa6865 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -95,12 +95,22 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) { builder := android.NewRuleBuilder(pctx, ctx) builder.Command().Textf("rm -rf %s", targetFilesDir.String()) builder.Command().Textf("mkdir -p %s", targetFilesDir.String()) - if a.partitionProps.Vendor_partition_name != nil { - fsInfo := a.getFilesystemInfo(ctx, *a.partitionProps.Vendor_partition_name) - builder.Command().Textf("mkdir -p %s/VENDOR", targetFilesDir.String()) + partitionToSubdir := map[*string]string{ + a.partitionProps.System_partition_name: "SYSTEM", + a.partitionProps.System_ext_partition_name: "SYSTEM_EXT", + a.partitionProps.Product_partition_name: "PRODUCT", + a.partitionProps.Vendor_partition_name: "VENDOR", + a.partitionProps.Odm_partition_name: "ODM", + } + for partition, subdir := range partitionToSubdir { + if partition == nil { + continue + } + fsInfo := a.getFilesystemInfo(ctx, *partition) + builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), subdir) builder.Command(). BuiltTool("acp"). - Textf("-rd %s/. %s/VENDOR", fsInfo.RootDir, targetFilesDir). + Textf("-rd %s/. %s/%s", fsInfo.RootDir, targetFilesDir, subdir). Implicit(fsInfo.Output) // so that the staging dir is built } builder.Command(). diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 43fd390ce..6dfbfd1be 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -751,7 +751,10 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and } if timestamp := proptools.String(f.properties.Fake_timestamp); timestamp != "" { addStr("timestamp", timestamp) + } else if ctx.Config().Getenv("USE_FIXED_TIMESTAMP_IMG_FILES") == "true" { + addStr("use_fixed_timestamp", "true") } + if uuid := proptools.String(f.properties.Uuid); uuid != "" { addStr("uuid", uuid) addStr("hash_seed", uuid) diff --git a/golang/golang_test.go b/golang/golang_test.go index 0a4baedb4..d555d144c 100644 --- a/golang/golang_test.go +++ b/golang/golang_test.go @@ -47,7 +47,7 @@ func TestGolang(t *testing.T) { bin := result.ModuleForTests("gobin", result.Config.BuildOSTarget.String()) - expected := "^out/soong/host/" + result.Config.PrebuiltOS() + "/bin/go/gobin/?[^/]*/obj/gobin$" + expected := "^out/host/" + result.Config.PrebuiltOS() + "/bin/go/gobin/?[^/]*/obj/gobin$" actual := android.PathsRelativeToTop(bin.OutputFiles(result.TestContext, t, "")) if len(actual) != 1 { t.Fatalf("Expected 1 output file, got %v", actual) diff --git a/java/aar.go b/java/aar.go index 3c6244141..ed2fb7a66 100644 --- a/java/aar.go +++ b/java/aar.go @@ -391,8 +391,9 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte versionName = proptools.NinjaEscape(versionName) linkFlags = append(linkFlags, "--version-name ", versionName) } - - linkFlags, compileFlags = android.FilterList(linkFlags, []string{"--legacy"}) + // Split the flags by prefix, as --png-compression-level has the "=value" suffix. + linkFlags, compileFlags = android.FilterListByPrefix(linkFlags, + []string{"--legacy", "--png-compression-level"}) // Always set --pseudo-localize, it will be stripped out later for release // builds that don't want it. diff --git a/java/app.go b/java/app.go index b0dcbb003..a4e84e097 100644 --- a/java/app.go +++ b/java/app.go @@ -1565,6 +1565,9 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { } a.generateAndroidBuildActions(ctx) + for _, c := range a.testProperties.Test_options.Tradefed_options { + configs = append(configs, c) + } for _, module := range a.testProperties.Test_mainline_modules { configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module}) } @@ -1735,6 +1738,8 @@ func AndroidTestHelperAppFactory() android.Module { // TODO(b/192032291): Disable by default after auditing downstream usage. module.Module.dexProperties.Optimize.EnabledByDefault = true + module.Module.dexProperties.Optimize.Ignore_library_extends_program = proptools.BoolPtr(true) + module.Module.dexProperties.Optimize.Proguard_compatibility = proptools.BoolPtr(false) module.Module.properties.Installable = proptools.BoolPtr(true) module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true) diff --git a/java/app_test.go b/java/app_test.go index 4e915d2e9..bde801b32 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -18,6 +18,7 @@ import ( "fmt" "path/filepath" "reflect" + "regexp" "sort" "strings" "testing" @@ -4589,6 +4590,75 @@ func TestTestOnlyApp(t *testing.T) { assertTestOnlyAndTopLevel(t, ctx, expectedTestOnly, expectedTopLevel) } +func TestTestConfigTemplate(t *testing.T) { + t.Parallel() + ctx := android.GroupFixturePreparers( + prepareForJavaTest, + ).RunTestWithBp(t, ` + android_test { + name: "android-test", + test_config_template: "AndroidTestTemplate.xml", + test_options: { + tradefed_options: [ + { + name: "name1", + key: "key1", + value: "value1", + }, + { + name: "name2", + key: "key2", + value: "value2", + }, + ], + test_runner_options: [ + { + name: "name3", + key: "key3", + value: "value3", + }, + { + name: "name4", + key: "key4", + value: "value4", + }, + ], + }, + } + `) + type option struct { + name string + key string + value string + } + re := regexp.MustCompile(`<option name="(.*)" key="(.*)" value="(.*)" />`) + parse_options := func(optionsString string) []option { + lines := strings.Split(optionsString, `\n`) + var ret []option + for _, l := range lines { + sm := re.FindStringSubmatch(l) + if sm == nil { + continue + } + ret = append(ret, option{sm[1], sm[2], sm[3]}) + } + return ret + } + rule := ctx.ModuleForTests("android-test", "android_common").Rule("autogenInstrumentationTest") + android.AssertSameArray(t, "extraConfigs mismatch", + []option{ + {"name1", "key1", "value1"}, + {"name2", "key2", "value2"}, + }, + parse_options(rule.Args["extraConfigs"])) + android.AssertSameArray(t, "extraTestRunnerConfigs mismatch", + []option{ + {"name3", "key3", "value3"}, + {"name4", "key4", "value4"}, + }, + parse_options(rule.Args["extraTestRunnerConfigs"])) +} + func TestAppStem(t *testing.T) { ctx := testApp(t, ` android_app { diff --git a/java/builder.go b/java/builder.go index 88058e09a..8d4d6af8a 100644 --- a/java/builder.go +++ b/java/builder.go @@ -56,7 +56,7 @@ var ( `$zipTemplate${config.SoongZipCmd} -jar -o $out.tmp -C $outDir -D $outDir && ` + `if ! cmp -s "$out.tmp" "$out"; then mv "$out.tmp" "$out"; fi && ` + `if ! cmp -s "$annoSrcJar.tmp" "$annoSrcJar"; then mv "$annoSrcJar.tmp" "$annoSrcJar"; fi && ` + - `if [[ -f "$out.pc_state.new" ]]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` + + `if [ -f "$out.pc_state.new" ]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` + `rm -rf "$srcJarDir" "$outDir"`, CommandDeps: []string{ "${config.FindInputDeltaCmd}", diff --git a/java/config/config.go b/java/config/config.go index 19d695291..7c29722a2 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -42,9 +42,6 @@ var ( InstrumentFrameworkModules = []string{ "framework", "framework-minus-apex", - // TODO(b/383559945) Remove "framework-minus-apex_jarjar-sharded" once - // we remove this module. - "framework-minus-apex_jarjar-sharded", "ims-common", "telephony-common", "services", diff --git a/java/dex.go b/java/dex.go index 168a23114..7b99549d4 100644 --- a/java/dex.go +++ b/java/dex.go @@ -42,11 +42,15 @@ type DexProperties struct { // True if the module containing this has it set by default. EnabledByDefault bool `blueprint:"mutated"` + // Whether to allow that library classes inherit from program classes. + // Defaults to false. + Ignore_library_extends_program *bool + // Whether to continue building even if warnings are emitted. Defaults to true. Ignore_warnings *bool // If true, runs R8 in Proguard compatibility mode, otherwise runs R8 in full mode. - // Defaults to false for apps, true for libraries and tests. + // Defaults to false for apps and tests, true for libraries. Proguard_compatibility *bool // If true, optimize for size by removing unused code. Defaults to true for apps, @@ -356,6 +360,10 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams, r8Flags = append(r8Flags, opt.Proguard_flags...) + if BoolDefault(opt.Ignore_library_extends_program, false) { + r8Flags = append(r8Flags, "--ignore-library-extends-program") + } + if BoolDefault(opt.Proguard_compatibility, true) { r8Flags = append(r8Flags, "--force-proguard-compatibility") } diff --git a/java/kotlin.go b/java/kotlin.go index e1a3f71a3..308bb0305 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -198,7 +198,7 @@ var kaptStubs = pctx.AndroidRemoteStaticRule("kaptStubs", android.RemoteRuleSupp `$kaptProcessor ` + `-Xbuild-file=$kotlinBuildFile && ` + `${config.SoongZipCmd} -jar -write_if_changed -o $out -C $kaptDir/stubs -D $kaptDir/stubs && ` + - `if [[ -f "$out.pc_state.new" ]]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` + + `if [ -f "$out.pc_state.new" ]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` + `rm -rf "$srcJarDir"`, CommandDeps: []string{ "${config.FindInputDeltaCmd}", diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go index 6128ce3df..4be7d0470 100644 --- a/java/legacy_core_platform_api_usage.go +++ b/java/legacy_core_platform_api_usage.go @@ -28,9 +28,6 @@ var legacyCorePlatformApiModules = []string{ "FloralClocks", "framework-jobscheduler", "framework-minus-apex", - // TODO(b/383559945) Remove "framework-minus-apex_jarjar-sharded" once - // we remove this module. - "framework-minus-apex_jarjar-sharded", "framework-minus-apex-headers", "framework-minus-apex-intdefs", "FrameworksCoreTests", diff --git a/java/lint.go b/java/lint.go index ac90e19ba..9c6b93b45 100644 --- a/java/lint.go +++ b/java/lint.go @@ -470,7 +470,7 @@ func (l *linter) lint(ctx android.ModuleContext) { cmd := rule.Command() - cmd.Flag(`JAVA_OPTS="-Xmx3072m --add-opens java.base/java.util=ALL-UNNAMED"`). + cmd.Flag(`JAVA_OPTS="-Xmx4096m --add-opens java.base/java.util=ALL-UNNAMED"`). FlagWithArg("ANDROID_SDK_HOME=", lintPaths.homeDir.String()). FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath). FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXMLPath) diff --git a/java/robolectric.go b/java/robolectric.go index 3b2c65611..6c137ba47 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -20,7 +20,7 @@ import ( "android/soong/android" "android/soong/java/config" "android/soong/tradefed" - + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -28,6 +28,17 @@ func init() { RegisterRobolectricBuildComponents(android.InitRegistrationContext) } +type roboRuntimeOnlyDependencyTag struct { + blueprint.BaseDependencyTag +} + +var roboRuntimeOnlyDepTag roboRuntimeOnlyDependencyTag + +// Mark this tag so dependencies that use it are excluded from visibility enforcement. +func (t roboRuntimeOnlyDependencyTag) ExcludeFromVisibilityEnforcement() {} + +var _ android.ExcludeFromVisibilityEnforcementTag = roboRuntimeOnlyDepTag + func RegisterRobolectricBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("android_robolectric_test", RobolectricTestFactory) ctx.RegisterModuleType("android_robolectric_runtimes", robolectricRuntimesFactory) @@ -47,7 +58,6 @@ const robolectricPrebuiltLibPattern = "platform-robolectric-%s-prebuilt" var ( roboCoverageLibsTag = dependencyTag{name: "roboCoverageLibs"} roboRuntimesTag = dependencyTag{name: "roboRuntimes"} - roboRuntimeOnlyTag = dependencyTag{name: "roboRuntimeOnlyTag"} ) type robolectricProperties struct { @@ -65,10 +75,6 @@ type robolectricProperties struct { Shards *int64 } - // The version number of a robolectric prebuilt to use from prebuilts/misc/common/robolectric - // instead of the one built from source in external/robolectric-shadows. - Robolectric_prebuilt_version *string - // Use /external/robolectric rather than /external/robolectric-shadows as the version of robolectric // to use. /external/robolectric closely tracks github's master, and will fully replace /external/robolectric-shadows Upstream *bool @@ -98,6 +104,8 @@ func (r *robolectricTest) TestSuites() []string { var _ android.TestSuiteModule = (*robolectricTest)(nil) + + func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { r.Library.DepsMutator(ctx) @@ -107,21 +115,12 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { ctx.PropertyErrorf("instrumentation_for", "missing required instrumented module") } - ctx.AddVariationDependencies(nil, staticLibTag, clearcutJunitLib) - - if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" { - ctx.AddVariationDependencies(nil, staticLibTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v)) - } else if !proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { - if proptools.Bool(r.robolectricProperties.Upstream) { - ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib+"_upstream") - } else { - ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib) - } - } + ctx.AddVariationDependencies(nil, roboRuntimeOnlyDepTag, clearcutJunitLib) if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { - ctx.AddVariationDependencies(nil, roboRuntimeOnlyTag, robolectricCurrentLib+"_upstream") + ctx.AddVariationDependencies(nil, roboRuntimeOnlyDepTag, robolectricCurrentLib) } else { + ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib) // opting out from strict mode, robolectric_non_strict_mode_permission lib should be added ctx.AddVariationDependencies(nil, staticLibTag, "robolectric_non_strict_mode_permission") } @@ -197,7 +196,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) handleLibDeps(dep) } // handle the runtimeOnly tag for strict_mode - for _, dep := range ctx.GetDirectDepsWithTag(roboRuntimeOnlyTag) { + for _, dep := range ctx.GetDirectDepsWithTag(roboRuntimeOnlyDepTag) { handleLibDeps(dep) } diff --git a/java/robolectric_test.go b/java/robolectric_test.go index a2474e8d0..78326abee 100644 --- a/java/robolectric_test.go +++ b/java/robolectric_test.go @@ -32,6 +32,11 @@ var prepareRobolectricRuntime = android.GroupFixturePreparers( } java_library { + name: "Robolectric_all-target", + srcs: ["Robo.java"] + } + + java_library { name: "mockito-robolectric-prebuilt", srcs: ["Mockito.java"] } diff --git a/ui/build/build.go b/ui/build/build.go index 110ee9518..1dc6dbd8b 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -87,6 +87,17 @@ func SetupOutDir(ctx Context, config Config) { // without changing the command line every time. Avoids rebuilds // when using ninja. writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_number.txt", buildNumber) + + hostname, ok := config.environ.Get("BUILD_HOSTNAME") + if !ok { + var err error + hostname, err = os.Hostname() + if err != nil { + ctx.Println("Failed to read hostname:", err) + hostname = "unknown" + } + } + writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_hostname.txt", hostname) } var combinedBuildNinjaTemplate = template.Must(template.New("combined").Parse(` diff --git a/ui/build/kati.go b/ui/build/kati.go index 4dfb7108b..acd52546f 100644 --- a/ui/build/kati.go +++ b/ui/build/kati.go @@ -200,18 +200,10 @@ func runKati(ctx Context, config Config, extraSuffix string, args []string, envF // fi cmd.Environment.Unset("SOONG_USE_PARTIAL_COMPILE") - hostname, ok := cmd.Environment.Get("BUILD_HOSTNAME") // Unset BUILD_HOSTNAME during kati run to avoid kati rerun, kati will use BUILD_HOSTNAME from a file. cmd.Environment.Unset("BUILD_HOSTNAME") - if !ok { - hostname, err = os.Hostname() - if err != nil { - ctx.Println("Failed to read hostname:", err) - hostname = "unknown" - } - } - writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_hostname.txt", hostname) - _, ok = cmd.Environment.Get("BUILD_NUMBER") + + _, ok := cmd.Environment.Get("BUILD_NUMBER") // Unset BUILD_NUMBER during kati run to avoid kati rerun, kati will use BUILD_NUMBER from a file. cmd.Environment.Unset("BUILD_NUMBER") if ok { |