Skip to content

Commit

Permalink
Python scripts now compatible with both 2.x and 3.x releases of python
Browse files Browse the repository at this point in the history
  • Loading branch information
jduprat committed Jan 9, 2012
1 parent 59f4c99 commit 5d67252
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions bitcode2cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
try:
as_out=subprocess.Popen([llvm_as, "-", "-o", "-"], stdout=subprocess.PIPE)
except IOError:
print("Couldn't open " + src, file=sys.stderr)
sys.stderr.write("Couldn't open " + src)
sys.exit(1)

print("unsigned char builtins_bitcode_" + target + "[] = {")
sys.stdout.write("unsigned char builtins_bitcode_" + target + "[] = {\n")
num = 0
for line in as_out.stdout.readlines():
length = length + len(line)
for c in line:
num+=1
print("0x%0.2X, " % c, end="")
sys.stdout.write("0x%0.2X, " % ord(c))
if num%16 == 0:
print()
print(" 0 };\n\n")
print("int builtins_bitcode_" + target + "_length = " + str(length) + ";\n")
sys.stdout.write("\n");
sys.stdout.write(" 0 };\n\n")
sys.stdout.write("int builtins_bitcode_" + target + "_length = " + str(length) + ";\n")

as_out.wait()

Expand Down
9 changes: 4 additions & 5 deletions stdlib2cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

t=str(sys.argv[1])

print("char stdlib_" + t + "_code[] = { ")
sys.stdout.write("char stdlib_" + t + "_code[] = {\n")

num = 0
for line in sys.stdin:
for c in line:
num+=1
print("0x%0.2X, " % ord(c), end="")
sys.stdout.write("0x%0.2X, " % ord(c))
if num%16 == 0:
print()

print("0 };")
sys.stdout.write("\n")
sys.stdout.write("0 };\n")

0 comments on commit 5d67252

Please sign in to comment.