Merge "Change java stem attribute for both device and host" into main
This commit is contained in:
commit
064b145365
6 changed files with 63 additions and 11 deletions
|
@ -823,7 +823,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||
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.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.
|
||||
// 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.
|
||||
// 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
|
||||
// the module name for both android_app and override_android_app.
|
||||
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(
|
||||
proptools.StringDefault(a.overridableDeviceProperties.Stem, a.Name()))
|
||||
proptools.StringDefault(a.overridableProperties.Stem, a.Name()))
|
||||
|
||||
if ctx.ModuleName() == "framework-res" {
|
||||
// framework-res.apk is installed as system/framework/framework-res.apk
|
||||
|
@ -1507,7 +1507,7 @@ func (i *OverrideAndroidApp) GenerateAndroidBuildActions(_ android.ModuleContext
|
|||
func OverrideAndroidAppModuleFactory() android.Module {
|
||||
m := &OverrideAndroidApp{}
|
||||
m.AddProperties(
|
||||
&OverridableDeviceProperties{},
|
||||
&OverridableProperties{},
|
||||
&overridableAppProperties{},
|
||||
)
|
||||
|
||||
|
|
|
@ -4401,3 +4401,20 @@ func TestNoDexpreoptOptionalUsesLibDoesNotHaveImpl(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,8 +305,8 @@ type DeviceProperties struct {
|
|||
HiddenAPIFlagFileProperties
|
||||
}
|
||||
|
||||
// Device properties that can be overridden by overriding module (e.g. override_android_app)
|
||||
type OverridableDeviceProperties struct {
|
||||
// Properties that can be overridden by overriding module (e.g. override_android_app)
|
||||
type OverridableProperties struct {
|
||||
// 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.
|
||||
// Otherwise, both the overridden and the overriding modules will have the same output name, which
|
||||
|
@ -434,7 +434,7 @@ type Module struct {
|
|||
protoProperties android.ProtoProperties
|
||||
deviceProperties DeviceProperties
|
||||
|
||||
overridableDeviceProperties OverridableDeviceProperties
|
||||
overridableProperties OverridableProperties
|
||||
|
||||
// jar file containing header classes including static library dependencies, suitable for
|
||||
// inserting into the bootclasspath/classpath of another compile
|
||||
|
@ -616,6 +616,7 @@ func (j *Module) checkHeadersOnly(ctx android.ModuleContext) {
|
|||
func (j *Module) addHostProperties() {
|
||||
j.AddProperties(
|
||||
&j.properties,
|
||||
&j.overridableProperties,
|
||||
&j.protoProperties,
|
||||
&j.usesLibraryProperties,
|
||||
)
|
||||
|
@ -625,7 +626,6 @@ func (j *Module) addHostAndDeviceProperties() {
|
|||
j.addHostProperties()
|
||||
j.AddProperties(
|
||||
&j.deviceProperties,
|
||||
&j.overridableDeviceProperties,
|
||||
&j.dexer.dexProperties,
|
||||
&j.dexpreoptProperties,
|
||||
&j.linter.properties,
|
||||
|
|
|
@ -901,7 +901,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)
|
||||
android.SetProvider(ctx, ProguardSpecInfoProvider, proguardSpecInfo)
|
||||
|
@ -1698,7 +1698,7 @@ func (j *Binary) HostToolPath() android.OptionalPath {
|
|||
}
|
||||
|
||||
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 {
|
||||
// Compile the jar
|
||||
|
@ -3009,7 +3009,7 @@ func DefaultsFactory() android.Module {
|
|||
module.AddProperties(
|
||||
&CommonProperties{},
|
||||
&DeviceProperties{},
|
||||
&OverridableDeviceProperties{},
|
||||
&OverridableProperties{},
|
||||
&DexProperties{},
|
||||
&DexpreoptProperties{},
|
||||
&android.ProtoProperties{},
|
||||
|
|
|
@ -2757,3 +2757,38 @@ func TestApiLibraryAconfigDeclarations(t *testing.T) {
|
|||
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")
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue