[AMDGPU] Test codegen'ing True16 additions.
[llvm-project.git] / llvm / utils / gn / build / symbol_exports.py
blob379a999d4c778140b92a22132f74fa8415935611
1 #!/usr/bin/env python3
3 """Converts a .exports file to a format consumable by linkers.
5 An .exports file is a file with one exported symbol per line.
6 This script converts a .exports file into a format that linkers
7 can understand:
8 - It prepends a `_` to each line for use with -exported_symbols_list for Darwin
9 - It writes a .def file for use with /DEF: for Windows
10 - It writes a linker script for use with --version-script elsewhere
11 """
13 import argparse
14 import sys
17 def main():
18 parser = argparse.ArgumentParser(description=__doc__)
19 parser.add_argument("--format", required=True, choices=("linux", "mac", "win"))
20 parser.add_argument("source")
21 parser.add_argument("output")
22 args = parser.parse_args()
24 symbols = open(args.source).readlines()
26 if args.format == "linux":
27 output_lines = (
29 "LLVM_0 {\n",
30 " global:\n",
32 + [" %s;\n" % s.rstrip() for s in symbols]
33 + [" local:\n", " *;\n", "};\n"]
35 elif args.format == "mac":
36 output_lines = ["_" + s for s in symbols]
37 else:
38 assert args.format == "win"
39 output_lines = ["EXPORTS\n"] + [" " + s for s in symbols]
41 open(args.output, "w").writelines(output_lines)
44 if __name__ == "__main__":
45 sys.exit(main())