xref: /llvm-project/llvm/test/tools/llvm-libtool-darwin/Inputs/DependencyDump.py (revision b71edfaa4ec3c998aadb35255ce2f60bba2940b0)
110f22335SKeith Smiley#
210f22335SKeith Smiley# Dump the dependency file (produced with -dependency_info) to text
310f22335SKeith Smiley# format for testing purposes.
410f22335SKeith Smiley#
510f22335SKeith Smiley
610f22335SKeith Smileyimport sys
710f22335SKeith Smiley
810f22335SKeith Smileyf = open(sys.argv[1], "rb")
910f22335SKeith Smileybyte = f.read(1)
10*b71edfaaSTobias Hietawhile byte != b"":
11*b71edfaaSTobias Hieta    if byte == b"\x00":
1210f22335SKeith Smiley        sys.stdout.write("version: ")
13*b71edfaaSTobias Hieta    elif byte == b"\x10":
1410f22335SKeith Smiley        sys.stdout.write("input-file: ")
15*b71edfaaSTobias Hieta    elif byte == b"\x11":
1610f22335SKeith Smiley        sys.stdout.write("not-found: ")
17*b71edfaaSTobias Hieta    elif byte == b"\x40":
1810f22335SKeith Smiley        sys.stdout.write("output-file: ")
1910f22335SKeith Smiley    byte = f.read(1)
20*b71edfaaSTobias Hieta    while byte != b"\x00":
2110f22335SKeith Smiley        sys.stdout.write(byte.decode("ascii"))
2210f22335SKeith Smiley        byte = f.read(1)
2310f22335SKeith Smiley    sys.stdout.write("\n")
2410f22335SKeith Smiley    byte = f.read(1)
2510f22335SKeith Smiley
2610f22335SKeith Smileyf.close()
27