Merge "bootimg supports building (non-vendor) boot.img" am: 05785f0023
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1594411 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ic162526591b47f7a7df48d929724af0a1d790a2b
This commit is contained in:
@@ -107,14 +107,8 @@ func (b *bootimg) partitionName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
var unsignedOutput android.OutputPath
|
vendor := proptools.Bool(b.properties.Vendor_boot)
|
||||||
if proptools.Bool(b.properties.Vendor_boot) {
|
unsignedOutput := b.buildBootImage(ctx, vendor)
|
||||||
unsignedOutput = b.buildVendorBootImage(ctx)
|
|
||||||
} else {
|
|
||||||
// TODO(jiyong): fix this
|
|
||||||
ctx.PropertyErrorf("vendor_boot", "only vendor_boot:true is supported")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if proptools.Bool(b.properties.Use_avb) {
|
if proptools.Bool(b.properties.Use_avb) {
|
||||||
b.output = b.signImage(ctx, unsignedOutput)
|
b.output = b.signImage(ctx, unsignedOutput)
|
||||||
@@ -126,17 +120,24 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
ctx.InstallFile(b.installDir, b.installFileName(), b.output)
|
ctx.InstallFile(b.installDir, b.installFileName(), b.output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.OutputPath {
|
func (b *bootimg) buildBootImage(ctx android.ModuleContext, vendor bool) android.OutputPath {
|
||||||
output := android.PathForModuleOut(ctx, "unsigned", b.installFileName()).OutputPath
|
output := android.PathForModuleOut(ctx, "unsigned", b.installFileName()).OutputPath
|
||||||
|
|
||||||
builder := android.NewRuleBuilder(pctx, ctx)
|
builder := android.NewRuleBuilder(pctx, ctx)
|
||||||
cmd := builder.Command().BuiltTool("mkbootimg")
|
cmd := builder.Command().BuiltTool("mkbootimg")
|
||||||
|
|
||||||
kernel := android.OptionalPathForModuleSrc(ctx, b.properties.Kernel_prebuilt)
|
kernel := proptools.String(b.properties.Kernel_prebuilt)
|
||||||
if kernel.Valid() {
|
if vendor && kernel != "" {
|
||||||
ctx.PropertyErrorf("kernel_prebuilt", "vendor_boot partition can't have kernel")
|
ctx.PropertyErrorf("kernel_prebuilt", "vendor_boot partition can't have kernel")
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
if !vendor && kernel == "" {
|
||||||
|
ctx.PropertyErrorf("kernel_prebuilt", "boot partition must have kernel")
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
if kernel != "" {
|
||||||
|
cmd.FlagWithInput("--kernel ", android.PathForModuleSrc(ctx, kernel))
|
||||||
|
}
|
||||||
|
|
||||||
dtbName := proptools.String(b.properties.Dtb_prebuilt)
|
dtbName := proptools.String(b.properties.Dtb_prebuilt)
|
||||||
if dtbName == "" {
|
if dtbName == "" {
|
||||||
@@ -148,7 +149,11 @@ func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.Output
|
|||||||
|
|
||||||
cmdline := proptools.String(b.properties.Cmdline)
|
cmdline := proptools.String(b.properties.Cmdline)
|
||||||
if cmdline != "" {
|
if cmdline != "" {
|
||||||
cmd.FlagWithArg("--vendor_cmdline ", "\""+cmdline+"\"")
|
flag := "--cmdline "
|
||||||
|
if vendor {
|
||||||
|
flag = "--vendor_cmdline "
|
||||||
|
}
|
||||||
|
cmd.FlagWithArg(flag, "\""+proptools.ShellEscape(cmdline)+"\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerVersion := proptools.String(b.properties.Header_version)
|
headerVersion := proptools.String(b.properties.Header_version)
|
||||||
@@ -174,15 +179,23 @@ func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.Output
|
|||||||
}
|
}
|
||||||
ramdisk := ctx.GetDirectDepWithTag(ramdiskName, bootimgRamdiskDep)
|
ramdisk := ctx.GetDirectDepWithTag(ramdiskName, bootimgRamdiskDep)
|
||||||
if filesystem, ok := ramdisk.(*filesystem); ok {
|
if filesystem, ok := ramdisk.(*filesystem); ok {
|
||||||
cmd.FlagWithInput("--vendor_ramdisk ", filesystem.OutputPath())
|
flag := "--ramdisk "
|
||||||
|
if vendor {
|
||||||
|
flag = "--vendor_ramdisk "
|
||||||
|
}
|
||||||
|
cmd.FlagWithInput(flag, filesystem.OutputPath())
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("ramdisk", "%q is not android_filesystem module", ramdisk.Name())
|
ctx.PropertyErrorf("ramdisk", "%q is not android_filesystem module", ramdisk.Name())
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.FlagWithOutput("--vendor_boot ", output)
|
flag := "--output "
|
||||||
|
if vendor {
|
||||||
|
flag = "--vendor_boot "
|
||||||
|
}
|
||||||
|
cmd.FlagWithOutput(flag, output)
|
||||||
|
|
||||||
builder.Build("build_vendor_bootimg", fmt.Sprintf("Creating %s", b.BaseModuleName()))
|
builder.Build("build_bootimg", fmt.Sprintf("Creating %s", b.BaseModuleName()))
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user