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
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
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":
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
]
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__":