Change java stem attribute for both device and host
Bug: 329762127 Test: cd build/soong/java ; go test -run TestJavaLibHostWithStem Test: cd build/soong/java ; go test -run TestAppStem Test: cd build/soong/java ; go test -run TestAndroidAppImport_ArchVariants Test: cd build/soong/java ; go test -run TestOverrideAndroidAppStem Test: cd build/soong/java ; go test -run TestOverrideAndroidApp Test: cd build/soong/java ; go test -run TestPackageNameOverride Change-Id: I8fbdc82116f9a0c68121fbbeb1ef4f78f2b6fea3
This commit is contained in:
@@ -823,7 +823,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||||
a.hideApexVariantFromMake = !apexInfo.IsForPlatform()
|
a.hideApexVariantFromMake = !apexInfo.IsForPlatform()
|
||||||
|
|
||||||
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
|
a.stem = proptools.StringDefault(a.overridableProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
ctx.CheckbuildFile(a.aapt.proguardOptionsFile)
|
ctx.CheckbuildFile(a.aapt.proguardOptionsFile)
|
||||||
ctx.CheckbuildFile(a.aapt.exportPackage)
|
ctx.CheckbuildFile(a.aapt.exportPackage)
|
||||||
|
@@ -755,7 +755,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
// Unlike installApkName, a.stem should respect base module name for override_android_app.
|
// Unlike installApkName, a.stem should respect base module name for override_android_app.
|
||||||
// Therefore, use ctx.ModuleName() instead of a.Name().
|
// Therefore, use ctx.ModuleName() instead of a.Name().
|
||||||
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
|
a.stem = proptools.StringDefault(a.overridableProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
// Check if the install APK name needs to be overridden.
|
// Check if the install APK name needs to be overridden.
|
||||||
// Both android_app and override_android_app module are expected to possess
|
// Both android_app and override_android_app module are expected to possess
|
||||||
@@ -763,7 +763,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// from the base module. Therefore, use a.Name() which represents
|
// from the base module. Therefore, use a.Name() which represents
|
||||||
// the module name for both android_app and override_android_app.
|
// the module name for both android_app and override_android_app.
|
||||||
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(
|
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(
|
||||||
proptools.StringDefault(a.overridableDeviceProperties.Stem, a.Name()))
|
proptools.StringDefault(a.overridableProperties.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
|
||||||
@@ -1500,7 +1500,7 @@ func (i *OverrideAndroidApp) GenerateAndroidBuildActions(_ android.ModuleContext
|
|||||||
func OverrideAndroidAppModuleFactory() android.Module {
|
func OverrideAndroidAppModuleFactory() android.Module {
|
||||||
m := &OverrideAndroidApp{}
|
m := &OverrideAndroidApp{}
|
||||||
m.AddProperties(
|
m.AddProperties(
|
||||||
&OverridableDeviceProperties{},
|
&OverridableProperties{},
|
||||||
&overridableAppProperties{},
|
&overridableAppProperties{},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -4401,3 +4401,20 @@ func TestNoDexpreoptOptionalUsesLibDoesNotHaveImpl(t *testing.T) {
|
|||||||
dexpreopt := result.ModuleForTests("app", "android_common").MaybeRule("dexpreopt").Rule
|
dexpreopt := result.ModuleForTests("app", "android_common").MaybeRule("dexpreopt").Rule
|
||||||
android.AssertBoolEquals(t, "dexpreopt should be disabled if optional_uses_libs does not have an implementation", true, dexpreopt == nil)
|
android.AssertBoolEquals(t, "dexpreopt should be disabled if optional_uses_libs does not have an implementation", true, dexpreopt == nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAppStem(t *testing.T) {
|
||||||
|
ctx := testApp(t, `
|
||||||
|
android_app {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
stem: "foo-new",
|
||||||
|
sdk_version: "current",
|
||||||
|
}`)
|
||||||
|
|
||||||
|
foo := ctx.ModuleForTests("foo", "android_common")
|
||||||
|
|
||||||
|
outputs := fmt.Sprint(foo.AllOutputs())
|
||||||
|
if !strings.Contains(outputs, "foo-new.apk") {
|
||||||
|
t.Errorf("Module output does not contain expected apk %s", "foo-new.apk")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -303,8 +303,8 @@ type DeviceProperties struct {
|
|||||||
HiddenAPIFlagFileProperties
|
HiddenAPIFlagFileProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device properties that can be overridden by overriding module (e.g. override_android_app)
|
// Properties that can be overridden by overriding module (e.g. override_android_app)
|
||||||
type OverridableDeviceProperties struct {
|
type OverridableProperties struct {
|
||||||
// set the name of the output. If not set, `name` is used.
|
// set the name of the output. If not set, `name` is used.
|
||||||
// To override a module with this property set, overriding module might need to set this as well.
|
// To override a module with this property set, overriding module might need to set this as well.
|
||||||
// Otherwise, both the overridden and the overriding modules will have the same output name, which
|
// Otherwise, both the overridden and the overriding modules will have the same output name, which
|
||||||
@@ -432,7 +432,7 @@ type Module struct {
|
|||||||
protoProperties android.ProtoProperties
|
protoProperties android.ProtoProperties
|
||||||
deviceProperties DeviceProperties
|
deviceProperties DeviceProperties
|
||||||
|
|
||||||
overridableDeviceProperties OverridableDeviceProperties
|
overridableProperties OverridableProperties
|
||||||
|
|
||||||
// jar file containing header classes including static library dependencies, suitable for
|
// jar file containing header classes including static library dependencies, suitable for
|
||||||
// inserting into the bootclasspath/classpath of another compile
|
// inserting into the bootclasspath/classpath of another compile
|
||||||
@@ -614,6 +614,7 @@ func (j *Module) checkHeadersOnly(ctx android.ModuleContext) {
|
|||||||
func (j *Module) addHostProperties() {
|
func (j *Module) addHostProperties() {
|
||||||
j.AddProperties(
|
j.AddProperties(
|
||||||
&j.properties,
|
&j.properties,
|
||||||
|
&j.overridableProperties,
|
||||||
&j.protoProperties,
|
&j.protoProperties,
|
||||||
&j.usesLibraryProperties,
|
&j.usesLibraryProperties,
|
||||||
)
|
)
|
||||||
@@ -623,7 +624,6 @@ func (j *Module) addHostAndDeviceProperties() {
|
|||||||
j.addHostProperties()
|
j.addHostProperties()
|
||||||
j.AddProperties(
|
j.AddProperties(
|
||||||
&j.deviceProperties,
|
&j.deviceProperties,
|
||||||
&j.overridableDeviceProperties,
|
|
||||||
&j.dexer.dexProperties,
|
&j.dexer.dexProperties,
|
||||||
&j.dexpreoptProperties,
|
&j.dexpreoptProperties,
|
||||||
&j.linter.properties,
|
&j.linter.properties,
|
||||||
|
@@ -889,7 +889,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
|
j.stem = proptools.StringDefault(j.overridableProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
proguardSpecInfo := j.collectProguardSpecInfo(ctx)
|
proguardSpecInfo := j.collectProguardSpecInfo(ctx)
|
||||||
android.SetProvider(ctx, ProguardSpecInfoProvider, proguardSpecInfo)
|
android.SetProvider(ctx, ProguardSpecInfoProvider, proguardSpecInfo)
|
||||||
@@ -1686,7 +1686,7 @@ 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())
|
j.stem = proptools.StringDefault(j.overridableProperties.Stem, ctx.ModuleName())
|
||||||
|
|
||||||
if ctx.Arch().ArchType == android.Common {
|
if ctx.Arch().ArchType == android.Common {
|
||||||
// Compile the jar
|
// Compile the jar
|
||||||
@@ -2997,7 +2997,7 @@ func DefaultsFactory() android.Module {
|
|||||||
module.AddProperties(
|
module.AddProperties(
|
||||||
&CommonProperties{},
|
&CommonProperties{},
|
||||||
&DeviceProperties{},
|
&DeviceProperties{},
|
||||||
&OverridableDeviceProperties{},
|
&OverridableProperties{},
|
||||||
&DexProperties{},
|
&DexProperties{},
|
||||||
&DexpreoptProperties{},
|
&DexpreoptProperties{},
|
||||||
&android.ProtoProperties{},
|
&android.ProtoProperties{},
|
||||||
|
@@ -2693,3 +2693,38 @@ func TestApiLibraryAconfigDeclarations(t *testing.T) {
|
|||||||
cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
|
cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
|
||||||
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt")
|
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaLibHostWithStem(t *testing.T) {
|
||||||
|
ctx, _ := testJava(t, `
|
||||||
|
java_library_host {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
stem: "foo-new",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
foo := ctx.ModuleForTests("foo", buildOS+"_common")
|
||||||
|
|
||||||
|
outputs := fmt.Sprint(foo.AllOutputs())
|
||||||
|
if !strings.Contains(outputs, "foo-new.jar") {
|
||||||
|
t.Errorf("Module output does not contain expected jar %s", "foo-new.jar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJavaLibWithStem(t *testing.T) {
|
||||||
|
ctx, _ := testJava(t, `
|
||||||
|
java_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
stem: "foo-new",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
foo := ctx.ModuleForTests("foo", "android_common")
|
||||||
|
|
||||||
|
outputs := fmt.Sprint(foo.AllOutputs())
|
||||||
|
if !strings.Contains(outputs, "foo-new.jar") {
|
||||||
|
t.Errorf("Module output does not contain expected jar %s", "foo-new.jar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user