diff options
-rw-r--r-- | android/arch.go | 5 | ||||
-rw-r--r-- | android/module.go | 10 | ||||
-rw-r--r-- | android/mutator.go | 18 | ||||
-rw-r--r-- | apex/vndk.go | 10 | ||||
-rw-r--r-- | cc/check.go | 2 | ||||
-rw-r--r-- | cc/compiler.go | 20 | ||||
-rw-r--r-- | cmd/soong_build/main.go | 1 | ||||
-rw-r--r-- | java/fuzz.go | 7 | ||||
-rw-r--r-- | java/java.go | 7 | ||||
-rw-r--r-- | java/java_test.go | 34 | ||||
-rw-r--r-- | rust/bindgen.go | 20 |
11 files changed, 108 insertions, 26 deletions
diff --git a/android/arch.go b/android/arch.go index d9ecb508d..1ec971d15 100644 --- a/android/arch.go +++ b/android/arch.go @@ -142,7 +142,10 @@ func (a ArchType) Bitness() string { if a.Multilib == "lib32" { return "32" } - return "64" + if a.Multilib == "lib64" { + return "64" + } + panic("Bitness is not defined for the common variant") } const COMMON_VARIANT = "common" diff --git a/android/module.go b/android/module.go index 1866d7a9d..20caae2d8 100644 --- a/android/module.go +++ b/android/module.go @@ -1005,6 +1005,14 @@ func addRequiredDeps(ctx BottomUpMutatorContext) { return } + // Do not create a dependency from common variant to arch variant for `common_first` modules + if multilib, _ := decodeMultilib(ctx, ctx.Module().base()); multilib == string(MultilibCommonFirst) { + commonVariant := ctx.Arch().ArchType.Multilib == "" + if bothInAndroid && commonVariant && InList(target.Arch.ArchType.Multilib, []string{"lib32", "lib64"}) { + return + } + } + variation := target.Variations() if ctx.OtherModuleFarDependencyVariantExists(variation, depName) { ctx.AddFarVariationDependencies(variation, RequiredDepTag, depName) @@ -2288,6 +2296,8 @@ func (e configurationEvalutor) EvaluateConfiguration(condition proptools.Configu } variable := condition.Arg(0) switch variable { + case "build_from_text_stub": + return proptools.ConfigurableValueBool(ctx.Config().BuildFromTextStub()) case "debuggable": return proptools.ConfigurableValueBool(ctx.Config().Debuggable()) case "use_debug_art": diff --git a/android/mutator.go b/android/mutator.go index 434e3ba56..a8b5c7db6 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -242,6 +242,16 @@ type BottomUpMutatorContext interface { // be ordered correctly for all future mutator passes. AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module + // AddReverseVariationDependencies adds a dependency from the named module to the current + // module. The given variations will be added to the current module's varations, and then the + // result will be used to find the correct variation of the depending module, which must exist. + // + // Does not affect the ordering of the current mutator pass, but will be ordered + // correctly for all future mutator passes. All reverse dependencies for a destination module are + // collected until the end of the mutator pass, sorted by name, and then appended to the destination + // module's dependency list. + AddReverseVariationDependency([]blueprint.Variation, blueprint.DependencyTag, string) + // AddFarVariationDependencies adds deps as dependencies of the current module, but uses the // variations argument to select which variant of the dependency to use. It returns a slice of // modules for each dependency (some entries may be nil). A variant of the dependency must @@ -703,6 +713,14 @@ func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, t } b.bp.AddReverseDependency(module, tag, name) } + +func (b *bottomUpMutatorContext) AddReverseVariationDependency(variations []blueprint.Variation, tag blueprint.DependencyTag, name string) { + if b.baseModuleContext.checkedMissingDeps() { + panic("Adding deps not allowed after checking for missing deps") + } + b.bp.AddReverseVariationDependency(variations, tag, name) +} + func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module { if b.baseModuleContext.checkedMissingDeps() { diff --git a/apex/vndk.go b/apex/vndk.go index 3ececc5c1..5e630c0c0 100644 --- a/apex/vndk.go +++ b/apex/vndk.go @@ -20,6 +20,7 @@ import ( "android/soong/android" "android/soong/cc" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -66,7 +67,14 @@ func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) { vndkApexName := "com.android.vndk." + vndkVersion if mctx.OtherModuleExists(vndkApexName) { - mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApexName) + // Reverse dependencies must exactly specify the variant they want, starting from the + // current module's variant. But unlike cc modules, the vndk apex doesn't have + // arch/image/link variations, so we explicitly remove them here. + mctx.AddReverseVariationDependency([]blueprint.Variation{ + {Mutator: "arch", Variation: "common"}, + {Mutator: "image", Variation: ""}, + {Mutator: "link", Variation: ""}, + }, sharedLibTag, vndkApexName) } } else if a, ok := mctx.Module().(*apexBundle); ok && a.vndkApex { if a.IsNativeBridgeSupported() { diff --git a/cc/check.go b/cc/check.go index fa1926dd4..8e2844f16 100644 --- a/cc/check.go +++ b/cc/check.go @@ -40,6 +40,8 @@ func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) { ctx.PropertyErrorf(prop, "Bad flag: `%s`, use native_coverage instead", flag) } else if flag == "-fwhole-program-vtables" { ctx.PropertyErrorf(prop, "Bad flag: `%s`, use whole_program_vtables instead", flag) + } else if flag == "-gsplit-dwarf" { + ctx.PropertyErrorf(prop, "Bad flag: `%s`, soong cannot track dependencies to split dwarf debuginfo", flag) } else if flag == "-fno-integrated-as" { ctx.PropertyErrorf("Bad flag: `%s` is disallowed as it may invoke the `as` from the build host", flag) } else if flag == "-Weverything" { diff --git a/cc/compiler.go b/cc/compiler.go index 396ec886b..a6f623f5b 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -437,18 +437,20 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__") if ctx.inVendor() { flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__") - - vendorApiLevel := ctx.Config().VendorApiLevel() - if vendorApiLevel == "" { - // TODO(b/314036847): This is a fallback for UDC targets. - // This must be a build failure when UDC is no longer built - // from this source tree. - vendorApiLevel = ctx.Config().PlatformSdkVersion().String() - } - flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel) } else if ctx.inProduct() { flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_PRODUCT__") } + + // Define __ANDROID_VENDOR_API__ for both product and vendor variants + // because they both use the same LLNDK libraries. + vendorApiLevel := ctx.Config().VendorApiLevel() + if vendorApiLevel == "" { + // TODO(b/314036847): This is a fallback for UDC targets. + // This must be a build failure when UDC is no longer built + // from this source tree. + vendorApiLevel = ctx.Config().PlatformSdkVersion().String() + } + flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel) } if ctx.inRecovery() { diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 577c6cc74..5b1ae5406 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -375,6 +375,7 @@ func main() { ctx.Register() finalOutputFile, ninjaDeps := runSoongOnlyBuild(ctx) + ninjaDeps = append(ninjaDeps, configuration.ProductVariablesFileName) ninjaDeps = append(ninjaDeps, usedEnvFile) if shared.IsDebugging() { // Add a non-existent file to the dependencies so that soong_build will rerun when the debugger is diff --git a/java/fuzz.go b/java/fuzz.go index d37c55804..e5f1f04ee 100644 --- a/java/fuzz.go +++ b/java/fuzz.go @@ -85,10 +85,11 @@ func JavaFuzzFactory() android.Module { func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) { if j.Os().Class.String() == deviceString { - j.testProperties.Jni_libs = append(j.testProperties.Jni_libs, artDeps...) + j.testProperties.Jni_libs.AppendSimpleValue(artDeps) } - if len(j.testProperties.Jni_libs) > 0 { + jniLibs := j.testProperties.Jni_libs.GetOrDefault(ctx, nil) + if len(jniLibs) > 0 { if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil { config := &fuzz.FuzzConfig{} j.fuzzPackagedModule.FuzzProperties.Fuzz_config = config @@ -98,7 +99,7 @@ func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) { j.fuzzPackagedModule.FuzzProperties.Fuzz_config.IsJni = proptools.BoolPtr(true) for _, target := range ctx.MultiTargets() { sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) - ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...) + ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, jniLibs...) } } diff --git a/java/java.go b/java/java.go index 92dcc6322..661422b54 100644 --- a/java/java.go +++ b/java/java.go @@ -1301,7 +1301,7 @@ type testProperties struct { Test_options TestOptions // Names of modules containing JNI libraries that should be installed alongside the test. - Jni_libs []string + Jni_libs proptools.Configurable[[]string] // Install the test into a folder named for the module in all test suites. Per_testcase_directory *bool @@ -1485,10 +1485,11 @@ func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if len(j.testProperties.Jni_libs) > 0 { + jniLibs := j.testProperties.Jni_libs.GetOrDefault(ctx, nil) + if len(jniLibs) > 0 { for _, target := range ctx.MultiTargets() { sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) - ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...) + ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, jniLibs...) } } diff --git a/java/java_test.go b/java/java_test.go index 641bf4030..e976b081e 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -3132,3 +3132,37 @@ func assertTestOnlyAndTopLevel(t *testing.T, ctx *android.TestResult, expectedTe t.Errorf("top-level: Expected but not found: %v, Found but not expected: %v", left, right) } } + +// Test that a dependency edge is created to the "first" variant of a native library listed in `required` of java_binary +func TestNativeRequiredDepOfJavaBinary(t *testing.T) { + findDepsOfModule := func(ctx *android.TestContext, module android.Module, depName string) []blueprint.Module { + var ret []blueprint.Module + ctx.VisitDirectDeps(module, func(dep blueprint.Module) { + if dep.Name() == depName { + ret = append(ret, dep) + } + }) + return ret + } + + bp := cc.GatherRequiredDepsForTest(android.Android) + ` +java_binary { + name: "myjavabin", + main_class: "com.android.MyJava", + required: ["mynativelib"], +} +cc_library_shared { + name: "mynativelib", +} +` + res, _ := testJava(t, bp) + // The first variant installs the native library via the common variant, so check the deps of both variants. + nativeVariantDepsWithDups := findDepsOfModule(res, res.ModuleForTests("myjavabin", "android_arm64_armv8-a").Module(), "mynativelib") + nativeVariantDepsWithDups = append(nativeVariantDepsWithDups, findDepsOfModule(res, res.ModuleForTests("myjavabin", "android_common").Module(), "mynativelib")...) + + nativeVariantDepsUnique := map[blueprint.Module]bool{} + for _, dep := range nativeVariantDepsWithDups { + nativeVariantDepsUnique[dep] = true + } + android.AssertIntEquals(t, "Create a dep on the first variant", 1, len(nativeVariantDepsUnique)) +} diff --git a/rust/bindgen.go b/rust/bindgen.go index 31aa13725..abb51814e 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -198,18 +198,20 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr cflags = append(cflags, "-D__ANDROID_VNDK__") if ctx.RustModule().InVendor() { cflags = append(cflags, "-D__ANDROID_VENDOR__") - - vendorApiLevel := ctx.Config().VendorApiLevel() - if vendorApiLevel == "" { - // TODO(b/314036847): This is a fallback for UDC targets. - // This must be a build failure when UDC is no longer built - // from this source tree. - vendorApiLevel = ctx.Config().PlatformSdkVersion().String() - } - cflags = append(cflags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel) } else if ctx.RustModule().InProduct() { cflags = append(cflags, "-D__ANDROID_PRODUCT__") } + + // Define __ANDROID_VENDOR_API__ for both product and vendor variants + // because they both use the same LLNDK libraries. + vendorApiLevel := ctx.Config().VendorApiLevel() + if vendorApiLevel == "" { + // TODO(b/314036847): This is a fallback for UDC targets. + // This must be a build failure when UDC is no longer built + // from this source tree. + vendorApiLevel = ctx.Config().PlatformSdkVersion().String() + } + cflags = append(cflags, "-D__ANDROID_VENDOR_API__="+vendorApiLevel) } if ctx.RustModule().InRecovery() { |