3 """A script to generate MSVC Module-Definition files from version-script
4 files (which are maintained manually)."""
11 def symbols_from_map(path):
12 return re.findall(r"^\s+(r?xkb_.*);", path.read_text("utf-8"), re.MULTILINE)
15 if 2 > len(sys.argv) > 3:
16 raise SystemExit("Usage: {} file.map [file.def]".format(sys.argv[0]))
19 map_file = pathlib.Path(sys.argv[1])
20 map_symbols = set(symbols_from_map(map_file))
22 if len(sys.argv) == 3:
23 def_file = open(sys.argv[2], "w", encoding="utf-8")
27 def_file.write("LIBRARY {}\n".format(map_file.stem))
28 def_file.write("EXPORTS\n")
29 for symbol in sorted(map_symbols):
30 def_file.write("\t{}\n".format(symbol))