symbolextractor: Add support for Cygwin

pull/6637/head
Nirbheek Chauhan 4 years ago
parent cbd143844d
commit 04e89d0867
  1. 26
      mesonbuild/scripts/symbolextractor.py
  2. 4
      run_unittests.py

@ -139,6 +139,25 @@ def osx_syms(libfilename: str, outfilename: str):
result += [' '.join(x.split()[0:2]) for x in output.split('\n')]
write_if_changed('\n'.join(result) + '\n', outfilename)
def cygwin_syms(impfilename: str, outfilename: str):
# Get the name of the library
output = call_tool('dlltool', ['-I', impfilename])
if not output:
dummy_syms(outfilename)
return
result = [output]
# Get the list of all symbols exported
output = call_tool('nm', ['--extern-only', '--defined-only',
'--format=posix', impfilename])
if not output:
dummy_syms(outfilename)
return
for line in output.split('\n'):
if ' T ' not in line:
continue
result.append(line.split(maxsplit=1)[0])
write_if_changed('\n'.join(result) + '\n', outfilename)
def _get_implib_dllname(impfilename: str) -> T.Tuple[T.List[str], str]:
all_stderr = ''
# First try lib.exe, which is provided by MSVC. Then llvm-lib.exe, by LLVM
@ -222,6 +241,13 @@ def gen_symbols(libfilename: str, impfilename: str, outfilename: str, cross_host
# No import library. Not sure how the DLL is being used, so just
# rebuild everything that links to it every time.
dummy_syms(outfilename)
elif mesonlib.is_cygwin():
if os.path.isfile(impfilename):
cygwin_syms(impfilename, outfilename)
else:
# No import library. Not sure how the DLL is being used, so just
# rebuild everything that links to it every time.
dummy_syms(outfilename)
else:
if not os.path.exists(TOOL_WARNING_FILE):
mlog.warning('Symbol extracting has not been implemented for this '

@ -1759,7 +1759,7 @@ class BasePlatformTests(unittest.TestCase):
@staticmethod
def get_target_from_filename(filename):
base = os.path.splitext(filename)[0]
if base.startswith('lib'):
if base.startswith(('lib', 'cyg')):
return base[3:]
return base
@ -2591,8 +2591,6 @@ class AllPlatformTests(BasePlatformTests):
Test that no-op changes to the build files such as mtime do not cause
a rebuild of anything.
'''
if is_cygwin():
raise unittest.SkipTest('symbolextractor has not been implemented for Cygwin yet')
testdir = os.path.join(self.common_test_dir, '6 linkshared')
self.init(testdir)
self.build()

Loading…
Cancel
Save