From b17f6dae541ec9744e82c2cb6f1c31c9a76b45f5 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 31 Oct 2018 12:31:10 +0000 Subject: [PATCH] Add a test of installed library names when name_{suf,pre}fix: is used Extend platform_fix_name() to handle this case We avoid using library(version:), so we don't have to teach platform_fix_name() all the platform details of versioned shared library naming. Hopefully that's exercised by platform-specific tests... --- run_project_tests.py | 35 ++++++++++++++++++- .../installed_files.txt | 10 ++++++ .../libfile.c | 14 ++++++++ .../meson.build | 7 ++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 test cases/common/207 install name_prefix name_suffix/installed_files.txt create mode 100644 test cases/common/207 install name_prefix name_suffix/libfile.c create mode 100644 test cases/common/207 install name_prefix name_suffix/meson.build diff --git a/run_project_tests.py b/run_project_tests.py index c73567e4e..6f7d9d77e 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -119,8 +119,14 @@ def get_relative_files_list_from_dir(fromdir): def platform_fix_name(fname, compiler, env): if '?lib' in fname: - if mesonlib.for_cygwin(env.is_cross_build(), env): + if mesonlib.for_windows(env.is_cross_build(), env) and compiler == 'msvc': + fname = re.sub(r'lib/\?lib(.*)\.', r'bin/\1.', 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) + 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) else: fname = re.sub(r'\?lib', 'lib', fname) @@ -145,6 +151,33 @@ def platform_fix_name(fname, compiler, env): if compiler == 'msvc' or 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'): + if mesonlib.for_windows(env.is_cross_build(), env) and compiler == 'msvc': + return re.sub(r'/(?:lib|)([^/]*?)\?implib$', r'/\1.lib', fname) + elif mesonlib.for_windows(env.is_cross_build(), env) or mesonlib.for_cygwin(env.is_cross_build(), env): + return fname[:-7] + '.dll.a' + else: + return None + return fname def validate_install(srcdir, installdir, compiler, env): diff --git a/test cases/common/207 install name_prefix name_suffix/installed_files.txt b/test cases/common/207 install name_prefix name_suffix/installed_files.txt new file mode 100644 index 000000000..d590591c4 --- /dev/null +++ b/test cases/common/207 install name_prefix name_suffix/installed_files.txt @@ -0,0 +1,10 @@ +?msvc:usr/bin/baz.pdb +?msvc:usr/bin/foo.pdb +?msvc:usr/lib/baz.pdb +?msvc:usr/lib/foo.pdb +usr/lib/?libbaz.cheese +usr/lib/bar.a +usr/lib/foo?implib +usr/lib/foo?so +usr/lib/libbaz?implib +usr/lib/libqux.cheese diff --git a/test cases/common/207 install name_prefix name_suffix/libfile.c b/test cases/common/207 install name_prefix name_suffix/libfile.c new file mode 100644 index 000000000..44f7667d4 --- /dev/null +++ b/test cases/common/207 install name_prefix name_suffix/libfile.c @@ -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; +} diff --git a/test cases/common/207 install name_prefix name_suffix/meson.build b/test cases/common/207 install name_prefix name_suffix/meson.build new file mode 100644 index 000000000..1ae98b6e9 --- /dev/null +++ b/test cases/common/207 install name_prefix name_suffix/meson.build @@ -0,0 +1,7 @@ +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)