Merge "apex: support prebuilt_firmware for vendor apexes"

This commit is contained in:
Jooyung Han 2020-09-02 04:17:43 +00:00 committed by Gerrit Code Review
commit 3a92fbeaff
5 changed files with 64 additions and 18 deletions

View File

@ -1740,7 +1740,7 @@ func apexFileForJavaLibrary(ctx android.BaseModuleContext, module javaModule) ap
}
func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
dirInApex := filepath.Join("etc", prebuilt.SubDir())
dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir())
fileToCopy := prebuilt.OutputFile()
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
}

View File

@ -248,7 +248,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
ctx.RegisterModuleType("cc_test", cc.TestFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
ctx.RegisterModuleType("prebuilt_etc", prebuilt_etc.PrebuiltEtcFactory)
prebuilt_etc.RegisterPrebuiltEtcBuildComponents(ctx)
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
@ -2272,6 +2272,32 @@ func TestVendorApex_use_vndk_as_stable(t *testing.T) {
ensureListContains(t, requireNativeLibs, ":vndk")
}
func TestVendorApex_withPrebuiltFirmware(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
prebuilts: ["myfirmware"],
vendor: true,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
prebuilt_firmware {
name: "myfirmware",
src: "myfirmware.bin",
filename_from_src: true,
vendor: true,
}
`)
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"firmware/myfirmware.bin",
})
}
func TestAndroidMk_UseVendorRequired(t *testing.T) {
ctx, config := testApex(t, `
apex {

View File

@ -505,18 +505,25 @@ func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
}}
}
// PrebuiltEtcModule interface
func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
return txt.outputFile
}
func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
return android.Paths{txt.outputFile}, nil
// PrebuiltEtcModule interface
func (txt *vndkLibrariesTxt) BaseDir() string {
return "etc"
}
// PrebuiltEtcModule interface
func (txt *vndkLibrariesTxt) SubDir() string {
return ""
}
func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
return android.Paths{txt.outputFile}, nil
}
func VndkSnapshotSingleton() android.Singleton {
return &vndkSnapshotSingleton{}
}

View File

@ -28,14 +28,17 @@ var pctx = android.NewPackageContext("android/soong/etc")
func init() {
pctx.Import("android/soong/android")
RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
}
android.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
android.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
android.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
android.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
android.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
android.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
android.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
}
type prebuiltEtcProperties struct {
@ -70,6 +73,7 @@ type prebuiltEtcProperties struct {
type PrebuiltEtcModule interface {
android.Module
BaseDir() string
SubDir() string
OutputFile() android.OutputPath
}
@ -167,6 +171,16 @@ func (p *PrebuiltEtc) SubDir() string {
return proptools.String(p.properties.Relative_install_path)
}
func (p *PrebuiltEtc) BaseDir() string {
// If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
// socInstallDirBase.
installBaseDir := p.installDirBase
if p.SocSpecific() && p.socInstallDirBase != "" {
installBaseDir = p.socInstallDirBase
}
return installBaseDir
}
func (p *PrebuiltEtc) Installable() bool {
return p.properties.Installable == nil || android.Bool(p.properties.Installable)
}
@ -191,13 +205,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
}
// If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
// socInstallDirBase.
installBaseDir := p.installDirBase
if ctx.SocSpecific() && p.socInstallDirBase != "" {
installBaseDir = p.socInstallDirBase
}
p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
p.installDirPath = android.PathForModuleInstall(ctx, p.BaseDir(), p.SubDir())
// This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name.

View File

@ -2069,6 +2069,11 @@ func (module *sdkLibraryXml) UniqueApexVariations() bool {
return true
}
// from android.PrebuiltEtcModule
func (module *sdkLibraryXml) BaseDir() string {
return "etc"
}
// from android.PrebuiltEtcModule
func (module *sdkLibraryXml) SubDir() string {
return "permissions"