From 4a3a0a5412859f3b2143042dcbf0840bc78797e4 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 12 Oct 2023 15:01:29 +0100 Subject: [PATCH] Pretty print SBox manifest files to make them easier to read When debugging problems with, or just modifying a ninja rule that uses the SBox it is often necessary to read the manifest file. This change makes them easier to read by pretty printing them onto multiple lines with a small but clear indent. This increased the size of the following file by abot 6% from 66K to 70K bytes: out/soong/.intermediates/packages/modules/Wifi/framework/framework-wifi.stubs.source.system/android_common/metalava.sbox.textproto Test: m out/soong/.intermediates/packages/modules/Wifi/framework/framework-wifi.stubs.source.system/android_common/metalava.sbox.textproto less out/soong/.intermediates/packages/modules/Wifi/framework/framework-wifi.stubs.source.system/android_common/metalava.sbox.textproto Change-Id: Icfadeaad1c6334bd0010128f4437669f35822850 --- android/rule_builder.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/rule_builder.go b/android/rule_builder.go index 1454357ec..399dfdb91 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -629,8 +629,9 @@ func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString b name, r.sboxManifestPath.String(), r.outDir.String()) } - // Create a rule to write the manifest as textproto. - pbText, err := prototext.Marshal(&manifest) + // Create a rule to write the manifest as textproto. Pretty print it by indenting and + // splitting across multiple lines. + pbText, err := prototext.MarshalOptions{Indent: " "}.Marshal(&manifest) if err != nil { ReportPathErrorf(r.ctx, "sbox manifest failed to marshal: %q", err) }