Merge "Fix stem to be propagated to output jar name in java_library" into main am: ef5d8278be
am: 258edea6f6
am: 70de94a1e0
am: 0f00e9c056
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2646424 Change-Id: I3db0c15c53e3b1ca4cb7d9a355b2a07a2139888c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -611,6 +611,8 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
|
|
||||||
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
|
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
|
||||||
|
|
||||||
|
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
ctx.CheckbuildFile(a.proguardOptionsFile)
|
ctx.CheckbuildFile(a.proguardOptionsFile)
|
||||||
ctx.CheckbuildFile(a.exportPackage)
|
ctx.CheckbuildFile(a.exportPackage)
|
||||||
ctx.CheckbuildFile(a.aaptSrcJar)
|
ctx.CheckbuildFile(a.aaptSrcJar)
|
||||||
|
@@ -455,11 +455,6 @@ func (a *AndroidApp) getOverriddenPackages() []string {
|
|||||||
if len(a.overridableAppProperties.Overrides) > 0 {
|
if len(a.overridableAppProperties.Overrides) > 0 {
|
||||||
overridden = append(overridden, a.overridableAppProperties.Overrides...)
|
overridden = append(overridden, a.overridableAppProperties.Overrides...)
|
||||||
}
|
}
|
||||||
// When APK name is overridden via PRODUCT_PACKAGE_NAME_OVERRIDES
|
|
||||||
// ensure that the original name is overridden.
|
|
||||||
if a.Stem() != a.installApkName {
|
|
||||||
overridden = append(overridden, a.Stem())
|
|
||||||
}
|
|
||||||
return overridden
|
return overridden
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
java/app.go
11
java/app.go
@@ -666,8 +666,17 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
a.aapt.useEmbeddedNativeLibs = a.useEmbeddedNativeLibs(ctx)
|
a.aapt.useEmbeddedNativeLibs = a.useEmbeddedNativeLibs(ctx)
|
||||||
a.aapt.useEmbeddedDex = Bool(a.appProperties.Use_embedded_dex)
|
a.aapt.useEmbeddedDex = Bool(a.appProperties.Use_embedded_dex)
|
||||||
|
|
||||||
|
// Unlike installApkName, a.stem should respect base module name for override_android_app.
|
||||||
|
// Therefore, use ctx.ModuleName() instead of a.Name().
|
||||||
|
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
// Check if the install APK name needs to be overridden.
|
// Check if the install APK name needs to be overridden.
|
||||||
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(a.Stem())
|
// Both android_app and override_android_app module are expected to possess
|
||||||
|
// its module bound apk path. However, override_android_app inherits ctx.ModuleName()
|
||||||
|
// from the base module. Therefore, use a.Name() which represents
|
||||||
|
// the module name for both android_app and override_android_app.
|
||||||
|
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(
|
||||||
|
proptools.StringDefault(a.overridableDeviceProperties.Stem, a.Name()))
|
||||||
|
|
||||||
if ctx.ModuleName() == "framework-res" {
|
if ctx.ModuleName() == "framework-res" {
|
||||||
// framework-res.apk is installed as system/framework/framework-res.apk
|
// framework-res.apk is installed as system/framework/framework-res.apk
|
||||||
|
13
java/base.go
13
java/base.go
@@ -21,6 +21,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/ui/metrics/bp2build_metrics_proto"
|
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||||
|
|
||||||
"github.com/google/blueprint/pathtools"
|
"github.com/google/blueprint/pathtools"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
@@ -502,6 +503,11 @@ type Module struct {
|
|||||||
sourceExtensions []string
|
sourceExtensions []string
|
||||||
|
|
||||||
annoSrcJars android.Paths
|
annoSrcJars android.Paths
|
||||||
|
|
||||||
|
// output file name based on Stem property.
|
||||||
|
// This should be set in every ModuleWithStem's GenerateAndroidBuildActions
|
||||||
|
// or the module should override Stem().
|
||||||
|
stem string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
||||||
@@ -1099,7 +1105,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
||||||
}
|
}
|
||||||
|
|
||||||
jarName := ctx.ModuleName() + ".jar"
|
jarName := j.Stem() + ".jar"
|
||||||
|
|
||||||
var uniqueJavaFiles android.Paths
|
var uniqueJavaFiles android.Paths
|
||||||
set := make(map[string]bool)
|
set := make(map[string]bool)
|
||||||
@@ -1897,7 +1903,10 @@ func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) Stem() string {
|
func (j *Module) Stem() string {
|
||||||
return proptools.StringDefault(j.overridableDeviceProperties.Stem, j.Name())
|
if j.stem == "" {
|
||||||
|
panic("Stem() called before stem property was set")
|
||||||
|
}
|
||||||
|
return j.stem
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) JacocoReportClassesFile() android.Path {
|
func (j *Module) JacocoReportClassesFile() android.Path {
|
||||||
|
@@ -676,6 +676,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.minSdkVersion = j.MinSdkVersion(ctx)
|
j.minSdkVersion = j.MinSdkVersion(ctx)
|
||||||
j.maxSdkVersion = j.MaxSdkVersion(ctx)
|
j.maxSdkVersion = j.MaxSdkVersion(ctx)
|
||||||
|
|
||||||
|
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||||
if !apexInfo.IsForPlatform() {
|
if !apexInfo.IsForPlatform() {
|
||||||
j.hideApexVariantFromMake = true
|
j.hideApexVariantFromMake = true
|
||||||
@@ -1468,6 +1470,8 @@ func (j *Binary) HostToolPath() android.OptionalPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
if ctx.Arch().ArchType == android.Common {
|
if ctx.Arch().ArchType == android.Common {
|
||||||
// Compile the jar
|
// Compile the jar
|
||||||
if j.binaryProperties.Main_class != nil {
|
if j.binaryProperties.Main_class != nil {
|
||||||
|
@@ -2351,3 +2351,22 @@ func TestJavaExcludeStaticLib(t *testing.T) {
|
|||||||
`stable.core.platform.api.stubs`,
|
`stable.core.platform.api.stubs`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaLibraryWithResourcesStem(t *testing.T) {
|
||||||
|
ctx, _ := testJavaWithFS(t, `
|
||||||
|
java_library {
|
||||||
|
name: "foo",
|
||||||
|
java_resource_dirs: ["test-jar"],
|
||||||
|
stem: "test",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
map[string][]byte{
|
||||||
|
"test-jar/test/resource.txt": nil,
|
||||||
|
})
|
||||||
|
|
||||||
|
m := ctx.ModuleForTests("foo", "android_common")
|
||||||
|
outputs := fmt.Sprint(m.AllOutputs())
|
||||||
|
if !strings.Contains(outputs, "test.jar") {
|
||||||
|
t.Errorf("Module output does not contain expected jar %s", "test.jar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user