xref: /llvm-project/llvm/test/tools/llvm-libtool-darwin/Inputs/DependencyDump.py (revision b71edfaa4ec3c998aadb35255ce2f60bba2940b0)
1#
2# Dump the dependency file (produced with -dependency_info) to text
3# format for testing purposes.
4#
5
6import sys
7
8f = open(sys.argv[1], "rb")
9byte = f.read(1)
10while byte != b"":
11    if byte == b"\x00":
12        sys.stdout.write("version: ")
13    elif byte == b"\x10":
14        sys.stdout.write("input-file: ")
15    elif byte == b"\x11":
16        sys.stdout.write("not-found: ")
17    elif byte == b"\x40":
18        sys.stdout.write("output-file: ")
19    byte = f.read(1)
20    while byte != b"\x00":
21        sys.stdout.write(byte.decode("ascii"))
22        byte = f.read(1)
23    sys.stdout.write("\n")
24    byte = f.read(1)
25
26f.close()
27