Merge "Add support for compat config in APEX." am: 86a5dc5575
am: a53ed40948
Change-Id: I55e4b749e2b4ea2910fbc8c77cb8c4637f07471d
This commit is contained in:
commit
085528a57a
10
apex/apex.go
10
apex/apex.go
|
@ -1194,6 +1194,12 @@ func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.Preb
|
||||||
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
|
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
|
||||||
|
dirInApex := filepath.Join("etc", config.SubDir())
|
||||||
|
fileToCopy := config.CompatConfig()
|
||||||
|
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
|
||||||
|
}
|
||||||
|
|
||||||
func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
|
func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
|
||||||
android.Module
|
android.Module
|
||||||
Privileged() bool
|
Privileged() bool
|
||||||
|
@ -1361,8 +1367,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
case prebuiltTag:
|
case prebuiltTag:
|
||||||
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
|
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
|
||||||
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
|
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
|
||||||
|
} else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
|
||||||
|
filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
|
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
|
||||||
}
|
}
|
||||||
case testTag:
|
case testTag:
|
||||||
if ccTest, ok := child.(*cc.Module); ok {
|
if ccTest, ok := child.(*cc.Module); ok {
|
||||||
|
|
|
@ -299,6 +299,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
|
||||||
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
|
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
|
||||||
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
|
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory)
|
ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory)
|
||||||
|
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
|
||||||
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
|
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
|
||||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||||
java.RegisterJavaBuildComponents(ctx)
|
java.RegisterJavaBuildComponents(ctx)
|
||||||
|
@ -3451,6 +3452,41 @@ func TestJavaSDKLibrary(t *testing.T) {
|
||||||
ensureContains(t, xml.Args["content"], `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
|
ensureContains(t, xml.Args["content"], `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCompatConfig(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
prebuilts: ["myjar-platform-compat-config"],
|
||||||
|
java_libs: ["myjar"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
platform_compat_config {
|
||||||
|
name: "myjar-platform-compat-config",
|
||||||
|
src: ":myjar",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "myjar",
|
||||||
|
srcs: ["foo/bar/MyClass.java"],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "none",
|
||||||
|
compile_dex: true,
|
||||||
|
apex_available: [ "myapex" ],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
|
"etc/compatconfig/myjar-platform-compat-config.xml",
|
||||||
|
"javalib/myjar.jar",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestRejectNonInstallableJavaLibrary(t *testing.T) {
|
func TestRejectNonInstallableJavaLibrary(t *testing.T) {
|
||||||
testApexError(t, `"myjar" is not configured to be compiled into dex`, `
|
testApexError(t, `"myjar" is not configured to be compiled into dex`, `
|
||||||
apex {
|
apex {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
|
android.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
|
||||||
android.RegisterModuleType("platform_compat_config", platformCompatConfigFactory)
|
android.RegisterModuleType("platform_compat_config", PlatformCompatConfigFactory)
|
||||||
android.RegisterModuleType("global_compat_config", globalCompatConfigFactory)
|
android.RegisterModuleType("global_compat_config", globalCompatConfigFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +50,24 @@ func (p *platformCompatConfig) compatConfigMetadata() android.OutputPath {
|
||||||
return p.metadataFile
|
return p.metadataFile
|
||||||
}
|
}
|
||||||
|
|
||||||
type platformCompatConfigIntf interface {
|
func (p *platformCompatConfig) CompatConfig() android.OutputPath {
|
||||||
compatConfigMetadata() android.OutputPath
|
return p.configFile
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ platformCompatConfigIntf = (*platformCompatConfig)(nil)
|
func (p *platformCompatConfig) SubDir() string {
|
||||||
|
return "compatconfig"
|
||||||
|
}
|
||||||
|
|
||||||
|
type PlatformCompatConfigIntf interface {
|
||||||
|
android.Module
|
||||||
|
|
||||||
|
compatConfigMetadata() android.OutputPath
|
||||||
|
CompatConfig() android.OutputPath
|
||||||
|
// Sub dir under etc dir.
|
||||||
|
SubDir() string
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ PlatformCompatConfigIntf = (*platformCompatConfig)(nil)
|
||||||
|
|
||||||
// compat singleton rules
|
// compat singleton rules
|
||||||
func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
|
@ -62,7 +75,7 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet
|
||||||
var compatConfigMetadata android.Paths
|
var compatConfigMetadata android.Paths
|
||||||
|
|
||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
if c, ok := module.(platformCompatConfigIntf); ok {
|
if c, ok := module.(PlatformCompatConfigIntf); ok {
|
||||||
metadata := c.compatConfigMetadata()
|
metadata := c.compatConfigMetadata()
|
||||||
compatConfigMetadata = append(compatConfigMetadata, metadata)
|
compatConfigMetadata = append(compatConfigMetadata, metadata)
|
||||||
}
|
}
|
||||||
|
@ -130,7 +143,7 @@ func platformCompatConfigSingletonFactory() android.Singleton {
|
||||||
return &platformCompatConfigSingleton{}
|
return &platformCompatConfigSingleton{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func platformCompatConfigFactory() android.Module {
|
func PlatformCompatConfigFactory() android.Module {
|
||||||
module := &platformCompatConfig{}
|
module := &platformCompatConfig{}
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||||
|
|
Loading…
Reference in New Issue