diff options
author | Adrian Perez de Castro <aperez@igalia.com> | 2021-04-26 17:38:48 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2021-04-27 09:54:00 +0300 |
commit | 5cd76a8d934936115caf04f2aea1d713dc43b8e9 (patch) | |
tree | 1f9068d4ddb2ae06fbedac77d7fcdf021e419828 /scripts | |
parent | f434c690cc7f5e47f122f54fa13ec26a533090ac (diff) | |
download | xorg-lib-libxkbcommon-5cd76a8d934936115caf04f2aea1d713dc43b8e9.tar.gz |
Windows: Pass list of symbols to export to MSVC
Arrange for passing .def files with the lists of symbols to export from
DLLs when building on Windows with MSVC. Without this no symbols were
being exported at all.
The .def files are generated from the .map files at build time using
scripts/map-to-def, which avoids needing to maintain two different sets
of files.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/map-to-def | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/map-to-def b/scripts/map-to-def new file mode 100755 index 0000000..63b566e --- /dev/null +++ b/scripts/map-to-def @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +"""A script to generate MSVC Module-Definition files from version-script +files (which are maintained manually).""" + +import re +import sys +import pathlib + + +def symbols_from_map(path): + return re.findall(r'^\s+(r?xkb_.*);', path.read_text('utf-8'), re.MULTILINE) + + +if 2 > len(sys.argv) > 3: + raise SystemExit("Usage: {} file.map [file.def]".format(sys.argv[0])) + + +map_file = pathlib.Path(sys.argv[1]) +map_symbols = set(symbols_from_map(map_file)) + +if len(sys.argv) == 3: + def_file = open(sys.argv[2], "w", encoding="utf-8") +else: + def_file = sys.stdout + +def_file.write("LIBRARY {}\n".format(map_file.stem)) +def_file.write("EXPORTS\n") +for symbol in sorted(map_symbols): + def_file.write("\t{}\n".format(symbol)) |