Merge pull request #4480 from jon-turney/fix-implib-prefix-suffix

Fix naming of implib when name_prefix/suffix is used
pull/4507/head
Jussi Pakkanen 6 years ago committed by GitHub
commit 59774702b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      mesonbuild/build.py
  2. 57
      run_project_tests.py
  3. 5
      test cases/common/122 shared module/installed_files.txt
  4. 8
      test cases/common/122 shared module/meson.build
  5. 15
      test cases/common/207 install name_prefix name_suffix/installed_files.txt
  6. 14
      test cases/common/207 install name_prefix name_suffix/libfile.c
  7. 10
      test cases/common/207 install name_prefix name_suffix/meson.build
  8. 1
      test cases/common/25 library versions/installed_files.txt
  9. 13
      test cases/common/25 library versions/lib.c
  10. 10
      test cases/windows/7 dll versioning/installed_files.txt
  11. 4
      test cases/windows/7 dll versioning/meson.build

@ -1549,13 +1549,9 @@ class SharedLibrary(BuildTarget):
prefix = ''
suffix = ''
self.filename_tpl = self.basic_filename_tpl
# If the user already provided the prefix and suffix to us, we don't
# need to do any filename suffix/prefix detection.
# NOTE: manual prefix/suffix override is currently only tested for C/C++
if self.prefix is not None and self.suffix is not None:
pass
# C# and Mono
elif 'cs' in self.compilers:
if 'cs' in self.compilers:
prefix = ''
suffix = 'dll'
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
@ -1564,8 +1560,8 @@ class SharedLibrary(BuildTarget):
# For all other targets/platforms import_filename stays None
elif for_windows(is_cross, env):
suffix = 'dll'
self.vs_import_filename = '{0}.lib'.format(self.name)
self.gcc_import_filename = 'lib{0}.dll.a'.format(self.name)
self.vs_import_filename = '{0}{1}.lib'.format(self.prefix if self.prefix is not None else '', self.name)
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
if self.get_using_msvc():
# Shared library is of the form foo.dll
prefix = ''
@ -1584,7 +1580,7 @@ class SharedLibrary(BuildTarget):
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif for_cygwin(is_cross, env):
suffix = 'dll'
self.gcc_import_filename = 'lib{0}.dll.a'.format(self.name)
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
# Shared library is of the form cygfoo.dll
# (ld --dll-search-prefix=cyg is the default)
prefix = 'cyg'

@ -118,10 +118,25 @@ def get_relative_files_list_from_dir(fromdir):
return paths
def platform_fix_name(fname, compiler, env):
# canonicalize compiler
if compiler == 'clang-cl':
canonical_compiler = 'msvc'
else:
canonical_compiler = compiler
if '?lib' in fname:
if mesonlib.for_cygwin(env.is_cross_build(), env):
if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc':
fname = re.sub(r'lib/\?lib(.*)\.', r'bin/\1.', fname)
fname = re.sub(r'/\?lib/', r'/bin/', fname)
elif mesonlib.for_windows(env.is_cross_build(), env):
fname = re.sub(r'lib/\?lib(.*)\.', r'bin/lib\1.', fname)
fname = re.sub(r'\?lib(.*)\.dll$', r'lib\1.dll', fname)
fname = re.sub(r'/\?lib/', r'/bin/', fname)
elif mesonlib.for_cygwin(env.is_cross_build(), env):
fname = re.sub(r'lib/\?lib(.*)\.so$', r'bin/cyg\1.dll', fname)
fname = re.sub(r'lib/\?lib(.*)\.', r'bin/cyg\1.', fname)
fname = re.sub(r'\?lib(.*)\.dll$', r'cyg\1.dll', fname)
fname = re.sub(r'/\?lib/', r'/bin/', fname)
else:
fname = re.sub(r'\?lib', 'lib', fname)
@ -132,17 +147,47 @@ def platform_fix_name(fname, compiler, env):
if fname.startswith('?msvc:'):
fname = fname[6:]
if compiler != 'msvc':
if canonical_compiler != 'msvc':
return None
if fname.startswith('?gcc:'):
fname = fname[5:]
if compiler == 'msvc':
if canonical_compiler == 'msvc':
return None
if fname.startswith('?cygwin:'):
fname = fname[8:]
if compiler == 'msvc' or not mesonlib.for_cygwin(env.is_cross_build(), env):
if not mesonlib.for_cygwin(env.is_cross_build(), env):
return None
if fname.endswith('?so'):
if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc':
fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
fname = re.sub(r'/(?:lib|)([^/]*?)\?so$', r'/\1.dll', fname)
return fname
elif mesonlib.for_windows(env.is_cross_build(), env):
fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
return fname
elif mesonlib.for_cygwin(env.is_cross_build(), env):
fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
fname = re.sub(r'/lib([^/]*?)\?so$', r'/cyg\1.dll', fname)
fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
return fname
elif mesonlib.for_darwin(env.is_cross_build(), env):
return fname[:-3] + '.dylib'
else:
return fname[:-3] + '.so'
if fname.endswith('?implib') or fname.endswith('?implibempty'):
if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc':
# only MSVC doesn't generate empty implibs
if fname.endswith('?implibempty') and compiler == 'msvc':
return None
return re.sub(r'/(?:lib|)([^/]*?)\?implib(?:empty|)$', r'/\1.lib', fname)
elif mesonlib.for_windows(env.is_cross_build(), env) or mesonlib.for_cygwin(env.is_cross_build(), env):
return re.sub(r'\?implib(?:empty|)$', r'.dll.a', fname)
else:
return None
return fname
@ -696,10 +741,6 @@ def detect_system_compiler():
raise RuntimeError("Could not find C compiler.")
system_compiler = comp.get_id()
# canonicalize for platform_fix_name()
if system_compiler == 'clang-cl':
system_compiler = 'msvc'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Run the test suite of Meson.")
parser.add_argument('extra_args', nargs='*',

@ -1,2 +1,3 @@
usr/lib/libnosyms.so
?msvc:usr/lib/libnosyms.pdb
usr/lib/modules/libnosyms?so
usr/lib/modules/libnosyms?implibempty
?msvc:usr/lib/modules/nosyms.pdb

@ -13,8 +13,6 @@ e = executable('prog', 'prog.c',
test('import test', e, args : m)
# Shared module that does not export any symbols
shared_module('nosyms', 'nosyms.c', install : true,
# Because we don't have cross-platform library support in
# installed_files.txt
name_suffix : 'so',
name_prefix : 'lib')
shared_module('nosyms', 'nosyms.c',
install : true,
install_dir : join_paths(get_option('libdir'), 'modules'))

@ -0,0 +1,15 @@
?msvc:usr/bin/baz.pdb
?msvc:usr/bin/bowcorge.pdb
?msvc:usr/bin/foo.pdb
?msvc:usr/lib/baz.pdb
?msvc:usr/lib/bowcorge.pdb
?msvc:usr/lib/foo.pdb
usr/?lib/bowcorge.stern
usr/lib/?libbaz.cheese
usr/lib/bar.a
usr/lib/bowcorge?implib
usr/lib/bowgrault.stern
usr/lib/foo?implib
usr/lib/foo?so
usr/lib/libbaz?implib
usr/lib/libqux.cheese

@ -0,0 +1,14 @@
#if defined _WIN32 || defined __CYGWIN__
#define DLL_PUBLIC __declspec(dllexport)
#else
#if defined __GNUC__
#define DLL_PUBLIC __attribute__ ((visibility("default")))
#else
#pragma message ("Compiler does not support symbol visibility.")
#define DLL_PUBLIC
#endif
#endif
int DLL_PUBLIC func() {
return 0;
}

@ -0,0 +1,10 @@
project('library with name_prefix name_suffix test', 'c')
shared_library('foo', 'libfile.c', name_prefix: '', install : true)
static_library('bar', 'libfile.c', name_prefix: '', install : true)
shared_library('baz', 'libfile.c', name_suffix: 'cheese', install : true)
static_library('qux', 'libfile.c', name_suffix: 'cheese', install : true)
shared_library('corge', 'libfile.c', name_prefix: 'bow', name_suffix: 'stern', install : true)
static_library('grault', 'libfile.c', name_prefix: 'bow', name_suffix: 'stern', install : true)

@ -1,2 +1,3 @@
usr/lib/prefixsomelib.suffix
usr/lib/prefixsomelib?implib
?msvc:usr/lib/prefixsomelib.pdb

@ -1,3 +1,14 @@
int myFunc() {
#if defined _WIN32 || defined __CYGWIN__
#define DLL_PUBLIC __declspec(dllexport)
#else
#if defined __GNUC__
#define DLL_PUBLIC __attribute__ ((visibility("default")))
#else
#pragma message ("Compiler does not support symbol visibility.")
#define DLL_PUBLIC
#endif
#endif
int DLL_PUBLIC myFunc() {
return 55;
}

@ -14,9 +14,9 @@
?msvc:usr/libexec/customdir.dll
?msvc:usr/libexec/customdir.lib
?msvc:usr/libexec/customdir.pdb
?msvc:usr/lib/module.dll
?msvc:usr/lib/module.lib
?msvc:usr/lib/module.pdb
?msvc:usr/lib/modules/module.dll
?msvc:usr/lib/modules/module.lib
?msvc:usr/lib/modules/module.pdb
?gcc:usr/bin/?libsome-0.dll
?gcc:usr/lib/libsome.dll.a
?gcc:usr/bin/?libnoversion.dll
@ -27,5 +27,5 @@
?gcc:usr/lib/libonlysoversion.dll.a
?gcc:usr/libexec/?libcustomdir.dll
?gcc:usr/libexec/libcustomdir.dll.a
?gcc:usr/lib/?libmodule.dll
?gcc:usr/lib/libmodule.dll.a
?gcc:usr/lib/modules/?libmodule.dll
?gcc:usr/lib/modules/libmodule.dll.a

@ -49,4 +49,6 @@ shared_library('customdir', 'lib.c',
install : true,
install_dir : get_option('libexecdir'))
shared_module('module', 'lib.c', install : true)
shared_module('module', 'lib.c',
install : true,
install_dir: join_paths(get_option('libdir'), 'modules'))

Loading…
Cancel
Save