xref: /llvm-project/lld/test/MachO/Inputs/DependencyDump.py (revision f98ee40f4b5d7474fc67e82824bf6abbaedb7b1c)
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("lld-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