diff options
author | Bruce Richardson <bruce.richardson@intel.com> | 2019-04-12 09:29:00 +0100 |
---|---|---|
committer | Thomas Monjalon <thomas@monjalon.net> | 2019-06-05 19:49:28 +0200 |
commit | 4c773788e05a3d5e2a55e134f015bea09350807b (patch) | |
tree | fd695f45c5b326f4be27b9434d0697bb35506b32 /buildtools | |
parent | 8cb511bb94ad92a76990f175cac76bb13d51daba (diff) |
build: generate Windows exports file
Rather than having a separate version.map file for linux/BSD and an
exports definition file for windows for each library, generate the
latter from the former automatically at build time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/map_to_def.py | 40 | ||||
-rw-r--r-- | buildtools/meson.build | 12 | ||||
-rw-r--r-- | buildtools/pmdinfogen/meson.build | 7 |
3 files changed, 54 insertions, 5 deletions
diff --git a/buildtools/map_to_def.py b/buildtools/map_to_def.py new file mode 100644 index 0000000000..6775b54a9d --- /dev/null +++ b/buildtools/map_to_def.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2019 Intel Corporation + +from __future__ import print_function +import sys +from os.path import dirname, basename, join, exists + + +def is_function_line(ln): + return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln + + +def main(args): + if not args[1].endswith('version.map') or \ + not args[2].endswith('exports.def'): + return 1 + +# special case, allow override if an def file already exists alongside map file + override_file = join(dirname(args[1]), basename(args[2])) + if exists(override_file): + with open(override_file) as f_in: + functions = f_in.readlines() + +# generate def file from map file. +# This works taking indented lines only which end with a ";" and which don't +# have a colon in them, i.e. the lines defining functions only. + else: + with open(args[1]) as f_in: + functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines()) + if is_function_line(ln)] + functions = ["EXPORTS\n"] + functions + + with open(args[2], 'w') as f_out: + f_out.writelines(functions) + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/buildtools/meson.build b/buildtools/meson.build index 0d3a42c018..32c79c1308 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -1,10 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_windows - subdir_done() -endif - subdir('pmdinfogen') pmdinfo = find_program('gen-pmdinfo-cfile.sh') + +# set up map-to-def script using python, either built-in or external +python3 = import('python').find_installation(required: false) +if python3.found() + map_to_def_cmd = [python3, files('map_to_def.py')] +else + map_to_def_cmd = ['meson', 'runpython', files('map_to_def.py')] +endif diff --git a/buildtools/pmdinfogen/meson.build b/buildtools/pmdinfogen/meson.build index a219a8e963..899ba112cd 100644 --- a/buildtools/pmdinfogen/meson.build +++ b/buildtools/pmdinfogen/meson.build @@ -1,7 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -pmdinfogen_inc = eal_inc +if host_machine.system() == 'windows' + subdir_done() +endif + +pmdinfogen_inc = [global_inc] +pmdinfogen_inc += include_directories('../../lib/librte_eal/common/include') pmdinfogen_inc += include_directories('../../lib/librte_pci') pmdinfogen = executable('pmdinfogen', 'pmdinfogen.c', |