meson: Getting symbols-check.py works for mingw
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37289>
This commit is contained in:
Yonggang Luo 2023-12-15 17:42:38 +08:00 committed by Marge Bot
parent bd915eeb96
commit 57d273b55b
2 changed files with 34 additions and 4 deletions

View file

@ -121,6 +121,23 @@ def get_symbols_dumpbin(dumpbin, lib):
symbols.append(symbol_name)
return symbols
def get_symbols_gendef(gendef, lib):
'''
List all the (non platform-specific) symbols exported by the library
using `gendef -`
'''
symbols = []
output = subprocess.check_output([gendef, '-', lib],
stderr=open(os.devnull, 'w')).decode("ascii")
ordinal_table_found = False
for line in output.splitlines():
if not ordinal_table_found:
if line.strip() == 'EXPORTS':
ordinal_table_found = True
continue
symbols.append(line.strip())
return symbols
def main():
parser = argparse.ArgumentParser()
@ -138,15 +155,21 @@ def main():
parser.add_argument('--dumpbin',
action='store',
help='path to binary (or name in $PATH)')
parser.add_argument('--gendef',
action='store',
help='path to binary (or name in $PATH)')
parser.add_argument('--ignore-symbol',
action='append',
help='do not process this symbol')
args = parser.parse_args()
if platform.system() == 'Windows':
if not args.dumpbin:
parser.error('--dumpbin is mandatory')
lib_symbols = get_symbols_dumpbin(args.dumpbin, args.lib)
if args.dumpbin:
lib_symbols = get_symbols_dumpbin(args.dumpbin, args.lib)
elif args.gendef:
lib_symbols = get_symbols_gendef(args.gendef, args.lib)
else:
parser.error('--dumpbin is mandatory for msvc, --gendef is mandatory for mingw')
else:
if not args.nm:
parser.error('--nm is mandatory')

View file

@ -2224,12 +2224,19 @@ endif
pkg = import('pkgconfig')
if host_machine.system() == 'windows'
if host_machine.system() == 'windows' and cc.get_argument_syntax() == 'msvc'
prog_dumpbin = find_program('dumpbin', required : false)
with_symbols_check = prog_dumpbin.found() and with_tests
if with_symbols_check
symbols_check_args = ['--dumpbin', prog_dumpbin.full_path()]
endif
elif host_machine.system() == 'windows' and cc.get_argument_syntax() != 'msvc'
# mingw
prog_gendef = find_program('gendef', required : false)
with_symbols_check = prog_gendef.found() and with_tests
if with_symbols_check
symbols_check_args = ['--gendef', prog_gendef.full_path()]
endif
else
prog_nm = find_program('nm')
with_symbols_check = prog_nm.found() and with_tests