Merge "Propagate profile_guided requirement of imports to top-level apex" into main
diff --git a/android/config.go b/android/config.go
index eb1e647..d94a86f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1309,6 +1309,10 @@
return String(c.productVariables.VendorApiLevel)
}
+func (c *config) VendorApiLevelFrozen() bool {
+ return c.productVariables.GetBuildFlagBool("RELEASE_BOARD_API_LEVEL_FROZEN")
+}
+
func (c *deviceConfig) Arches() []Arch {
var arches []Arch
for _, target := range c.config.Targets[Android] {
@@ -1970,6 +1974,10 @@
return val, ok
}
+func (c *config) UseResourceProcessorByDefault() bool {
+ return c.productVariables.GetBuildFlagBool("RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT")
+}
+
var (
mainlineApexContributionBuildFlags = []string{
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES",
diff --git a/android/defaults_test.go b/android/defaults_test.go
index a7542ab..0ad0fb8 100644
--- a/android/defaults_test.go
+++ b/android/defaults_test.go
@@ -16,10 +16,13 @@
import (
"testing"
+
+ "github.com/google/blueprint"
)
type defaultsTestProperties struct {
- Foo []string
+ Foo []string
+ Path_prop []string `android:"path"`
}
type defaultsTestModule struct {
@@ -130,3 +133,40 @@
// TODO: missing transitive defaults is currently not handled
_ = missingTransitiveDefaults
}
+
+func TestDefaultsPathProperties(t *testing.T) {
+ bp := `
+ defaults {
+ name: "defaults",
+ path_prop: [":gen"],
+ }
+
+ test {
+ name: "foo",
+ defaults: ["defaults"],
+ }
+
+ test {
+ name: "gen",
+ }
+ `
+
+ result := GroupFixturePreparers(
+ prepareForDefaultsTest,
+ FixtureWithRootAndroidBp(bp),
+ ).RunTest(t)
+
+ collectDeps := func(m Module) []string {
+ var deps []string
+ result.VisitDirectDeps(m, func(dep blueprint.Module) {
+ deps = append(deps, result.ModuleName(dep))
+ })
+ return deps
+ }
+
+ foo := result.Module("foo", "")
+ defaults := result.Module("defaults", "")
+
+ AssertStringListContains(t, "foo should depend on gen", collectDeps(foo), "gen")
+ AssertStringListDoesNotContain(t, "defaults should not depend on gen", collectDeps(defaults), "gen")
+}
diff --git a/android/path_properties.go b/android/path_properties.go
index fdc4d91..bbfaa8c 100644
--- a/android/path_properties.go
+++ b/android/path_properties.go
@@ -33,6 +33,11 @@
// The pathDepsMutator automatically adds dependencies on any module that is listed with the
// ":module" module reference syntax in a property that is tagged with `android:"path"`.
func pathDepsMutator(ctx BottomUpMutatorContext) {
+ if _, ok := ctx.Module().(DefaultsModule); ok {
+ // Defaults modules shouldn't have dependencies added for path properties, they have already been
+ // squashed into the real modules.
+ return
+ }
props := ctx.Module().base().GetProperties()
addPathDepsForProps(ctx, props)
}
diff --git a/android/team_proto/Android.bp b/android/team_proto/Android.bp
index 061e77e..7e2a4c1 100644
--- a/android/team_proto/Android.bp
+++ b/android/team_proto/Android.bp
@@ -27,3 +27,17 @@
"team.pb.go",
],
}
+
+python_library_host {
+ name: "teams-proto-py",
+ pkg_path: "teams",
+ srcs: [
+ "team.proto",
+ ],
+ libs: [
+ "libprotobuf-python",
+ ],
+ proto: {
+ canonical_path_from_root: false,
+ },
+}
diff --git a/apex/apex.go b/apex/apex.go
index b069efd..276ac80 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1412,7 +1412,7 @@
var _ cc.Coverage = (*apexBundle)(nil)
// Implements cc.Coverage
-func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
+func (a *apexBundle) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
return ctx.DeviceConfig().NativeCoverageEnabled()
}
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 161941d..2bd3159 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -155,7 +155,7 @@
info, _ := android.SingletonModuleProvider(result, pbcp, java.MonolithicHiddenAPIInfoProvider)
for _, category := range java.HiddenAPIFlagFileCategories {
- name := category.PropertyName
+ name := category.PropertyName()
message := fmt.Sprintf("category %s", name)
filename := strings.ReplaceAll(name, "_", "-")
expected := []string{fmt.Sprintf("%s.txt", filename), fmt.Sprintf("bar-%s.txt", filename)}
diff --git a/cc/androidmk.go b/cc/androidmk.go
index fe542b0..c39668c 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -83,8 +83,9 @@
// causing multiple ART APEXes (com.android.art and com.android.art.debug)
// to be installed. And this is breaking some older devices (like marlin)
// where system.img is small.
- Required: c.Properties.AndroidMkRuntimeLibs,
- Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
+ Required: c.Properties.AndroidMkRuntimeLibs,
+ OverrideName: c.BaseModuleName(),
+ Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
diff --git a/cc/cc.go b/cc/cc.go
index c07e358..449d38f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -68,16 +68,14 @@
ctx.TopDown("fuzz_deps", fuzzMutatorDeps)
- ctx.BottomUp("coverage", coverageMutator).Parallel()
+ ctx.Transition("coverage", &coverageTransitionMutator{})
ctx.TopDown("afdo_deps", afdoDepsMutator)
ctx.BottomUp("afdo", afdoMutator).Parallel()
- ctx.TopDown("orderfile_deps", orderfileDepsMutator)
- ctx.BottomUp("orderfile", orderfileMutator).Parallel()
+ ctx.Transition("orderfile", &orderfileTransitionMutator{})
- ctx.TopDown("lto_deps", ltoDepsMutator)
- ctx.BottomUp("lto", ltoMutator).Parallel()
+ ctx.Transition("lto", <oTransitionMutator{})
ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel()
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
@@ -1608,9 +1606,10 @@
func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() {
- if ctx.useVndk() {
+ config := ctx.ctx.Config()
+ if !config.IsVndkDeprecated() && ctx.useVndk() {
vndkVer := ctx.mod.VndkVersion()
- if inList(vndkVer, ctx.ctx.Config().PlatformVersionActiveCodenames()) {
+ if inList(vndkVer, config.PlatformVersionActiveCodenames()) {
return "current"
}
return vndkVer
@@ -1628,6 +1627,17 @@
if ver == "apex_inherit" || ver == "" {
ver = ctx.sdkVersion()
}
+
+ if ctx.ctx.Device() {
+ config := ctx.ctx.Config()
+ if config.IsVndkDeprecated() && ctx.inVendor() {
+ // If building for vendor with final API, then use the latest _stable_ API as "current".
+ if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
+ ver = config.PlatformSdkVersion().String()
+ }
+ }
+ }
+
// For crt objects, the meaning of min_sdk_version is very different from other types of
// module. For them, min_sdk_version defines the oldest version that the build system will
// create versioned variants for. For example, if min_sdk_version is 16, then sdk variant of
@@ -1744,7 +1754,7 @@
}
func (ctx *moduleContextImpl) baseModuleName() string {
- return ctx.mod.ModuleBase.BaseModuleName()
+ return ctx.mod.BaseModuleName()
}
func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
@@ -4173,6 +4183,18 @@
return ""
}
+type sourceModuleName interface {
+ sourceModuleName() string
+}
+
+func (c *Module) BaseModuleName() string {
+ if smn, ok := c.linker.(sourceModuleName); ok && smn.sourceModuleName() != "" {
+ // if the prebuilt module sets a source_module_name in Android.bp, use that
+ return smn.sourceModuleName()
+ }
+ return c.ModuleBase.BaseModuleName()
+}
+
var Bool = proptools.Bool
var BoolDefault = proptools.BoolDefault
var BoolPtr = proptools.BoolPtr
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 321bd38..6cc500b 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -43,6 +43,7 @@
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.VendorApiLevel = StringPtr("202404")
variables.DeviceVndkVersion = StringPtr("current")
+ variables.KeepVndk = BoolPtr(true)
variables.Platform_vndk_version = StringPtr("29")
}),
)
@@ -4843,3 +4844,43 @@
testDepWithVariant("vendor")
testDepWithVariant("product")
}
+
+func TestVendorSdkVersionWithoutVndk(t *testing.T) {
+ t.Parallel()
+
+ bp := `
+ cc_library {
+ name: "libfoo",
+ srcs: ["libfoo.cc"],
+ vendor_available: true,
+ }
+
+ cc_library {
+ name: "libbar",
+ srcs: ["libbar.cc"],
+ vendor_available: true,
+ min_sdk_version: "29",
+ }
+ `
+
+ ctx := prepareForCcTestWithoutVndk.RunTestWithBp(t, bp)
+ testSdkVersionFlag := func(module, version string) {
+ flags := ctx.ModuleForTests(module, "android_vendor_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
+ android.AssertStringDoesContain(t, "min sdk version", flags, "-target aarch64-linux-android"+version)
+ }
+
+ testSdkVersionFlag("libfoo", "10000")
+ testSdkVersionFlag("libbar", "29")
+
+ ctx = android.GroupFixturePreparers(
+ prepareForCcTestWithoutVndk,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ if variables.BuildFlags == nil {
+ variables.BuildFlags = make(map[string]string)
+ }
+ variables.BuildFlags["RELEASE_BOARD_API_LEVEL_FROZEN"] = "true"
+ }),
+ ).RunTestWithBp(t, bp)
+ testSdkVersionFlag("libfoo", "30")
+ testSdkVersionFlag("libbar", "29")
+}
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index 3d6890c..603bc6d 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -28,13 +28,20 @@
armCflags = []string{
"-fomit-frame-pointer",
+ // Revert this after b/322359235 is fixed
+ "-mllvm", "-enable-shrink-wrap=false",
}
- armCppflags = []string{}
+ armCppflags = []string{
+ // Revert this after b/322359235 is fixed
+ "-mllvm", "-enable-shrink-wrap=false",
+ }
armLdflags = []string{
"-Wl,--hash-style=gnu",
"-Wl,-m,armelf",
+ // Revert this after b/322359235 is fixed
+ "-Wl,-mllvm", "-Wl,-enable-shrink-wrap=false",
}
armLldflags = armLdflags
diff --git a/cc/coverage.go b/cc/coverage.go
index 393a8a6..43f5e07 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -246,7 +246,7 @@
type UseCoverage interface {
android.Module
- IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool
+ IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool
}
// Coverage is an interface for non-CC modules to implement to be mutated for coverage
@@ -258,43 +258,86 @@
EnableCoverageIfNeeded()
}
-func coverageMutator(mctx android.BottomUpMutatorContext) {
- if c, ok := mctx.Module().(*Module); ok && c.coverage != nil {
- needCoverageVariant := c.coverage.Properties.NeedCoverageVariant
- needCoverageBuild := c.coverage.Properties.NeedCoverageBuild
- if needCoverageVariant {
- m := mctx.CreateVariations("", "cov")
+type coverageTransitionMutator struct{}
- // Setup the non-coverage version and set HideFromMake and
- // PreventInstall to true.
- m[0].(*Module).coverage.Properties.CoverageEnabled = false
- m[0].(*Module).coverage.Properties.IsCoverageVariant = false
- m[0].(*Module).Properties.HideFromMake = true
- m[0].(*Module).Properties.PreventInstall = true
+var _ android.TransitionMutator = (*coverageTransitionMutator)(nil)
- // The coverage-enabled version inherits HideFromMake,
- // PreventInstall from the original module.
- m[1].(*Module).coverage.Properties.CoverageEnabled = needCoverageBuild
- m[1].(*Module).coverage.Properties.IsCoverageVariant = true
+func (c coverageTransitionMutator) Split(ctx android.BaseModuleContext) []string {
+ if c, ok := ctx.Module().(*Module); ok && c.coverage != nil {
+ if c.coverage.Properties.NeedCoverageVariant {
+ return []string{"", "cov"}
}
- } else if cov, ok := mctx.Module().(Coverage); ok && cov.IsNativeCoverageNeeded(mctx) {
+ } else if cov, ok := ctx.Module().(Coverage); ok && cov.IsNativeCoverageNeeded(ctx) {
// APEX and Rust modules fall here
// Note: variant "" is also created because an APEX can be depended on by another
// module which are split into "" and "cov" variants. e.g. when cc_test refers
// to an APEX via 'data' property.
- m := mctx.CreateVariations("", "cov")
- m[0].(Coverage).MarkAsCoverageVariant(false)
- m[0].(Coverage).SetPreventInstall()
- m[0].(Coverage).HideFromMake()
-
- m[1].(Coverage).MarkAsCoverageVariant(true)
- m[1].(Coverage).EnableCoverageIfNeeded()
- } else if cov, ok := mctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(mctx) {
+ return []string{"", "cov"}
+ } else if cov, ok := ctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(ctx) {
// Module itself doesn't have to have "cov" variant, but it should use "cov" variants of
// deps.
- mctx.CreateVariations("cov")
- mctx.AliasVariation("cov")
+ return []string{"cov"}
+ }
+
+ return []string{""}
+}
+
+func (c coverageTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ return sourceVariation
+}
+
+func (c coverageTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if c, ok := ctx.Module().(*Module); ok && c.coverage != nil {
+ if !c.coverage.Properties.NeedCoverageVariant {
+ return ""
+ }
+ } else if cov, ok := ctx.Module().(Coverage); ok {
+ if !cov.IsNativeCoverageNeeded(ctx) {
+ return ""
+ }
+ } else if cov, ok := ctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(ctx) {
+ // Module only has a "cov" variation, so all incoming variations should use "cov".
+ return "cov"
+ } else {
+ return ""
+ }
+
+ return incomingVariation
+}
+
+func (c coverageTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ if c, ok := ctx.Module().(*Module); ok && c.coverage != nil {
+ if variation == "" && c.coverage.Properties.NeedCoverageVariant {
+ // Setup the non-coverage version and set HideFromMake and
+ // PreventInstall to true.
+ c.coverage.Properties.CoverageEnabled = false
+ c.coverage.Properties.IsCoverageVariant = false
+ c.Properties.HideFromMake = true
+ c.Properties.PreventInstall = true
+ } else if variation == "cov" {
+ // The coverage-enabled version inherits HideFromMake,
+ // PreventInstall from the original module.
+ c.coverage.Properties.CoverageEnabled = c.coverage.Properties.NeedCoverageBuild
+ c.coverage.Properties.IsCoverageVariant = true
+ }
+ } else if cov, ok := ctx.Module().(Coverage); ok && cov.IsNativeCoverageNeeded(ctx) {
+ // APEX and Rust modules fall here
+
+ // Note: variant "" is also created because an APEX can be depended on by another
+ // module which are split into "" and "cov" variants. e.g. when cc_test refers
+ // to an APEX via 'data' property.
+ if variation == "" {
+ cov.MarkAsCoverageVariant(false)
+ cov.SetPreventInstall()
+ cov.HideFromMake()
+ } else if variation == "cov" {
+ cov.MarkAsCoverageVariant(true)
+ cov.EnableCoverageIfNeeded()
+ }
+ } else if cov, ok := ctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(ctx) {
+ // Module itself doesn't have to have "cov" variant, but it should use "cov" variants of
+ // deps.
}
}
diff --git a/cc/library.go b/cc/library.go
index ff30d40..4b6ac59 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1350,10 +1350,12 @@
fileName+".lsdump")
}
-func getRefAbiDumpDir(isNdk bool) string {
+func getRefAbiDumpDir(isNdk, isLlndk bool) string {
var dirName string
if isNdk {
dirName = "ndk"
+ } else if isLlndk {
+ dirName = "vndk"
} else {
dirName = "platform"
}
@@ -1476,7 +1478,7 @@
addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())
- dumpDir := getRefAbiDumpDir(isNdk)
+ dumpDir := getRefAbiDumpDir(isNdk, isLlndk)
binderBitness := ctx.DeviceConfig().BinderBitness()
// Check against the previous version.
prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir)
diff --git a/cc/lto.go b/cc/lto.go
index 8b0880c..b2b4570 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -15,9 +15,12 @@
package cc
import (
- "android/soong/android"
+ "fmt"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
+
+ "android/soong/android"
)
// LTO (link-time optimization) allows the compiler to optimize and generate
@@ -49,11 +52,6 @@
LtoEnabled bool `blueprint:"mutated"`
LtoDefault bool `blueprint:"mutated"`
- // Dep properties indicate that this module needs to be built with LTO
- // since it is an object dependency of an LTO module.
- LtoDep bool `blueprint:"mutated"`
- NoLtoDep bool `blueprint:"mutated"`
-
// Use -fwhole-program-vtables cflag.
Whole_program_vtables *bool
}
@@ -176,86 +174,83 @@
return lto != nil && proptools.Bool(lto.Properties.Lto.Never)
}
-// Propagate lto requirements down from binaries
-func ltoDepsMutator(mctx android.TopDownMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok {
- if m.lto == nil || m.lto.Properties.LtoEnabled == m.lto.Properties.LtoDefault {
- return
- }
-
- mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
- tag := mctx.OtherModuleDependencyTag(dep)
- libTag, isLibTag := tag.(libraryDependencyTag)
-
- // Do not recurse down non-static dependencies
- if isLibTag {
- if !libTag.static() {
- return false
- }
- } else {
- if tag != objDepTag && tag != reuseObjTag {
- return false
- }
- }
-
- if dep, ok := dep.(*Module); ok {
- if m.lto.Properties.LtoEnabled {
- dep.lto.Properties.LtoDep = true
- } else {
- dep.lto.Properties.NoLtoDep = true
- }
- }
-
- // Recursively walk static dependencies
- return true
- })
+func ltoPropagateViaDepTag(tag blueprint.DependencyTag) bool {
+ libTag, isLibTag := tag.(libraryDependencyTag)
+ // Do not recurse down non-static dependencies
+ if isLibTag {
+ return libTag.static()
+ } else {
+ return tag == objDepTag || tag == reuseObjTag || tag == staticVariantTag
}
}
-// Create lto variants for modules that need them
-func ltoMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok && m.lto != nil {
- // Create variations for LTO types required as static
- // dependencies
- variationNames := []string{""}
- if m.lto.Properties.LtoDep {
- variationNames = append(variationNames, "lto-thin")
- }
- if m.lto.Properties.NoLtoDep {
- variationNames = append(variationNames, "lto-none")
+// ltoTransitionMutator creates LTO variants of cc modules. Variant "" is the default variant, which may
+// or may not have LTO enabled depending on the config and the module's type and properties. "lto-thin" or
+// "lto-none" variants are created when a module needs to compile in the non-default state for that module.
+type ltoTransitionMutator struct{}
+
+const LTO_NONE_VARIATION = "lto-none"
+const LTO_THIN_VARIATION = "lto-thin"
+
+func (l *ltoTransitionMutator) Split(ctx android.BaseModuleContext) []string {
+ return []string{""}
+}
+
+func (l *ltoTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.lto != nil {
+ if !ltoPropagateViaDepTag(ctx.DepTag()) {
+ return ""
}
- if !m.lto.Properties.LtoEnabled {
- mctx.SetDependencyVariation("lto-none")
+ if sourceVariation != "" {
+ return sourceVariation
}
+
+ // Always request an explicit variation, IncomingTransition will rewrite it back to the default variation
+ // if necessary.
if m.lto.Properties.LtoEnabled {
- mctx.SetDependencyVariation("lto-thin")
+ return LTO_THIN_VARIATION
+ } else {
+ return LTO_NONE_VARIATION
}
+ }
+ return ""
+}
- if len(variationNames) > 1 {
- modules := mctx.CreateVariations(variationNames...)
- for i, name := range variationNames {
- variation := modules[i].(*Module)
- // Default module which will be
- // installed. Variation set above according to
- // explicit LTO properties
- if name == "" {
- continue
- }
-
- // LTO properties for dependencies
- if name == "lto-thin" {
- variation.lto.Properties.LtoEnabled = true
- }
- if name == "lto-none" {
- variation.lto.Properties.LtoEnabled = false
- }
- variation.Properties.PreventInstall = true
- variation.Properties.HideFromMake = true
- variation.lto.Properties.LtoDefault = m.lto.Properties.LtoDefault
- variation.lto.Properties.LtoDep = false
- variation.lto.Properties.NoLtoDep = false
- }
+func (l *ltoTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.lto != nil {
+ if m.lto.Never() {
+ return ""
}
+ // Rewrite explicit variations back to the default variation if the default variation matches.
+ if incomingVariation == LTO_THIN_VARIATION && m.lto.Properties.LtoDefault {
+ return ""
+ } else if incomingVariation == LTO_NONE_VARIATION && !m.lto.Properties.LtoDefault {
+ return ""
+ }
+ return incomingVariation
+ }
+ return ""
+}
+
+func (l *ltoTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ // Default module which will be installed. Variation set above according to explicit LTO properties.
+ if variation == "" {
+ return
+ }
+
+ if m, ok := ctx.Module().(*Module); ok && m.lto != nil {
+ // Non-default variation, set the LTO properties to match the variation.
+ switch variation {
+ case LTO_THIN_VARIATION:
+ m.lto.Properties.LtoEnabled = true
+ case LTO_NONE_VARIATION:
+ m.lto.Properties.LtoEnabled = false
+ default:
+ panic(fmt.Errorf("unknown variation %s", variation))
+ }
+ // Non-default variations are never installed.
+ m.Properties.PreventInstall = true
+ m.Properties.HideFromMake = true
}
}
diff --git a/cc/lto_test.go b/cc/lto_test.go
index 7b7fe8c..e4b5a3a 100644
--- a/cc/lto_test.go
+++ b/cc/lto_test.go
@@ -146,8 +146,9 @@
t.Errorf("'root' missing dependency on the default variant of 'foo'")
}
- if !hasDep(result, libRootLtoNever, libFoo.Module()) {
- t.Errorf("'root_no_lto' missing dependency on the default variant of 'foo'")
+ libFooNoLto := result.ModuleForTests("foo", "android_arm64_armv8-a_static_lto-none")
+ if !hasDep(result, libRootLtoNever, libFooNoLto.Module()) {
+ t.Errorf("'root_no_lto' missing dependency on the lto_none variant of 'foo'")
}
libFooCFlags := libFoo.Rule("cc").Args["cFlags"]
diff --git a/cc/object_test.go b/cc/object_test.go
index e6a3fdd..c0d1331 100644
--- a/cc/object_test.go
+++ b/cc/object_test.go
@@ -22,7 +22,7 @@
)
func TestMinSdkVersionsOfCrtObjects(t *testing.T) {
- ctx := testCc(t, `
+ bp := `
cc_object {
name: "crt_foo",
srcs: ["foo.c"],
@@ -30,8 +30,8 @@
stl: "none",
min_sdk_version: "28",
vendor_available: true,
- }`)
-
+ }
+ `
variants := []struct {
variant string
num string
@@ -43,11 +43,17 @@
{"android_arm64_armv8-a_sdk_current", "10000"},
{"android_vendor.29_arm64_armv8-a", "29"},
}
+
+ ctx := prepareForCcTest.RunTestWithBp(t, bp)
for _, v := range variants {
cflags := ctx.ModuleForTests("crt_foo", v.variant).Rule("cc").Args["cFlags"]
expected := "-target aarch64-linux-android" + v.num + " "
android.AssertStringDoesContain(t, "cflag", cflags, expected)
}
+ ctx = prepareForCcTestWithoutVndk.RunTestWithBp(t, bp)
+ android.AssertStringDoesContain(t, "cflag",
+ ctx.ModuleForTests("crt_foo", "android_vendor_arm64_armv8-a").Rule("cc").Args["cFlags"],
+ "-target aarch64-linux-android10000 ")
}
func TestUseCrtObjectOfCorrectVersion(t *testing.T) {
diff --git a/cc/orderfile.go b/cc/orderfile.go
index 9192e81..38b8905 100644
--- a/cc/orderfile.go
+++ b/cc/orderfile.go
@@ -20,6 +20,8 @@
import (
"fmt"
+ "github.com/google/blueprint"
+
"android/soong/android"
)
@@ -190,66 +192,61 @@
return flags
}
-// Propagate profile orderfile flags down from binaries and shared libraries
-// We do not allow propagation for load flags because the orderfile is specific
-// to the module (binary / shared library)
-func orderfileDepsMutator(mctx android.TopDownMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok {
- if !m.orderfile.orderfileLinkEnabled() {
- return
- }
- mctx.WalkDeps(func(dep android.
- Module, parent android.Module) bool {
- tag := mctx.OtherModuleDependencyTag(dep)
- libTag, isLibTag := tag.(libraryDependencyTag)
-
- // Do not recurse down non-static dependencies
- if isLibTag {
- if !libTag.static() {
- return false
- }
- } else {
- if tag != objDepTag && tag != reuseObjTag {
- return false
- }
- }
-
- if dep, ok := dep.(*Module); ok {
- if m.orderfile.Properties.OrderfileInstrLink {
- dep.orderfile.Properties.OrderfileInstrLink = true
- }
- }
-
- return true
- })
+func orderfilePropagateViaDepTag(tag blueprint.DependencyTag) bool {
+ libTag, isLibTag := tag.(libraryDependencyTag)
+ // Do not recurse down non-static dependencies
+ if isLibTag {
+ return libTag.static()
+ } else {
+ return tag == objDepTag || tag == reuseObjTag || tag == staticVariantTag
}
}
-// Create orderfile variants for modules that need them
-func orderfileMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok && m.orderfile != nil {
- if !m.static() && m.orderfile.orderfileEnabled() {
- mctx.SetDependencyVariation("orderfile")
- return
+// orderfileTransitionMutator creates orderfile variants of cc modules.
+type orderfileTransitionMutator struct{}
+
+const ORDERFILE_VARIATION = "orderfile"
+
+func (o *orderfileTransitionMutator) Split(ctx android.BaseModuleContext) []string {
+ return []string{""}
+}
+
+func (o *orderfileTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.orderfile != nil {
+ if !orderfilePropagateViaDepTag(ctx.DepTag()) {
+ return ""
}
- variationNames := []string{""}
- if m.orderfile.Properties.OrderfileInstrLink {
- variationNames = append(variationNames, "orderfile")
+ if sourceVariation != "" {
+ return sourceVariation
}
- if len(variationNames) > 1 {
- modules := mctx.CreateVariations(variationNames...)
- for i, name := range variationNames {
- if name == "" {
- continue
- }
- variation := modules[i].(*Module)
- variation.Properties.PreventInstall = true
- variation.Properties.HideFromMake = true
- variation.orderfile.Properties.ShouldProfileModule = true
- variation.orderfile.Properties.OrderfileLoad = false
- }
+ // Propagate profile orderfile flags down from binaries and shared libraries
+ if m.orderfile.orderfileLinkEnabled() {
+ return ORDERFILE_VARIATION
}
}
+ return ""
+}
+
+func (o *orderfileTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.orderfile != nil {
+ return incomingVariation
+ }
+ return ""
+}
+
+func (o *orderfileTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ if variation == "" {
+ return
+ }
+
+ if m, ok := ctx.Module().(*Module); ok && m.orderfile != nil {
+ m.Properties.PreventInstall = true
+ m.Properties.HideFromMake = true
+ m.orderfile.Properties.ShouldProfileModule = true
+ // We do not allow propagation for load flags because the orderfile is specific
+ // to the module (binary / shared library)
+ m.orderfile.Properties.OrderfileLoad = false
+ }
}
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index e721c53..8f4b7df 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -17,6 +17,8 @@
import (
"path/filepath"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
)
@@ -36,9 +38,15 @@
type prebuiltLinkerInterface interface {
Name(string) string
prebuilt() *android.Prebuilt
+ sourceModuleName() string
}
type prebuiltLinkerProperties struct {
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
+
// a prebuilt library or binary. Can reference a genrule module that generates an executable file.
Srcs []string `android:"path,arch_variant"`
@@ -337,7 +345,11 @@
}
type prebuiltObjectProperties struct {
- Srcs []string `android:"path,arch_variant"`
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
+ Srcs []string `android:"path,arch_variant"`
}
type prebuiltObjectLinker struct {
@@ -351,6 +363,10 @@
return &p.Prebuilt
}
+func (p *prebuiltObjectLinker) sourceModuleName() string {
+ return proptools.String(p.properties.Source_module_name)
+}
+
var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
func (p *prebuiltObjectLinker) link(ctx ModuleContext,
@@ -520,3 +536,7 @@
}
return sanitized.None.Srcs
}
+
+func (p *prebuiltLinker) sourceModuleName() string {
+ return proptools.String(p.properties.Source_module_name)
+}
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 8b4174b..95fb7ed 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -15,6 +15,7 @@
package cc
import (
+ "fmt"
"runtime"
"testing"
@@ -509,3 +510,100 @@
}`
testCcError(t, `Android.bp:4:6: module "bintest" variant "android_arm64_armv8-a": srcs: multiple prebuilt source files`, bp)
}
+
+func TestMultiplePrebuilts(t *testing.T) {
+ bp := `
+ // an rdep
+ cc_library {
+ name: "libfoo",
+ shared_libs: ["libbar"],
+ }
+
+ // multiple variations of dep
+ // source
+ cc_library {
+ name: "libbar",
+ }
+ // prebuilt "v1"
+ cc_prebuilt_library_shared {
+ name: "libbar",
+ srcs: ["libbar.so"],
+ }
+ // prebuilt "v2"
+ cc_prebuilt_library_shared {
+ name: "libbar.v2",
+ stem: "libbar",
+ source_module_name: "libbar",
+ srcs: ["libbar.so"],
+ }
+
+ // selectors
+ apex_contributions {
+ name: "myapex_contributions",
+ contents: ["%v"],
+ }
+ all_apex_contributions {name: "all_apex_contributions"}
+ `
+ hasDep := func(ctx *android.TestContext, m android.Module, wantDep android.Module) bool {
+ t.Helper()
+ var found bool
+ ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
+ if dep == wantDep {
+ found = true
+ }
+ })
+ return found
+ }
+
+ testCases := []struct {
+ desc string
+ selectedDependencyName string
+ expectedDependencyName string
+ }{
+ {
+ desc: "Source library is selected using apex_contributions",
+ selectedDependencyName: "libbar",
+ expectedDependencyName: "libbar",
+ },
+ {
+ desc: "Prebuilt library v1 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_libbar",
+ expectedDependencyName: "prebuilt_libbar",
+ },
+ {
+ desc: "Prebuilt library v2 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_libbar.v2",
+ expectedDependencyName: "prebuilt_libbar.v2",
+ },
+ }
+
+ for _, tc := range testCases {
+ preparer := android.GroupFixturePreparers(
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ android.RegisterApexContributionsBuildComponents(ctx)
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
+ }
+ }),
+ )
+ ctx := testPrebuilt(t, fmt.Sprintf(bp, tc.selectedDependencyName), map[string][]byte{
+ "libbar.so": nil,
+ "crtx.o": nil,
+ }, preparer)
+ libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
+ expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module()
+ android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", libfoo.Name(), tc.expectedDependencyName), true, hasDep(ctx, libfoo, expectedDependency))
+
+ // check installation rules
+ // the selected soong module should be exported to make
+ libbar := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module()
+ android.AssertBoolEquals(t, fmt.Sprintf("dependency %s should be exported to make\n", expectedDependency), true, !libbar.IsHideFromMake())
+
+ // check LOCAL_MODULE of the selected module name
+ // the prebuilt should have the same LOCAL_MODULE when exported to make
+ entries := android.AndroidMkEntriesForTest(t, ctx, libbar)[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "libbar", entries.EntryMap["LOCAL_MODULE"][0])
+ }
+}
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go
index 3fb4454..6d1caf9 100644
--- a/cmd/pom2bp/pom2bp.go
+++ b/cmd/pom2bp/pom2bp.go
@@ -651,7 +651,7 @@
{{- end}}
],
{{- end}}
- java_version: "1.7",
+ java_version: "1.8",
}
`))
diff --git a/cmd/pom2mk/pom2mk.go b/cmd/pom2mk/pom2mk.go
index b347155..5ca770e 100644
--- a/cmd/pom2mk/pom2mk.go
+++ b/cmd/pom2mk/pom2mk.go
@@ -262,7 +262,7 @@
{{.MkName}}-nodeps{{end}}{{range .MkAarDeps}} \
{{.}}{{end}}
LOCAL_JAR_EXCLUDE_FILES := none
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_JAVA_LANGUAGE_VERSION := 1.8
LOCAL_USE_AAPT2 := true
include $(BUILD_STATIC_JAVA_LIBRARY)
`))
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 7b207d6..2f6476c 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -512,6 +512,6 @@
var _ cc.UseCoverage = (*filesystem)(nil)
-func (*filesystem) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
+func (*filesystem) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
}
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
index 3383650..60b1366 100644
--- a/genrule/allowlists.go
+++ b/genrule/allowlists.go
@@ -15,12 +15,6 @@
package genrule
var (
- DepfileAllowList = []string{
- // go/keep-sorted start
- "depfile_allowed_for_test",
- // go/keep-sorted end
- }
-
SandboxingDenyModuleList = []string{
// go/keep-sorted start
"aidl_camera_build_version",
diff --git a/genrule/genrule.go b/genrule/genrule.go
index fbda074..6f66088 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -124,14 +124,10 @@
// $(locations <label>): the paths to the tools, tool_files, inputs or outputs with name <label>. Use $(locations) if <label> refers to a rule that outputs two or more files.
// $(in): one or more input files.
// $(out): a single output file.
- // $(depfile): a file to which dependencies will be written, if the depfile property is set to true.
// $(genDir): the sandbox directory for this tool; contains $(out).
// $$: a literal $
Cmd *string
- // Enable reading a file containing dependencies in gcc format after the command completes
- Depfile *bool
-
// name of the modules (if any) that produces the host executable. Leave empty for
// prebuilts or scripts that do not need a module to build them.
Tools []string
@@ -194,10 +190,8 @@
type generateTask struct {
in android.Paths
out android.WritablePaths
- depFile android.WritablePath
copyTo android.WritablePaths // For gensrcs to set on gensrcsMerge rule.
genDir android.WritablePath
- extraTools android.Paths // dependencies on tools used by the generator
extraInputs map[string][]string
cmd string
@@ -448,8 +442,6 @@
addLocationLabel(out.Rel(), outputLocation{out})
}
- referencedDepfile := false
-
rawCommand, err := android.Expand(task.cmd, func(name string) (string, error) {
// report the error directly without returning an error to android.Expand to catch multiple errors in a
// single run
@@ -481,12 +473,6 @@
sandboxOuts = append(sandboxOuts, cmd.PathForOutput(out))
}
return strings.Join(proptools.ShellEscapeList(sandboxOuts), " "), nil
- case "depfile":
- referencedDepfile = true
- if !Bool(g.properties.Depfile) {
- return reportError("$(depfile) used without depfile property")
- }
- return "__SBOX_DEPFILE__", nil
case "genDir":
return proptools.ShellEscape(cmd.PathForOutput(task.genDir)), nil
default:
@@ -526,10 +512,6 @@
return
}
- if Bool(g.properties.Depfile) && !referencedDepfile {
- ctx.PropertyErrorf("cmd", "specified depfile=true but did not include a reference to '${depfile}' in cmd")
- return
- }
g.rawCommands = append(g.rawCommands, rawCommand)
cmd.Text(rawCommand)
@@ -538,11 +520,7 @@
cmd.ImplicitOutputs(task.out)
cmd.Implicits(task.in)
cmd.ImplicitTools(tools)
- cmd.ImplicitTools(task.extraTools)
cmd.ImplicitPackagedTools(packagedTools)
- if Bool(g.properties.Depfile) {
- cmd.ImplicitDepFile(task.depFile)
- }
// Create the rule to run the genrule command inside sbox.
rule.Build(name, desc)
@@ -583,19 +561,6 @@
}
func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- // Allowlist genrule to use depfile until we have a solution to remove it.
- // TODO(b/307824623): Remove depfile property
- if Bool(g.properties.Depfile) {
- sandboxingAllowlistSets := getSandboxingAllowlistSets(ctx)
- if ctx.DeviceConfig().GenruleSandboxing() && !sandboxingAllowlistSets.depfileAllowSet[g.Name()] {
- ctx.PropertyErrorf(
- "depfile",
- "Deprecated because with genrule sandboxing, dependencies must be known before the action is run "+
- "in order to add them to the sandbox. "+
- "Please specify the dependencies explicitly so that there is no need to use depfile.")
- }
- }
-
g.generateCommonBuildActions(ctx)
// For <= 6 outputs, just embed those directly in the users. Right now, that covers >90% of
@@ -721,7 +686,6 @@
for i, shard := range shards {
var commands []string
var outFiles android.WritablePaths
- var commandDepFiles []string
var copyTo android.WritablePaths
// When sharding is enabled (i.e. len(shards) > 1), the sbox rules for each
@@ -761,12 +725,6 @@
return in.String(), nil
case "out":
return rule.Command().PathForOutput(outFile), nil
- case "depfile":
- // Generate a depfile for each output file. Store the list for
- // later in order to combine them all into a single depfile.
- depFile := rule.Command().PathForOutput(outFile.ReplaceExtension(ctx, "d"))
- commandDepFiles = append(commandDepFiles, depFile)
- return depFile, nil
default:
return "$(" + name + ")", nil
}
@@ -781,30 +739,14 @@
}
fullCommand := strings.Join(commands, " && ")
- var outputDepfile android.WritablePath
- var extraTools android.Paths
- if len(commandDepFiles) > 0 {
- // Each command wrote to a depfile, but ninja can only handle one
- // depfile per rule. Use the dep_fixer tool at the end of the
- // command to combine all the depfiles into a single output depfile.
- outputDepfile = android.PathForModuleGen(ctx, genSubDir, "gensrcs.d")
- depFixerTool := ctx.Config().HostToolPath(ctx, "dep_fixer")
- fullCommand += fmt.Sprintf(" && %s -o $(depfile) %s",
- rule.Command().PathForTool(depFixerTool),
- strings.Join(commandDepFiles, " "))
- extraTools = append(extraTools, depFixerTool)
- }
-
generateTasks = append(generateTasks, generateTask{
- in: shard,
- out: outFiles,
- depFile: outputDepfile,
- copyTo: copyTo,
- genDir: genDir,
- cmd: fullCommand,
- shard: i,
- shards: len(shards),
- extraTools: extraTools,
+ in: shard,
+ out: outFiles,
+ copyTo: copyTo,
+ genDir: genDir,
+ cmd: fullCommand,
+ shard: i,
+ shards: len(shards),
extraInputs: map[string][]string{
"data": properties.Data,
},
@@ -843,20 +785,14 @@
taskGenerator := func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask {
outs := make(android.WritablePaths, len(properties.Out))
- var depFile android.WritablePath
for i, out := range properties.Out {
- outPath := android.PathForModuleGen(ctx, out)
- if i == 0 {
- depFile = outPath.ReplaceExtension(ctx, "d")
- }
- outs[i] = outPath
+ outs[i] = android.PathForModuleGen(ctx, out)
}
return []generateTask{{
- in: srcFiles,
- out: outs,
- depFile: depFile,
- genDir: android.PathForModuleGen(ctx),
- cmd: rawCommand,
+ in: srcFiles,
+ out: outs,
+ genDir: android.PathForModuleGen(ctx),
+ cmd: rawCommand,
}}
}
@@ -907,22 +843,18 @@
type sandboxingAllowlistSets struct {
sandboxingDenyModuleSet map[string]bool
sandboxingDenyPathSet map[string]bool
- depfileAllowSet map[string]bool
}
func getSandboxingAllowlistSets(ctx android.PathContext) *sandboxingAllowlistSets {
return ctx.Config().Once(sandboxingAllowlistKey, func() interface{} {
sandboxingDenyModuleSet := map[string]bool{}
sandboxingDenyPathSet := map[string]bool{}
- depfileAllowSet := map[string]bool{}
- android.AddToStringSet(sandboxingDenyModuleSet, append(DepfileAllowList, SandboxingDenyModuleList...))
+ android.AddToStringSet(sandboxingDenyModuleSet, SandboxingDenyModuleList)
android.AddToStringSet(sandboxingDenyPathSet, SandboxingDenyPathList)
- android.AddToStringSet(depfileAllowSet, DepfileAllowList)
return &sandboxingAllowlistSets{
sandboxingDenyModuleSet: sandboxingDenyModuleSet,
sandboxingDenyPathSet: sandboxingDenyPathSet,
- depfileAllowSet: depfileAllowSet,
}
}).(*sandboxingAllowlistSets)
}
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index fa0ee17..2dc6a79 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -287,16 +287,6 @@
expect: "echo foo > __SBOX_SANDBOX_DIR__/out/out2",
},
{
- name: "depfile",
- moduleName: "depfile_allowed_for_test",
- prop: `
- out: ["out"],
- depfile: true,
- cmd: "echo foo > $(out) && touch $(depfile)",
- `,
- expect: "echo foo > __SBOX_SANDBOX_DIR__/out/out && touch __SBOX_DEPFILE__",
- },
- {
name: "gendir",
prop: `
out: ["out"],
@@ -392,24 +382,6 @@
err: `unknown variable '$(foo)'`,
},
{
- name: "error depfile",
- prop: `
- out: ["out"],
- cmd: "echo foo > $(out) && touch $(depfile)",
- `,
- err: "$(depfile) used without depfile property",
- },
- {
- name: "error no depfile",
- moduleName: "depfile_allowed_for_test",
- prop: `
- out: ["out"],
- depfile: true,
- cmd: "echo foo > $(out)",
- `,
- err: "specified depfile=true but did not include a reference to '${depfile}' in cmd",
- },
- {
name: "error no out",
prop: `
cmd: "echo foo > $(out)",
@@ -695,60 +667,6 @@
}
}
-func TestGenruleAllowlistingDepfile(t *testing.T) {
- tests := []struct {
- name string
- prop string
- err string
- moduleName string
- }{
- {
- name: `error when module is not allowlisted`,
- prop: `
- depfile: true,
- cmd: "cat $(in) > $(out) && cat $(depfile)",
- `,
- err: "depfile: Deprecated because with genrule sandboxing, dependencies must be known before the action is run in order to add them to the sandbox",
- },
- {
- name: `no error when module is allowlisted`,
- prop: `
- depfile: true,
- cmd: "cat $(in) > $(out) && cat $(depfile)",
- `,
- moduleName: `depfile_allowed_for_test`,
- },
- }
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- moduleName := "foo"
- if test.moduleName != "" {
- moduleName = test.moduleName
- }
- bp := fmt.Sprintf(`
- gensrcs {
- name: "%s",
- srcs: ["data.txt"],
- %s
- }`, moduleName, test.prop)
-
- var expectedErrors []string
- if test.err != "" {
- expectedErrors = append(expectedErrors, test.err)
- }
- android.GroupFixturePreparers(
- prepareForGenRuleTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.GenruleSandboxing = proptools.BoolPtr(true)
- }),
- ).
- ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(expectedErrors)).
- RunTestWithBp(t, bp)
- })
-
- }
-}
-
func TestGenruleDefaults(t *testing.T) {
bp := `
genrule_defaults {
diff --git a/java/aar.go b/java/aar.go
index b162ef6..f61fc83 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -159,8 +159,8 @@
}
}
-func (a *aapt) useResourceProcessorBusyBox() bool {
- return BoolDefault(a.aaptProperties.Use_resource_processor, false)
+func (a *aapt) useResourceProcessorBusyBox(ctx android.BaseModuleContext) bool {
+ return BoolDefault(a.aaptProperties.Use_resource_processor, ctx.Config().UseResourceProcessorByDefault())
}
func (a *aapt) filterProduct() string {
@@ -414,7 +414,7 @@
linkFlags = append(linkFlags, "--static-lib")
}
- if a.isLibrary && a.useResourceProcessorBusyBox() {
+ if a.isLibrary && a.useResourceProcessorBusyBox(ctx) {
// When building an android_library using ResourceProcessorBusyBox the resources are merged into
// package-res.apk with --merge-only, but --no-static-lib-packages is not used so that R.txt only
// contains resources from this library.
@@ -453,7 +453,7 @@
// of transitiveStaticLibs.
transitiveStaticLibs := android.ReversePaths(staticDeps.resPackages())
- if a.isLibrary && a.useResourceProcessorBusyBox() {
+ if a.isLibrary && a.useResourceProcessorBusyBox(ctx) {
// When building an android_library with ResourceProcessorBusyBox enabled treat static library dependencies
// as imports. The resources from dependencies will not be merged into this module's package-res.apk, and
// instead modules depending on this module will reference package-res.apk from all transitive static
@@ -515,7 +515,7 @@
})
}
- if !a.useResourceProcessorBusyBox() {
+ if !a.useResourceProcessorBusyBox(ctx) {
// the subdir "android" is required to be filtered by package names
srcJar = android.PathForModuleGen(ctx, "android", "R.srcjar")
}
@@ -542,7 +542,7 @@
a.assetPackage = android.OptionalPathForPath(assets)
}
- if a.useResourceProcessorBusyBox() {
+ if a.useResourceProcessorBusyBox(ctx) {
rJar := android.PathForModuleOut(ctx, "busybox/R.jar")
resourceProcessorBusyBoxGenerateBinaryR(ctx, rTxt, a.mergedManifestFile, rJar, staticDeps, a.isLibrary, a.aaptProperties.Aaptflags)
aapt2ExtractExtraPackages(ctx, extraPackages, rJar)
@@ -577,7 +577,7 @@
rJar: a.rJar,
assets: a.assetPackage,
- usedResourceProcessor: a.useResourceProcessorBusyBox(),
+ usedResourceProcessor: a.useResourceProcessorBusyBox(ctx),
}).
Transitive(staticResourcesNodesDepSet).Build()
a.rroDirsDepSet = android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL).
@@ -823,7 +823,7 @@
ctx.CheckbuildFile(a.aapt.proguardOptionsFile)
ctx.CheckbuildFile(a.aapt.exportPackage)
- if a.useResourceProcessorBusyBox() {
+ if a.useResourceProcessorBusyBox(ctx) {
ctx.CheckbuildFile(a.aapt.rJar)
} else {
ctx.CheckbuildFile(a.aapt.aaptSrcJar)
@@ -849,7 +849,7 @@
var extraSrcJars android.Paths
var extraCombinedJars android.Paths
var extraClasspathJars android.Paths
- if a.useResourceProcessorBusyBox() {
+ if a.useResourceProcessorBusyBox(ctx) {
// When building a library with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox for this
// library and each of the transitive static android_library dependencies has already created an
// R.class file for the appropriate package. Add all of those R.class files to the classpath.
@@ -889,7 +889,7 @@
}
func (a *aapt) IDEInfo(dpInfo *android.IdeInfo) {
- if a.useResourceProcessorBusyBox() {
+ if a.rJar != nil {
dpInfo.Jars = append(dpInfo.Jars, a.rJar.String())
}
}
diff --git a/java/androidmk.go b/java/androidmk.go
index c86dcf4..b523594 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -209,9 +209,10 @@
return []android.AndroidMkEntries{}
}
return []android.AndroidMkEntries{android.AndroidMkEntries{
- Class: "JAVA_LIBRARIES",
- OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
- Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ Class: "JAVA_LIBRARIES",
+ OverrideName: prebuilt.BaseModuleName(),
+ OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
diff --git a/java/app.go b/java/app.go
index 5d5c09a..0c56d81 100755
--- a/java/app.go
+++ b/java/app.go
@@ -588,7 +588,7 @@
var extraSrcJars android.Paths
var extraClasspathJars android.Paths
var extraCombinedJars android.Paths
- if a.useResourceProcessorBusyBox() {
+ if a.useResourceProcessorBusyBox(ctx) {
// When building an app with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox has already
// created R.class files that provide IDs for resources in busybox/R.jar. Pass that file in the
// classpath when compiling everything else, and add it to the final classes jar.
@@ -1108,7 +1108,7 @@
return Bool(a.appProperties.Privileged)
}
-func (a *AndroidApp) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
+func (a *AndroidApp) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
}
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index ce32131..7c45d30 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -949,7 +949,7 @@
builder.CopyToSnapshot(p, dest)
dests = append(dests, dest)
}
- hiddenAPISet.AddProperty(category.PropertyName, dests)
+ hiddenAPISet.AddProperty(category.PropertyName(), dests)
}
}
}
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 95cd4a9..8bc0a7e 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -467,10 +467,10 @@
android.AssertArrayString(t, "single packages", []string{"newlibrary.mine"}, info.SinglePackages)
for _, c := range HiddenAPIFlagFileCategories {
expectedMaxTargetQPaths := []string(nil)
- if c.PropertyName == "max_target_q" {
+ if c.PropertyName() == "max_target_q" {
expectedMaxTargetQPaths = []string{"my-new-max-target-q.txt"}
}
- android.AssertPathsRelativeToTopEquals(t, c.PropertyName, expectedMaxTargetQPaths, info.FlagFilesByCategory[c])
+ android.AssertPathsRelativeToTopEquals(t, c.PropertyName(), expectedMaxTargetQPaths, info.FlagFilesByCategory[c])
}
// Make sure that the signature-patterns.csv is passed all the appropriate package properties
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 3c7cf3a..e4beb5e 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -435,122 +435,118 @@
}
}
-type hiddenAPIFlagFileCategory struct {
- // PropertyName is the name of the property for this category.
- PropertyName string
+type hiddenAPIFlagFileCategory int
- // propertyValueReader retrieves the value of the property for this category from the set of
- // properties.
- propertyValueReader func(properties *HiddenAPIFlagFileProperties) []string
+const (
+ // The flag file category for removed members of the API.
+ //
+ // This is extracted from HiddenAPIFlagFileCategories as it is needed to add the dex signatures
+ // list of removed API members that are generated automatically from the removed.txt files provided
+ // by API stubs.
+ hiddenAPIFlagFileCategoryRemoved hiddenAPIFlagFileCategory = iota
+ hiddenAPIFlagFileCategoryUnsupported
+ hiddenAPIFlagFileCategoryMaxTargetRLowPriority
+ hiddenAPIFlagFileCategoryMaxTargetQ
+ hiddenAPIFlagFileCategoryMaxTargetP
+ hiddenAPIFlagFileCategoryMaxTargetOLowPriority
+ hiddenAPIFlagFileCategoryBlocked
+ hiddenAPIFlagFileCategoryUnsupportedPackages
+)
- // commandMutator adds the appropriate command line options for this category to the supplied
- // command
- commandMutator func(command *android.RuleBuilderCommand, path android.Path)
-}
-
-// The flag file category for removed members of the API.
-//
-// This is extracted from HiddenAPIFlagFileCategories as it is needed to add the dex signatures
-// list of removed API members that are generated automatically from the removed.txt files provided
-// by API stubs.
-var hiddenAPIRemovedFlagFileCategory = &hiddenAPIFlagFileCategory{
- // See HiddenAPIFlagFileProperties.Removed
- PropertyName: "removed",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Removed
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--unsupported ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "removed")
- },
-}
-
-type hiddenAPIFlagFileCategories []*hiddenAPIFlagFileCategory
-
-func (c hiddenAPIFlagFileCategories) byProperty(name string) *hiddenAPIFlagFileCategory {
- for _, category := range c {
- if category.PropertyName == name {
- return category
- }
+func (c hiddenAPIFlagFileCategory) PropertyName() string {
+ switch c {
+ case hiddenAPIFlagFileCategoryRemoved:
+ return "removed"
+ case hiddenAPIFlagFileCategoryUnsupported:
+ return "unsupported"
+ case hiddenAPIFlagFileCategoryMaxTargetRLowPriority:
+ return "max_target_r_low_priority"
+ case hiddenAPIFlagFileCategoryMaxTargetQ:
+ return "max_target_q"
+ case hiddenAPIFlagFileCategoryMaxTargetP:
+ return "max_target_p"
+ case hiddenAPIFlagFileCategoryMaxTargetOLowPriority:
+ return "max_target_o_low_priority"
+ case hiddenAPIFlagFileCategoryBlocked:
+ return "blocked"
+ case hiddenAPIFlagFileCategoryUnsupportedPackages:
+ return "unsupported_packages"
+ default:
+ panic(fmt.Sprintf("Unknown hidden api flag file category type: %d", c))
}
- panic(fmt.Errorf("no category exists with property name %q in %v", name, c))
}
+// propertyValueReader retrieves the value of the property for this category from the set of properties.
+func (c hiddenAPIFlagFileCategory) propertyValueReader(properties *HiddenAPIFlagFileProperties) []string {
+ switch c {
+ case hiddenAPIFlagFileCategoryRemoved:
+ return properties.Hidden_api.Removed
+ case hiddenAPIFlagFileCategoryUnsupported:
+ return properties.Hidden_api.Unsupported
+ case hiddenAPIFlagFileCategoryMaxTargetRLowPriority:
+ return properties.Hidden_api.Max_target_r_low_priority
+ case hiddenAPIFlagFileCategoryMaxTargetQ:
+ return properties.Hidden_api.Max_target_q
+ case hiddenAPIFlagFileCategoryMaxTargetP:
+ return properties.Hidden_api.Max_target_p
+ case hiddenAPIFlagFileCategoryMaxTargetOLowPriority:
+ return properties.Hidden_api.Max_target_o_low_priority
+ case hiddenAPIFlagFileCategoryBlocked:
+ return properties.Hidden_api.Blocked
+ case hiddenAPIFlagFileCategoryUnsupportedPackages:
+ return properties.Hidden_api.Unsupported_packages
+ default:
+ panic(fmt.Sprintf("Unknown hidden api flag file category type: %d", c))
+ }
+}
+
+// commandMutator adds the appropriate command line options for this category to the supplied command
+func (c hiddenAPIFlagFileCategory) commandMutator(command *android.RuleBuilderCommand, path android.Path) {
+ switch c {
+ case hiddenAPIFlagFileCategoryRemoved:
+ command.FlagWithInput("--unsupported ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "removed")
+ case hiddenAPIFlagFileCategoryUnsupported:
+ command.FlagWithInput("--unsupported ", path)
+ case hiddenAPIFlagFileCategoryMaxTargetRLowPriority:
+ command.FlagWithInput("--max-target-r ", path).FlagWithArg("--tag ", "lo-prio")
+ case hiddenAPIFlagFileCategoryMaxTargetQ:
+ command.FlagWithInput("--max-target-q ", path)
+ case hiddenAPIFlagFileCategoryMaxTargetP:
+ command.FlagWithInput("--max-target-p ", path)
+ case hiddenAPIFlagFileCategoryMaxTargetOLowPriority:
+ command.FlagWithInput("--max-target-o ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "lo-prio")
+ case hiddenAPIFlagFileCategoryBlocked:
+ command.FlagWithInput("--blocked ", path)
+ case hiddenAPIFlagFileCategoryUnsupportedPackages:
+ command.FlagWithInput("--unsupported ", path).Flag("--packages ")
+ default:
+ panic(fmt.Sprintf("Unknown hidden api flag file category type: %d", c))
+ }
+}
+
+type hiddenAPIFlagFileCategories []hiddenAPIFlagFileCategory
+
var HiddenAPIFlagFileCategories = hiddenAPIFlagFileCategories{
// See HiddenAPIFlagFileProperties.Unsupported
- {
- PropertyName: "unsupported",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Unsupported
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--unsupported ", path)
- },
- },
- hiddenAPIRemovedFlagFileCategory,
+ hiddenAPIFlagFileCategoryUnsupported,
+ // See HiddenAPIFlagFileProperties.Removed
+ hiddenAPIFlagFileCategoryRemoved,
// See HiddenAPIFlagFileProperties.Max_target_r_low_priority
- {
- PropertyName: "max_target_r_low_priority",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Max_target_r_low_priority
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--max-target-r ", path).FlagWithArg("--tag ", "lo-prio")
- },
- },
+ hiddenAPIFlagFileCategoryMaxTargetRLowPriority,
// See HiddenAPIFlagFileProperties.Max_target_q
- {
- PropertyName: "max_target_q",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Max_target_q
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--max-target-q ", path)
- },
- },
+ hiddenAPIFlagFileCategoryMaxTargetQ,
// See HiddenAPIFlagFileProperties.Max_target_p
- {
- PropertyName: "max_target_p",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Max_target_p
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--max-target-p ", path)
- },
- },
+ hiddenAPIFlagFileCategoryMaxTargetP,
// See HiddenAPIFlagFileProperties.Max_target_o_low_priority
- {
- PropertyName: "max_target_o_low_priority",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Max_target_o_low_priority
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--max-target-o ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "lo-prio")
- },
- },
+ hiddenAPIFlagFileCategoryMaxTargetOLowPriority,
// See HiddenAPIFlagFileProperties.Blocked
- {
- PropertyName: "blocked",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Blocked
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--blocked ", path)
- },
- },
+ hiddenAPIFlagFileCategoryBlocked,
// See HiddenAPIFlagFileProperties.Unsupported_packages
- {
- PropertyName: "unsupported_packages",
- propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
- return properties.Hidden_api.Unsupported_packages
- },
- commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
- command.FlagWithInput("--unsupported ", path).Flag("--packages ")
- },
- },
+ hiddenAPIFlagFileCategoryUnsupportedPackages,
}
// FlagFilesByCategory maps a hiddenAPIFlagFileCategory to the paths to the files in that category.
-type FlagFilesByCategory map[*hiddenAPIFlagFileCategory]android.Paths
+type FlagFilesByCategory map[hiddenAPIFlagFileCategory]android.Paths
// append the supplied flags files to the corresponding category in this map.
func (s FlagFilesByCategory) append(other FlagFilesByCategory) {
@@ -1014,7 +1010,7 @@
// If available then pass the automatically generated file containing dex signatures of removed
// API members to the rule so they can be marked as removed.
if generatedRemovedDexSignatures.Valid() {
- hiddenAPIRemovedFlagFileCategory.commandMutator(command, generatedRemovedDexSignatures.Path())
+ hiddenAPIFlagFileCategoryRemoved.commandMutator(command, generatedRemovedDexSignatures.Path())
}
commitChangeForRestat(rule, tempPath, outputPath)
diff --git a/java/java.go b/java/java.go
index 10e9234..cd249ed 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1084,7 +1084,7 @@
return true
}
-func (j *TestHost) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
+func (j *TestHost) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
return ctx.DeviceConfig().NativeCoverageEnabled()
}
@@ -1837,6 +1837,7 @@
func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
apiContributions := al.properties.Api_contributions
addValidations := !ctx.Config().IsEnvTrue("DISABLE_STUB_VALIDATION") &&
+ !ctx.Config().IsEnvTrue("WITHOUT_CHECK_API") &&
proptools.BoolDefault(al.properties.Enable_validation, true)
for _, apiContributionName := range apiContributions {
ctx.AddDependency(ctx.Module(), javaApiContributionTag, apiContributionName)
@@ -2089,6 +2090,11 @@
// that depend on this module, as well as to aidl for this module.
Export_include_dirs []string
}
+
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
}
type Import struct {
@@ -2162,12 +2168,16 @@
return j.properties.Jars
}
+func (j *Import) BaseModuleName() string {
+ return proptools.StringDefault(j.properties.Source_module_name, j.ModuleBase.Name())
+}
+
func (j *Import) Name() string {
return j.prebuilt.Name(j.ModuleBase.Name())
}
func (j *Import) Stem() string {
- return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name())
+ return proptools.StringDefault(j.properties.Stem, j.BaseModuleName())
}
func (a *Import) JacocoReportClassesFile() android.Path {
diff --git a/java/java_test.go b/java/java_test.go
index 0891ab6..42301d8 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -24,6 +24,7 @@
"strings"
"testing"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/aconfig"
@@ -2521,3 +2522,105 @@
apiScopePublic.stubsLibraryModuleName("foo"), "android_common",
apiScopePublic.apiLibraryModuleName("foo")))
}
+
+func TestMultiplePrebuilts(t *testing.T) {
+ bp := `
+ // an rdep
+ java_library {
+ name: "foo",
+ libs: ["bar"],
+ }
+
+ // multiple variations of dep
+ // source
+ java_library {
+ name: "bar",
+ srcs: ["bar.java"],
+ }
+ // prebuilt "v1"
+ java_import {
+ name: "bar",
+ jars: ["bar.jar"],
+ }
+ // prebuilt "v2"
+ java_import {
+ name: "bar.v2",
+ source_module_name: "bar",
+ jars: ["bar.v1.jar"],
+ }
+
+ // selectors
+ apex_contributions {
+ name: "myapex_contributions",
+ contents: ["%v"],
+ }
+ `
+ hasDep := func(ctx *android.TestResult, m android.Module, wantDep android.Module) bool {
+ t.Helper()
+ var found bool
+ ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
+ if dep == wantDep {
+ found = true
+ }
+ })
+ return found
+ }
+
+ hasFileWithStem := func(m android.TestingModule, stem string) bool {
+ t.Helper()
+ for _, o := range m.AllOutputs() {
+ _, file := filepath.Split(o)
+ if file == stem+".jar" {
+ return true
+ }
+ }
+ return false
+ }
+
+ testCases := []struct {
+ desc string
+ selectedDependencyName string
+ expectedDependencyName string
+ }{
+ {
+ desc: "Source library is selected using apex_contributions",
+ selectedDependencyName: "bar",
+ expectedDependencyName: "bar",
+ },
+ {
+ desc: "Prebuilt library v1 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_bar",
+ expectedDependencyName: "prebuilt_bar",
+ },
+ {
+ desc: "Prebuilt library v2 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_bar.v2",
+ expectedDependencyName: "prebuilt_bar.v2",
+ },
+ }
+
+ for _, tc := range testCases {
+ ctx := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
+ }
+ }),
+ ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName))
+
+ // check that rdep gets the correct variation of dep
+ foo := ctx.ModuleForTests("foo", "android_common")
+ expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_common")
+ android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", foo.Module().Name(), tc.expectedDependencyName), true, hasDep(ctx, foo.Module(), expectedDependency.Module()))
+
+ // check that output file of dep is always bar.jar
+ // The filename should be agnostic to source/prebuilt/prebuilt_version
+ android.AssertBoolEquals(t, fmt.Sprintf("could not find bar.jar in outputs of %s. All Outputs %v\n", tc.expectedDependencyName, expectedDependency.AllOutputs()), true, hasFileWithStem(expectedDependency, "bar"))
+
+ // check LOCAL_MODULE of the selected module name
+ // the prebuilt should have the same LOCAL_MODULE when exported to make
+ entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, expectedDependency.Module())[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "bar", entries.EntryMap["LOCAL_MODULE"][0])
+ }
+}
diff --git a/java/lint.go b/java/lint.go
index c3d723b..31e7f35 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -370,6 +370,12 @@
return
}
+ for _, flag := range l.properties.Lint.Flags {
+ if strings.Contains(flag, "--disable") || strings.Contains(flag, "--enable") || strings.Contains(flag, "--check") {
+ ctx.PropertyErrorf("lint.flags", "Don't use --disable, --enable, or --check in the flags field, instead use the dedicated disabled_checks, warning_checks, error_checks, or fatal_checks fields")
+ }
+ }
+
if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 {
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
// Skip lint warning checks for NewApi warnings for libcore where they come from source
diff --git a/java/lint_test.go b/java/lint_test.go
index b7e6aad..751b139 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -260,3 +260,22 @@
}
}
}
+
+func TestCantControlCheckSeverityWithFlags(t *testing.T) {
+ bp := `
+ java_library {
+ name: "foo",
+ srcs: [
+ "a.java",
+ ],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ flags: ["--disabled", "NewApi"],
+ },
+ }
+ `
+ PrepareForTestWithJavaDefaultModules.
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Don't use --disable, --enable, or --check in the flags field, instead use the dedicated disabled_checks, warning_checks, error_checks, or fatal_checks fields")).
+ RunTestWithBp(t, bp)
+}
diff --git a/rust/rust.go b/rust/rust.go
index 34ce4c5..245ed2e 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -535,7 +535,7 @@
var _ cc.Coverage = (*Module)(nil)
-func (mod *Module) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
+func (mod *Module) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
return mod.coverage != nil && mod.coverage.Properties.NeedCoverageVariant
}
diff --git a/testing/code_metadata_proto/Android.bp b/testing/code_metadata_proto/Android.bp
index 8fcca19..f07efff 100644
--- a/testing/code_metadata_proto/Android.bp
+++ b/testing/code_metadata_proto/Android.bp
@@ -20,10 +20,24 @@
name: "soong-testing-code_metadata_proto",
pkgPath: "android/soong/testing/code_metadata_proto",
deps: [
- "golang-protobuf-reflect-protoreflect",
- "golang-protobuf-runtime-protoimpl",
- ],
+ "golang-protobuf-reflect-protoreflect",
+ "golang-protobuf-runtime-protoimpl",
+ ],
srcs: [
"code_metadata.pb.go",
],
}
+
+python_library_host {
+ name: "code-metadata-proto-py",
+ pkg_path: "code_metadata",
+ srcs: [
+ "code_metadata.proto",
+ ],
+ libs: [
+ "libprotobuf-python",
+ ],
+ proto: {
+ canonical_path_from_root: false,
+ },
+}
diff --git a/testing/test_spec_proto/Android.bp b/testing/test_spec_proto/Android.bp
index 1cac492..d5ad70b 100644
--- a/testing/test_spec_proto/Android.bp
+++ b/testing/test_spec_proto/Android.bp
@@ -20,10 +20,24 @@
name: "soong-testing-test_spec_proto",
pkgPath: "android/soong/testing/test_spec_proto",
deps: [
- "golang-protobuf-reflect-protoreflect",
- "golang-protobuf-runtime-protoimpl",
- ],
+ "golang-protobuf-reflect-protoreflect",
+ "golang-protobuf-runtime-protoimpl",
+ ],
srcs: [
"test_spec.pb.go",
],
}
+
+python_library_host {
+ name: "test-spec-proto-py",
+ pkg_path: "test_spec",
+ srcs: [
+ "test_spec.proto",
+ ],
+ libs: [
+ "libprotobuf-python",
+ ],
+ proto: {
+ canonical_path_from_root: false,
+ },
+}