Blob Blame History Raw
From dd0155d32ec0077505faa757fc7e05339400021b Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 24 Jan 2017 11:41:09 +0100
Subject: [PATCH 2/4] acpi_extract: Make the generated .hex files more human
 readable

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1485258071-13209-3-git-send-email-kraxel@redhat.com>
Patchwork-id: 73326
O-Subject: [RHEL-7.3.z seabios PATCH 2/4] acpi_extract: Make the generated .hex files more human readable
Bugzilla: 1400102
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

From: Kevin O'Connor <kevin@koconnor.net>

Add a comment to the top of the generated file indicating that is is
an automatically generated file.  Compress output so that up to eight
hex values are placed on a single line.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 7fdd2fda3fc3ff46b0919e9fd47fcd19561bbb37)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 scripts/acpi_extract.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/acpi_extract.py b/scripts/acpi_extract.py
index 24ff0d1..3ed863b 100755
--- a/scripts/acpi_extract.py
+++ b/scripts/acpi_extract.py
@@ -346,14 +346,21 @@ def main():
     debug = "at end of file"
 
     # Pretty print output
+    outstrs = ["/* DO NOT EDIT!  This is an autogenerated file."
+               "  See scripts/acpi_extract.py. */"]
     for array in output.keys():
         otype = get_value_type(max(output[array]))
+        outstrs.append("static unsigned %s %s[] = {" % (otype, array))
         odata = []
         for value in output[array]:
-            odata.append("0x%x" % value)
-        sys.stdout.write("static unsigned %s %s[] = {\n" % (otype, array))
-        sys.stdout.write(",\n".join(odata))
-        sys.stdout.write('\n};\n')
+            odata.append("0x%02x" % value)
+            if len(odata) >= 8:
+                outstrs.append("    %s," % (', '.join(odata),))
+                del odata[:]
+        outstrs.append("    %s" % (', '.join(odata),))
+        outstrs.append('};')
+        outstrs.append('')
+    sys.stdout.write('\n'.join(outstrs))
 
 if __name__ == '__main__':
     main()
-- 
1.8.3.1