bootimg supports building (non-vendor) boot.img Bug: 178562516 Test: m microdroid_boot-5.10 Change-Id: I120fc954eb00362bdd2c02e3f3ef147670c69d8f
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index c90929a..a487150 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go
@@ -107,14 +107,8 @@ } func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { - var unsignedOutput android.OutputPath - if proptools.Bool(b.properties.Vendor_boot) { - unsignedOutput = b.buildVendorBootImage(ctx) - } else { - // TODO(jiyong): fix this - ctx.PropertyErrorf("vendor_boot", "only vendor_boot:true is supported") - return - } + vendor := proptools.Bool(b.properties.Vendor_boot) + unsignedOutput := b.buildBootImage(ctx, vendor) if proptools.Bool(b.properties.Use_avb) { b.output = b.signImage(ctx, unsignedOutput) @@ -126,17 +120,24 @@ 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 builder := android.NewRuleBuilder(pctx, ctx) cmd := builder.Command().BuiltTool("mkbootimg") - kernel := android.OptionalPathForModuleSrc(ctx, b.properties.Kernel_prebuilt) - if kernel.Valid() { + kernel := proptools.String(b.properties.Kernel_prebuilt) + if vendor && kernel != "" { ctx.PropertyErrorf("kernel_prebuilt", "vendor_boot partition can't have kernel") 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) if dtbName == "" { @@ -148,7 +149,11 @@ cmdline := proptools.String(b.properties.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) @@ -174,15 +179,23 @@ } ramdisk := ctx.GetDirectDepWithTag(ramdiskName, bootimgRamdiskDep) 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 { ctx.PropertyErrorf("ramdisk", "%q is not android_filesystem module", ramdisk.Name()) 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 }