]> xenbits.xensource.com Git - seabios.git/commitdiff
build: Make print statements in scripts python3 compatible.
authorJohannes Krampf <johannes.krampf@googlemail.com>
Sun, 12 Jan 2014 16:14:54 +0000 (11:14 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 20 Jan 2014 17:42:43 +0000 (12:42 -0500)
Signed-off-by: Johannes Krampf <johannes.krampf@googlemail.com>
scripts/checkrom.py
scripts/checkstack.py
scripts/checksum.py
scripts/layoutrom.py
scripts/readserial.py

index aa3dd0d1affe787c9bef3d19edd66a2b6896b68b..e724844c563913823735640f94707b7f36d4a6a3 100755 (executable)
@@ -40,11 +40,11 @@ def main():
             if datasize > 128*1024:
                 finalsize = 256*1024
     if datasize > finalsize:
-        print "Error!  ROM doesn't fit (%d > %d)" % (datasize, finalsize)
-        print "   You have to either increate the size (CONFIG_ROM_SIZE)"
-        print "   or turn off some features (such as hardware support not"
-        print "   needed) to make it fit.  Trying a more recent gcc version"
-        print "   might work too."
+        print("Error!  ROM doesn't fit (%d > %d)" % (datasize, finalsize))
+        print("   You have to either increate the size (CONFIG_ROM_SIZE)")
+        print("   or turn off some features (such as hardware support not")
+        print("   needed) to make it fit.  Trying a more recent gcc version")
+        print("   might work too.")
         sys.exit(1)
 
     # Sanity checks
@@ -52,17 +52,17 @@ def main():
     end = symbols['code32flat_end'].offset
     expend = layoutrom.BUILD_BIOS_ADDR + layoutrom.BUILD_BIOS_SIZE
     if end != expend:
-        print "Error!  Code does not end at 0x%x (got 0x%x)" % (
-            expend, end)
+        print("Error!  Code does not end at 0x%x (got 0x%x)" % (
+            expend, end))
         sys.exit(1)
     if datasize > finalsize:
-        print "Error!  Code is too big (0x%x vs 0x%x)" % (
-            datasize, finalsize)
+        print("Error!  Code is too big (0x%x vs 0x%x)" % (
+            datasize, finalsize))
         sys.exit(1)
     expdatasize = end - start
     if datasize != expdatasize:
-        print "Error!  Unknown extra data (0x%x vs 0x%x)" % (
-            datasize, expdatasize)
+        print("Error!  Unknown extra data (0x%x vs 0x%x)" % (
+            datasize, expdatasize))
         sys.exit(1)
 
     # Fix up CSM Compatibility16 table
@@ -83,10 +83,10 @@ def main():
 
     # Print statistics
     runtimesize = end - symbols['code32init_end'].offset
-    print "Total size: %d  Fixed: %d  Free: %d (used %.1f%% of %dKiB rom)" % (
+    print("Total size: %d  Fixed: %d  Free: %d (used %.1f%% of %dKiB rom)" % (
         datasize, runtimesize, finalsize - datasize
         , (datasize / float(finalsize)) * 100.0
-        , finalsize / 1024)
+        , finalsize / 1024))
 
     # Write final file
     f = open(outfile, 'wb')
index 23b7c8edbcd63db998fd0234f82c1aa2bf83b4ad..62fef362f43d283dfb51b3d734205c198e37cf34 100755 (executable)
@@ -182,12 +182,12 @@ def calc():
                 elif insn.startswith('calll'):
                     noteCall(cur, subfuncs, insnaddr, calladdr, stackusage + 4)
                 else:
-                    print "unknown call", ref
+                    print("unknown call", ref)
                     noteCall(cur, subfuncs, insnaddr, calladdr, stackusage)
             # Reset stack usage to preamble usage
             stackusage = cur[1]
 
-        #print "other", repr(line)
+        #print("other", repr(line))
 
     # Calculate maxstackusage
     for funcaddr, info in funcs.items():
@@ -199,7 +199,7 @@ def calc():
     funcaddrs = orderfuncs(funcs.keys(), funcs.copy())
 
     # Show all functions
-    print OUTPUTDESC
+    print(OUTPUTDESC)
     for funcaddr in funcaddrs:
         name, basicusage, maxusage, yieldusage, maxyieldusage, count, calls = \
             funcs[funcaddr]
@@ -208,15 +208,15 @@ def calc():
         yieldstr = ""
         if maxyieldusage is not None:
             yieldstr = ",%d" % maxyieldusage
-        print "\n%s[%d,%d%s]:" % (name, basicusage, maxusage, yieldstr)
+        print("\n%s[%d,%d%s]:" % (name, basicusage, maxusage, yieldstr))
         for insnaddr, calladdr, stackusage in calls:
             callinfo = funcs.get(calladdr, ("<unknown>", 0, 0, 0, None))
             yieldstr = ""
             if callinfo[4] is not None:
                 yieldstr = ",%d" % (stackusage + callinfo[4])
-            print "    %04s:%-40s [%d+%d,%d%s]" % (
+            print("    %04s:%-40s [%d+%d,%d%s]" % (
                 insnaddr, callinfo[0], stackusage, callinfo[1]
-                , stackusage+callinfo[2], yieldstr)
+                , stackusage+callinfo[2], yieldstr))
 
 def main():
     calc()
index 8c7665d2508d598abf07510234515ffbf198cdff..773fa7aa9f956385ea20e055275b481adec8b4a4 100755 (executable)
@@ -10,7 +10,7 @@ import sys
 def main():
     data = sys.stdin.read()
     ords = map(ord, data)
-    print "sum=%x\n" % sum(ords)
+    print("sum=%x\n" % sum(ords))
 
 if __name__ == '__main__':
     main()
index 24cd7a42ab7248286ed1e86d4b8e0503b3ae08d1..c0b325d3f70b7af95d3a5483f26d393780a4957b 100755 (executable)
@@ -76,8 +76,8 @@ def fitSections(sections, fillsections):
             section.finalsegloc = addr
             fixedsections.append((addr, section))
             if section.align != 1:
-                print "Error: Fixed section %s has non-zero alignment (%d)" % (
-                    section.name, section.align)
+                print("Error: Fixed section %s has non-zero alignment (%d)" % (
+                    section.name, section.align))
                 sys.exit(1)
     fixedsections.sort()
     firstfixed = fixedsections[0][0]
@@ -106,8 +106,8 @@ def fitSections(sections, fillsections):
         addpos = fixedsection.finalsegloc + fixedsection.size
         totalused += fixedsection.size
         nextfixedaddr = addpos + freespace
-#        print "Filling section %x uses %d, next=%x, available=%d" % (
-#            fixedsection.finalloc, fixedsection.size, nextfixedaddr, freespace)
+#        print("Filling section %x uses %d, next=%x, available=%d" % (
+#            fixedsection.finalloc, fixedsection.size, nextfixedaddr, freespace))
         while 1:
             canfit = None
             for fitsection in canrelocate:
@@ -115,8 +115,8 @@ def fitSections(sections, fillsections):
                     # Can't fit and nothing else will fit.
                     break
                 fitnextaddr = alignpos(addpos, fitsection.align) + fitsection.size
-#                print "Test %s - %x vs %x" % (
-#                    fitsection.name, fitnextaddr, nextfixedaddr)
+#                print("Test %s - %x vs %x" % (
+#                    fitsection.name, fitnextaddr, nextfixedaddr))
                 if fitnextaddr > nextfixedaddr:
                     # This item can't fit.
                     continue
@@ -130,9 +130,9 @@ def fitSections(sections, fillsections):
             fitsection.finalsegloc = addpos
             addpos = fitnextaddr
             totalused += fitsection.size
-#            print "    Adding %s (size %d align %d) pos=%x avail=%d" % (
+#            print("    Adding %s (size %d align %d) pos=%x avail=%d" % (
 #                fitsection[2], fitsection[0], fitsection[1]
-#                , fitnextaddr, nextfixedaddr - fitnextaddr)
+#                , fitnextaddr, nextfixedaddr - fitnextaddr))
 
     # Report stats
     total = BUILD_BIOS_SIZE-firstfixed
@@ -273,12 +273,12 @@ def doLayout(sections, config, genreloc):
     size32flat = li.sec32fseg_start - li.sec32flat_start
     size32init = li.sec32flat_start - li.sec32init_start
     sizelow = sec32low_end - li.sec32low_start
-    print "16bit size:           %d" % size16
-    print "32bit segmented size: %d" % size32seg
-    print "32bit flat size:      %d" % size32flat
-    print "32bit flat init size: %d" % size32init
-    print "Lowmem size:          %d" % sizelow
-    print "f-segment var size:   %d" % size32fseg
+    print("16bit size:           %d" % size16)
+    print("32bit segmented size: %d" % size32seg)
+    print("32bit flat size:      %d" % size32flat)
+    print("32bit flat init size: %d" % size32init)
+    print("Lowmem size:          %d" % sizelow)
+    print("f-segment var size:   %d" % size32fseg)
     return li
 
 
@@ -458,8 +458,8 @@ def markRuntime(section, sections, chain=[]):
         or '.init.' in section.name or section.fileid != '32flat'):
         return
     if '.data.varinit.' in section.name:
-        print "ERROR: %s is VARVERIFY32INIT but used from %s" % (
-            section.name, chain)
+        print("ERROR: %s is VARVERIFY32INIT but used from %s" % (
+            section.name, chain))
         sys.exit(1)
     section.category = '32flat'
     # Recursively mark all sections this section points to
index d85392eba67933e85ff58ab1ad53db6dd3759b29..5b40fdc0726b0b9dca4f5bb629a76dbac75ebc99 100755 (executable)
@@ -156,11 +156,11 @@ def main():
         try:
             import serial
         except ImportError:
-            print """
+            print("""
 Unable to find pyserial package ( http://pyserial.sourceforge.net/ ).
 On Linux machines try: yum install pyserial
 Or: apt-get install python-serial
-"""
+""")
             sys.exit(1)
         ser = serial.Serial(serialport, baud, timeout=0)
     else: