diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-02-22 23:53:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-02-22 23:53:15 +0000 |
commit | 05785f0023e427743c345dba9989a4d3aed03576 (patch) | |
tree | 79d8e1a06c3ccf22ec8a1c051c25c38667f53b25 /filesystem | |
parent | 277303f042e84a47cd2196126c9d85b05b3cf5c2 (diff) | |
parent | 4bbd6cfcaf3594dc273d33fb76509cd9b9ce41ff (diff) |
Merge "bootimg supports building (non-vendor) boot.img"
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/bootimg.go | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index 29e83da07..764f0452b 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -107,14 +107,8 @@ func (b *bootimg) partitionName() string { } 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 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { 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 @@ func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.Output 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 @@ func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.Output } 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 } |