Add property Exportable to aconfig_declarations
Only when aconfig_declarations explicitly set this property true, its flags will be repackaged. If a java_aconfig_library has mode "exported", its corresponding aconfig_declarations must have exportable prop set to true. Test: Added unit tests and CI Bug: 310504781 Ignore-AOSP-First: this change will be cherry picked to aosp (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e4527f3010b3fd6f33948a15a9b4fdc944da34f0) Merged-In: Ie9526e3755a6e7d142b377d5dd85a1bc60ffabc5 Change-Id: Ie9526e3755a6e7d142b377d5dd85a1bc60ffabc5
This commit is contained in:
committed by
Android Build Cherrypicker Worker
parent
62e3c24757
commit
0e5d16c6f0
@@ -40,6 +40,9 @@ type DeclarationsModule struct {
|
|||||||
|
|
||||||
// Container(system/vendor/apex) that this module belongs to
|
// Container(system/vendor/apex) that this module belongs to
|
||||||
Container string
|
Container string
|
||||||
|
|
||||||
|
// The flags will only be repackaged if this prop is true.
|
||||||
|
Exportable bool
|
||||||
}
|
}
|
||||||
|
|
||||||
intermediatePath android.WritablePath
|
intermediatePath android.WritablePath
|
||||||
@@ -159,6 +162,7 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
|
|||||||
android.SetProvider(ctx, android.AconfigDeclarationsProviderKey, android.AconfigDeclarationsProviderData{
|
android.SetProvider(ctx, android.AconfigDeclarationsProviderKey, android.AconfigDeclarationsProviderData{
|
||||||
Package: module.properties.Package,
|
Package: module.properties.Package,
|
||||||
Container: module.properties.Container,
|
Container: module.properties.Container,
|
||||||
|
Exportable: module.properties.Exportable,
|
||||||
IntermediateCacheOutputPath: intermediateCacheFilePath,
|
IntermediateCacheOutputPath: intermediateCacheFilePath,
|
||||||
IntermediateDumpOutputPath: intermediateDumpFilePath,
|
IntermediateDumpOutputPath: intermediateDumpFilePath,
|
||||||
})
|
})
|
||||||
|
@@ -27,6 +27,7 @@ func TestAconfigDeclarations(t *testing.T) {
|
|||||||
name: "module_name",
|
name: "module_name",
|
||||||
package: "com.example.package",
|
package: "com.example.package",
|
||||||
container: "com.android.foo",
|
container: "com.android.foo",
|
||||||
|
exportable: true,
|
||||||
srcs: [
|
srcs: [
|
||||||
"foo.aconfig",
|
"foo.aconfig",
|
||||||
"bar.aconfig",
|
"bar.aconfig",
|
||||||
@@ -41,6 +42,7 @@ func TestAconfigDeclarations(t *testing.T) {
|
|||||||
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
|
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
|
||||||
android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
|
android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
|
||||||
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
|
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
|
||||||
|
android.AssertBoolEquals(t, "exportable", depData.Exportable, true)
|
||||||
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
|
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
|
||||||
t.Errorf("Missing intermediates proto path in provider: %s", depData.IntermediateCacheOutputPath.String())
|
t.Errorf("Missing intermediates proto path in provider: %s", depData.IntermediateCacheOutputPath.String())
|
||||||
}
|
}
|
||||||
@@ -48,3 +50,22 @@ func TestAconfigDeclarations(t *testing.T) {
|
|||||||
t.Errorf("Missing intermediates text path in provider: %s", depData.IntermediateDumpOutputPath.String())
|
t.Errorf("Missing intermediates text path in provider: %s", depData.IntermediateDumpOutputPath.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAconfigDeclarationsWithExportableUnset(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
aconfig_declarations {
|
||||||
|
name: "module_name",
|
||||||
|
package: "com.example.package",
|
||||||
|
container: "com.android.foo",
|
||||||
|
srcs: [
|
||||||
|
"foo.aconfig",
|
||||||
|
"bar.aconfig",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`
|
||||||
|
result := runTest(t, android.FixtureExpectsNoErrors, bp)
|
||||||
|
|
||||||
|
module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
|
||||||
|
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
|
||||||
|
android.AssertBoolEquals(t, "exportable", depData.Exportable, false)
|
||||||
|
}
|
||||||
|
@@ -91,6 +91,12 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
|
|||||||
if !isModeSupported(mode) {
|
if !isModeSupported(mode) {
|
||||||
ctx.PropertyErrorf("mode", "%q is not a supported mode", mode)
|
ctx.PropertyErrorf("mode", "%q is not a supported mode", mode)
|
||||||
}
|
}
|
||||||
|
// TODO: uncomment this part after internal clean up
|
||||||
|
//if mode == "exported" && !declarations.Exportable {
|
||||||
|
// // if mode is exported, the corresponding aconfig_declaration must mark its
|
||||||
|
// // exportable property true
|
||||||
|
// ctx.PropertyErrorf("mode", "exported mode requires its aconfig_declaration has exportable prop true")
|
||||||
|
//}
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: javaRule,
|
Rule: javaRule,
|
||||||
@@ -102,12 +108,15 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Mark our generated code as possibly needing jarjar repackaging
|
if declarations.Exportable {
|
||||||
// TODO: Maybe control this with a property?
|
// Mark our generated code as possibly needing jarjar repackaging
|
||||||
module.AddJarJarRenameRule(declarations.Package+".Flags", "")
|
// The repackaging only happens when the corresponding aconfig_declaration
|
||||||
module.AddJarJarRenameRule(declarations.Package+".FeatureFlags", "")
|
// has property exportable true
|
||||||
module.AddJarJarRenameRule(declarations.Package+".FeatureFlagsImpl", "")
|
module.AddJarJarRenameRule(declarations.Package+".Flags", "")
|
||||||
module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
|
module.AddJarJarRenameRule(declarations.Package+".FeatureFlags", "")
|
||||||
|
module.AddJarJarRenameRule(declarations.Package+".FeatureFlagsImpl", "")
|
||||||
|
module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
|
||||||
|
}
|
||||||
|
|
||||||
return srcJarPath
|
return srcJarPath
|
||||||
}
|
}
|
||||||
|
@@ -176,6 +176,7 @@ func testCodegenMode(t *testing.T, bpMode string, ruleMode string) {
|
|||||||
name: "my_aconfig_declarations",
|
name: "my_aconfig_declarations",
|
||||||
package: "com.example.package",
|
package: "com.example.package",
|
||||||
srcs: ["foo.aconfig"],
|
srcs: ["foo.aconfig"],
|
||||||
|
exportable: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
|
@@ -35,6 +35,7 @@ var (
|
|||||||
type AconfigDeclarationsProviderData struct {
|
type AconfigDeclarationsProviderData struct {
|
||||||
Package string
|
Package string
|
||||||
Container string
|
Container string
|
||||||
|
Exportable bool
|
||||||
IntermediateCacheOutputPath WritablePath
|
IntermediateCacheOutputPath WritablePath
|
||||||
IntermediateDumpOutputPath WritablePath
|
IntermediateDumpOutputPath WritablePath
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user