Soong: Define a new Soong module named prebuilt_firmware.

There are several firmware files that are being installed to
system/etc/firmware or vendor/firmware. A new module type is
defined to install firmware files to install in the system
or vendor image.

Fixes: b/133711895
Test: Ran lunch, wrote unit test cases, created a sample Android.bp
      with defined prebuilt_firmware Soong and ran mma.

Change-Id: Iaa791cdda4402936037c5a456cc8bf8e6c905b3e
This commit is contained in:
Patrice Arruda
2019-06-03 15:29:27 -07:00
parent 06b2c69cfe
commit 057a8b1114
2 changed files with 60 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ func init() {
RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
PreDepsMutators(func(ctx RegisterMutatorsContext) {
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
@@ -61,7 +62,9 @@ type PrebuiltEtc struct {
sourceFilePath Path
outputFilePath OutputPath
// The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
installDirBase string
installDirBase string
// The base install location when soc_specific property is set to true, e.g. "firmware" for prebuilt_firmware.
socInstallDirBase string
installDirPath OutputPath
additionalDependencies *Paths
}
@@ -121,7 +124,14 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
return
}
p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath
p.installDirPath = PathForModuleInstall(ctx, p.installDirBase, String(p.properties.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 = PathForModuleInstall(ctx, installBaseDir, String(p.properties.Sub_dir))
// This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name.
@@ -250,3 +260,14 @@ func PrebuiltFontFactory() Module {
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
return module
}
// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system image.
// If soc_specific property is set to true, the firmware file is installed to the vendor <partition>/firmware
// directory for vendor image.
func PrebuiltFirmwareFactory() Module {
module := &PrebuiltEtc{installDirBase: "etc/firmware", socInstallDirBase: "firmware"}
InitPrebuiltEtcModule(module)
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
return module
}