diff options
34 files changed, 291 insertions, 121 deletions
@@ -24,3 +24,5 @@ packagecache /docs/built_docs /docs/hotdoc-private* + +*.pyc diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 1e3f640..1a98c4c 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -249,6 +249,7 @@ Executable supports the following keyword arguments. Note that just like the pos - `name_suffix` the string that will be used as the extension for the target by overriding the default. By default on Windows this is `exe` and on other platforms it is omitted. - `build_by_default` causes, when set to true, to have this target be built by default, that is, when invoking plain `ninja`, the default value is true for all built target types, since 0.38.0 - `override_options` takes an array of strings in the same format as `project`'s `default_options` overriding the values of these options for this target only, since 0.40.0 +- `implib` when set to true, an import library is generated for the executable (the name of the import library is based on *exe_name*). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in `link_with:` elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Since 0.42.0 The list of `sources`, `objects`, and `dependencies` is always flattened, which means you can freely nest and add lists while creating the final list. As a corollary, the best way to handle a 'disabled dependency' is by assigning an empty list `[]` to it and passing it like any other dependency to the `dependencies:` keyword argument. diff --git a/docs/markdown/Release-notes-for-0.42.0.md b/docs/markdown/Release-notes-for-0.42.0.md index c8a3305..f0ea534 100644 --- a/docs/markdown/Release-notes-for-0.42.0.md +++ b/docs/markdown/Release-notes-for-0.42.0.md @@ -66,6 +66,12 @@ instruction sets and selecting the best one at runtime. This module is unstable, meaning its API is subject to change in later releases. It might also be removed altogether. + +## Import libraries for executables on Windows + +The new keyword `implib` to `executable()` allows generation of an import +library for the executable. + ## Added build_rpath keyword argument You can specify `build_rpath : '/foo/bar'` in build targets and the @@ -76,3 +82,4 @@ Meson will print a warning when the user tries to add an rpath linker flag manually, e.g. via `link_args` to a target. This is not recommended because having multiple rpath causes them to stomp on each other. This warning will become a hard error in some future release. + diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index cadb655..f967de0 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -140,7 +140,12 @@ class Backend: return os.path.join(self.get_target_dir(target), link_lib) elif isinstance(target, build.StaticLibrary): return os.path.join(self.get_target_dir(target), target.get_filename()) - raise AssertionError('BUG: Tried to link to something that\'s not a library') + elif isinstance(target, build.Executable): + if target.import_filename: + return os.path.join(self.get_target_dir(target), target.get_import_filename()) + else: + return None + raise AssertionError('BUG: Tried to link to {!r} which is not linkable'.format(target)) def get_target_dir(self, target): if self.environment.coredata.get_builtin_option('layout') == 'mirror': @@ -463,12 +468,13 @@ class Backend: def build_target_link_arguments(self, compiler, deps): args = [] for d in deps: - if not isinstance(d, (build.StaticLibrary, build.SharedLibrary)): + if not (d.is_linkable_target()): raise RuntimeError('Tried to link with a non-library target "%s".' % d.get_basename()) + d_arg = self.get_target_filename_for_linking(d) + if not d_arg: + continue if isinstance(compiler, (compilers.LLVMDCompiler, compilers.DmdDCompiler)): - d_arg = '-L' + self.get_target_filename_for_linking(d) - else: - d_arg = self.get_target_filename_for_linking(d) + d_arg = '-L' + d_arg args.append(d_arg) return args diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b134510..08ae456 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -560,6 +560,8 @@ int dummy; elif isinstance(texe, build.CustomTarget): deps.append(self.get_target_filename(texe)) cmd += [os.path.join(self.environment.get_build_dir(), self.get_target_filename(texe))] + elif isinstance(texe, mesonlib.File): + cmd.append(texe.absolute_path(self.environment.get_source_dir(), self.environment.get_build_dir())) else: cmd.append(target.command) cmd += arg_strings @@ -693,7 +695,8 @@ int dummy; # On toolchains/platforms that use an import library for # linking (separate from the shared library with all the # code), we need to install that too (dll.a/.lib). - if isinstance(t, build.SharedLibrary) and t.get_import_filename(): + if (isinstance(t, build.SharedLibrary) or + isinstance(t, build.Executable)) and t.get_import_filename(): if custom_install_dir: # If the DLL is installed into a custom directory, # install the import library into the same place so @@ -2257,6 +2260,9 @@ rule FORTRAN_DEP_HACK # If gui_app, and that's significant on this platform if target.gui_app and hasattr(linker, 'get_gui_app_args'): commands += linker.get_gui_app_args() + # If implib, and that's significant on this platform (i.e. Windows using either GCC or Visual Studio) + if target.import_filename: + commands += linker.gen_import_library_args(os.path.join(target.subdir, target.import_filename)) elif isinstance(target, build.SharedLibrary): if isinstance(target, build.SharedModule): commands += linker.get_std_shared_module_link_args() diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 57b0437..4a92155 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -951,10 +951,12 @@ class Vs2010Backend(backends.Backend): ofile.text = '$(OutDir)%s' % target.get_filename() subsys = ET.SubElement(link, 'SubSystem') subsys.text = subsystem - if isinstance(target, build.SharedLibrary): + if (isinstance(target, build.SharedLibrary) or + isinstance(target, build.Executable)) and target.get_import_filename(): # DLLs built with MSVC always have an import library except when # they're data-only DLLs, but we don't support those yet. ET.SubElement(link, 'ImportLibrary').text = target.get_import_filename() + if isinstance(target, build.SharedLibrary): # Add module definitions file, if provided if target.vs_module_defs: relpath = os.path.join(down, target.vs_module_defs.rel_to_builddir(self.build_to_src)) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 99e132d..58cf987 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -75,6 +75,9 @@ known_lib_kwargs.update({'version': True, # Only for shared libs 'rust_crate_type': True, # Only for Rust libs }) +known_exe_kwargs = known_basic_kwargs.copy() +known_exe_kwargs.update({'implib': True, + }) class InvalidArguments(MesonException): pass @@ -833,7 +836,7 @@ You probably should put it in link_with instead.''') # This is a bit of a hack. We do not want Build to know anything # about the interpreter so we can't import it and use isinstance. # This should be reliable enough. - if hasattr(dep, 'project_args_frozen') or hasattr('global_args_frozen'): + if hasattr(dep, 'project_args_frozen') or hasattr(dep, 'global_args_frozen'): raise InvalidArguments('Tried to use subproject object as a dependency.\n' 'You probably wanted to use a dependency declared in it instead.\n' 'Access it by calling get_variable() on the subproject object.') @@ -849,8 +852,8 @@ You probably should put it in link_with instead.''') for t in flatten(target): if hasattr(t, 'held_object'): t = t.held_object - if not isinstance(t, (StaticLibrary, SharedLibrary)): - raise InvalidArguments('Link target {!r} is not library.'.format(t)) + if not t.is_linkable_target(): + raise InvalidArguments('Link target {!r} is not linkable.'.format(t)) if isinstance(self, SharedLibrary) and isinstance(t, StaticLibrary) and not t.pic: msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name) msg += "Use the 'pic' option to static_library to build with PIC." @@ -994,6 +997,9 @@ You probably should put it in link_with instead.''') return True return False + def is_linkable_target(self): + return False + class Generator: def __init__(self, args, kwargs): @@ -1130,9 +1136,52 @@ class Executable(BuildTarget): self.filename += '.' + self.suffix self.outputs = [self.filename] + # The import library this target will generate + self.import_filename = None + # The import library that Visual Studio would generate (and accept) + self.vs_import_filename = None + # The import library that GCC would generate (and prefer) + self.gcc_import_filename = None + + # if implib appears, this target is linkwith:-able, but that only means + # something on Windows platforms. + self.is_linkwithable = False + if 'implib' in kwargs and kwargs['implib']: + implib_basename = self.name + '.exe' + if not isinstance(kwargs['implib'], bool): + implib_basename = kwargs['implib'] + self.is_linkwithable = True + if for_windows(is_cross, environment) or for_cygwin(is_cross, environment): + self.vs_import_filename = '{0}.lib'.format(implib_basename) + self.gcc_import_filename = 'lib{0}.a'.format(implib_basename) + + if self.get_using_msvc(): + self.import_filename = self.vs_import_filename + else: + self.import_filename = self.gcc_import_filename + def type_suffix(self): return "@exe" + def check_unknown_kwargs(self, kwargs): + self.check_unknown_kwargs_int(kwargs, known_exe_kwargs) + + def get_import_filename(self): + """ + The name of the import library that will be outputted by the compiler + + Returns None if there is no import library required for this platform + """ + return self.import_filename + + def get_import_filenameslist(self): + if self.import_filename: + return [self.vs_import_filename, self.gcc_import_filename] + return [] + + def is_linkable_target(self): + return self.is_linkwithable + class StaticLibrary(BuildTarget): def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): if 'pic' not in kwargs and 'b_staticpic' in environment.coredata.base_options: @@ -1184,6 +1233,9 @@ class StaticLibrary(BuildTarget): else: raise InvalidArguments('Invalid rust_crate_type "{0}": must be a string.'.format(rust_crate_type)) + def is_linkable_target(self): + return True + class SharedLibrary(BuildTarget): def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): self.soversion = None @@ -1413,6 +1465,9 @@ class SharedLibrary(BuildTarget): def type_suffix(self): return "@sha" + def is_linkable_target(self): + return True + # A shared library that is meant to be used with dlopen rather than linking # into something else. class SharedModule(SharedLibrary): diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index c88286c..72e1ed3 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -957,8 +957,6 @@ class GnuCompiler: return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module) def get_std_shared_lib_link_args(self): - if self.gcc_type == GCC_OSX: - return ['-bundle'] return ['-shared'] def get_link_whole_for(self, args): diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index fdb5ab8..f98de44 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -551,7 +551,7 @@ class ExtraFrameworkDependency(ExternalDependency): def detect(self, name, path): lname = name.lower() if path is None: - paths = ['/Library/Frameworks'] + paths = ['/System/Library/Frameworks', '/Library/Frameworks'] else: paths = [path] for p in paths: diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index be3e570..1858e8c 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2513,7 +2513,14 @@ class Interpreter(InterpreterBase): if conffile not in self.build_def_files: self.build_def_files.append(conffile) os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True) - mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object) + missing_variables = mesonlib.do_conf_file(ifile_abs, ofile_abs, + conf.held_object) + if missing_variables: + var_list = ", ".join(map(repr, sorted(missing_variables))) + mlog.warning( + "The variable(s) %s in the input file %r are not " + "present in the given configuration data" % ( + var_list, inputfile)) else: mesonlib.dump_conf_header(ofile_abs, conf.held_object) conf.mark_used() diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 4760e04..d48625f 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -375,6 +375,7 @@ def get_library_dirs(): def do_replacement(regex, line, confdata): match = re.search(regex, line) + missing_variables = set() while match: varname = match.group(1) if varname in confdata: @@ -386,10 +387,11 @@ def do_replacement(regex, line, confdata): else: raise RuntimeError('Tried to replace a variable with something other than a string or int.') else: + missing_variables.add(varname) var = '' line = line.replace('@' + varname + '@', var) match = re.search(regex, line) - return line + return line, missing_variables def do_mesondefine(line, confdata): arr = line.split() @@ -423,17 +425,20 @@ def do_conf_file(src, dst, confdata): # Also allow escaping '@' with '\@' regex = re.compile(r'[^\\]?@([-a-zA-Z0-9_]+)@') result = [] + missing_variables = set() for line in data: if line.startswith('#mesondefine'): line = do_mesondefine(line, confdata) else: - line = do_replacement(regex, line, confdata) + line, missing = do_replacement(regex, line, confdata) + missing_variables.update(missing) result.append(line) dst_tmp = dst + '~' with open(dst_tmp, 'w', encoding='utf-8') as f: f.writelines(result) shutil.copymode(src, dst_tmp) replace_if_different(dst, dst_tmp) + return missing_variables def dump_conf_header(ofilename, cdata): with open(ofilename, 'w', encoding='utf-8') as ofile: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index dd4ca50..883799c 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -376,9 +376,7 @@ class GnomeModule(ExtensionModule): if girdir: gi_includes.update([girdir]) elif isinstance(dep, (build.StaticLibrary, build.SharedLibrary)): - for incd in dep.get_include_dirs(): - for idir in incd.get_incdirs(): - cflags.update(["-I%s" % idir]) + cflags.update(get_include_args(dep.get_include_dirs())) else: mlog.log('dependency %s not handled to build gir files' % dep) continue diff --git a/run_project_tests.py b/run_project_tests.py index 3420946..69a778e 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -183,7 +183,7 @@ def get_relative_files_list_from_dir(fromdir): paths.append(path) return paths -def platform_fix_name(fname): +def platform_fix_name(fname, compiler): if '?lib' in fname: if mesonlib.is_cygwin(): fname = re.sub(r'\?lib(.*)\.dll$', r'cyg\1.dll', fname) @@ -195,6 +195,16 @@ def platform_fix_name(fname): if mesonlib.is_windows() or mesonlib.is_cygwin(): return fname + '.exe' + if fname.startswith('?msvc:'): + fname = fname[6:] + if compiler != 'cl': + return None + + if fname.startswith('?gcc:'): + fname = fname[5:] + if compiler == 'cl': + return None + return fname def validate_install(srcdir, installdir, compiler): @@ -210,7 +220,9 @@ def validate_install(srcdir, installdir, compiler): elif os.path.exists(info_file): with open(info_file) as f: for line in f: - expected[platform_fix_name(line.strip())] = False + line = platform_fix_name(line.strip(), compiler) + if line: + expected[line] = False # Check if expected files were found for fname in expected: file_path = os.path.join(installdir, fname) diff --git a/test cases/common/156 shared module resolving symbol in executable/meson.build b/test cases/common/156 shared module resolving symbol in executable/meson.build new file mode 100644 index 0000000..34a75f1 --- /dev/null +++ b/test cases/common/156 shared module resolving symbol in executable/meson.build @@ -0,0 +1,21 @@ +project('shared module resolving symbol in executable', 'c') + +# The shared module contains a reference to the symbol 'func_from_executable', +# which is always provided by the executable which loads it. This symbol can be +# resolved at run-time by an ELF loader. But when building PE/COFF objects, all +# symbols must be resolved at link-time, so an implib is generated for the +# executable, and the shared module linked with it. +# +# See testcase 125 for an example of the more complex portability gymnastics +# required if we do not know (at link-time) what provides the symbol. + +link_flags = [] +if host_machine.system() != 'windows' + # Needed to export dynamic symbols from the executable + link_flags += ['-rdynamic'] +endif + +dl = meson.get_compiler('c').find_library('dl', required: false) +e = executable('prog', 'prog.c', dependencies: dl, implib: true, link_args: link_flags) +m = shared_module('module', 'module.c', link_with: e) +test('test', e, args: m.full_path()) diff --git a/test cases/common/156 shared module resolving symbol in executable/module.c b/test cases/common/156 shared module resolving symbol in executable/module.c new file mode 100644 index 0000000..64374d5 --- /dev/null +++ b/test cases/common/156 shared module resolving symbol in executable/module.c @@ -0,0 +1,16 @@ +#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 + +extern int func_from_executable(void); + +int DLL_PUBLIC func(void) { + return func_from_executable(); +} diff --git a/test cases/common/156 shared module resolving symbol in executable/prog.c b/test cases/common/156 shared module resolving symbol in executable/prog.c new file mode 100644 index 0000000..746c192 --- /dev/null +++ b/test cases/common/156 shared module resolving symbol in executable/prog.c @@ -0,0 +1,60 @@ +#include <stdio.h> +#include <assert.h> +#ifdef _WIN32 +#include <windows.h> +#else +#include <dlfcn.h> +#endif + +#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 + +typedef int (*fptr) (void); + +int DLL_PUBLIC +func_from_executable(void) +{ + return 42; +} + +int +main (int argc, char **argv) +{ + int expected, actual; + fptr importedfunc; + +#ifdef _WIN32 + HMODULE h = LoadLibraryA(argv[1]); +#else + void *h = dlopen(argv[1], RTLD_NOW); +#endif + assert(h != NULL); + +#ifdef _WIN32 + importedfunc = (fptr) GetProcAddress (h, "func"); +#else + importedfunc = (fptr) dlsym(h, "func"); +#endif + assert(importedfunc != NULL); + assert(importedfunc != func_from_executable); + + actual = (*importedfunc)(); + expected = func_from_executable(); + assert(actual == expected); + +#ifdef _WIN32 + FreeLibrary(h); +#else + dlclose(h); +#endif + + return 0; +} diff --git a/test cases/common/58 run target/configure.in b/test cases/common/58 run target/configure.in new file mode 100755 index 0000000..0d42d04 --- /dev/null +++ b/test cases/common/58 run target/configure.in @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('Success')
\ No newline at end of file diff --git a/test cases/common/58 run target/meson.build b/test cases/common/58 run target/meson.build index a1c5ad8..686db1f 100644 --- a/test cases/common/58 run target/meson.build +++ b/test cases/common/58 run target/meson.build @@ -49,3 +49,14 @@ run_target('check_exists', # executable but test that the output is generated correctly. run_target('donotrunme', command : hex) + +# Ensure configure files can be passed +conf = configure_file( + input: 'configure.in', + output: 'configure', + configuration: configuration_data() +) + +run_target('configure_script', + command : conf +) diff --git a/test cases/failing/59 link with executable/meson.build b/test cases/failing/59 link with executable/meson.build new file mode 100644 index 0000000..186b3e5 --- /dev/null +++ b/test cases/failing/59 link with executable/meson.build @@ -0,0 +1,4 @@ +project('link with exe', 'c') + +e = executable('prog', 'prog.c') +m = shared_module('module', 'module.c', link_with: e) diff --git a/test cases/failing/59 link with executable/module.c b/test cases/failing/59 link with executable/module.c new file mode 100644 index 0000000..dc0124a --- /dev/null +++ b/test cases/failing/59 link with executable/module.c @@ -0,0 +1,4 @@ + +int func(void) { + return 42; +} diff --git a/test cases/failing/59 link with executable/prog.c b/test cases/failing/59 link with executable/prog.c new file mode 100644 index 0000000..f3836d7 --- /dev/null +++ b/test cases/failing/59 link with executable/prog.c @@ -0,0 +1,5 @@ +int +main (int argc, char **argv) +{ + return 0; +} diff --git a/test cases/windows/12 exe implib/installed_files.txt b/test cases/windows/12 exe implib/installed_files.txt new file mode 100644 index 0000000..bd2abe9 --- /dev/null +++ b/test cases/windows/12 exe implib/installed_files.txt @@ -0,0 +1,8 @@ +usr/bin/prog.exe +usr/bin/prog.pdb +usr/bin/prog2.exe +usr/bin/prog2.pdb +?gcc:usr/lib/libprog.exe.a +?gcc:usr/lib/libburble.a +?msvc:usr/lib/prog.exe.lib +?msvc:usr/lib/burble.lib diff --git a/test cases/windows/12 exe implib/meson.build b/test cases/windows/12 exe implib/meson.build new file mode 100644 index 0000000..2526c65 --- /dev/null +++ b/test cases/windows/12 exe implib/meson.build @@ -0,0 +1,7 @@ +project('wintest', 'c') + +# Test that we can produce an implib for an executable on Windows, and that it's +# name can be set, and that it is installed along with the executable + +executable('prog', 'prog.c', install: true, implib: true) +executable('prog2', 'prog.c', install: true, implib: 'burble') diff --git a/test cases/windows/12 exe implib/prog.c b/test cases/windows/12 exe implib/prog.c new file mode 100644 index 0000000..6d5a9f5 --- /dev/null +++ b/test cases/windows/12 exe implib/prog.c @@ -0,0 +1,6 @@ +#include <windows.h> + +int __declspec(dllexport) +main(int argc, char **argv) { + return 0; +} diff --git a/test cases/windows/7 mingw dll versioning/installed_files.txt b/test cases/windows/7 mingw dll versioning/installed_files.txt deleted file mode 100644 index 26e14a7..0000000 --- a/test cases/windows/7 mingw dll versioning/installed_files.txt +++ /dev/null @@ -1,11 +0,0 @@ -usr/bin/?libsome-0.dll -usr/lib/libsome.dll.a -usr/bin/?libnoversion.dll -usr/lib/libnoversion.dll.a -usr/bin/?libonlyversion-1.dll -usr/lib/libonlyversion.dll.a -usr/bin/?libonlysoversion-5.dll -usr/lib/libonlysoversion.dll.a -usr/libexec/?libcustomdir.dll -usr/libexec/libcustomdir.dll.a -usr/lib/?libmodule.dll diff --git a/test cases/windows/7 mingw dll versioning/meson.build b/test cases/windows/7 mingw dll versioning/meson.build deleted file mode 100644 index 1d6562c..0000000 --- a/test cases/windows/7 mingw dll versioning/meson.build +++ /dev/null @@ -1,55 +0,0 @@ -project('mingw dll versioning', 'c') - -cc = meson.get_compiler('c') - -if cc.get_id() == 'msvc' - error('MESON_SKIP_TEST: test is only for MinGW') -endif - -# Test that MinGW/GCC creates correctly-named dll files and dll.a files, -# and also installs them in the right place -some = shared_library('some', 'lib.c', - version : '1.2.3', - soversion : '0', - install : true) - -noversion = shared_library('noversion', 'lib.c', - install : true) - -onlyversion = shared_library('onlyversion', 'lib.c', - version : '1.4.5', - install : true) - -onlysoversion = shared_library('onlysoversion', 'lib.c', - # Also test that int soversion is acceptable - soversion : 5, - install : true) - -# Hack to make the executables below depend on the shared libraries above -# without actually adding them as `link_with` dependencies since we want to try -# linking to them with -lfoo linker arguments. -out = custom_target('library-dependency-hack', - input : 'exe.orig.c', - output : 'exe.c', - depends : [some, noversion, onlyversion, onlysoversion], - command : ['cp', '@INPUT@', '@OUTPUT@']) - -# Manually test if the linker can find the above libraries -# i.e., whether they were generated with the right naming scheme -test('manually linked 1', executable('manuallink1', out, - link_args : ['-L.', '-lsome'])) - -test('manually linked 2', executable('manuallink2', out, - link_args : ['-L.', '-lnoversion'])) - -test('manually linked 3', executable('manuallink3', out, - link_args : ['-L.', '-lonlyversion'])) - -test('manually linked 4', executable('manuallink4', out, - link_args : ['-L.', '-lonlysoversion'])) - -shared_library('customdir', 'lib.c', - install : true, - install_dir : get_option('libexecdir')) - -shared_module('module', 'lib.c', install : true) diff --git a/test cases/windows/8 msvc dll versioning/copyfile.py b/test cases/windows/8 dll versioning/copyfile.py index ff42ac3..ff42ac3 100644 --- a/test cases/windows/8 msvc dll versioning/copyfile.py +++ b/test cases/windows/8 dll versioning/copyfile.py diff --git a/test cases/windows/7 mingw dll versioning/exe.orig.c b/test cases/windows/8 dll versioning/exe.orig.c index 86c4adc..86c4adc 100644 --- a/test cases/windows/7 mingw dll versioning/exe.orig.c +++ b/test cases/windows/8 dll versioning/exe.orig.c diff --git a/test cases/windows/8 dll versioning/installed_files.txt b/test cases/windows/8 dll versioning/installed_files.txt new file mode 100644 index 0000000..a1e9b2d --- /dev/null +++ b/test cases/windows/8 dll versioning/installed_files.txt @@ -0,0 +1,24 @@ +?msvc:usr/bin/some-0.dll +?msvc:usr/bin/some-0.pdb +?msvc:usr/lib/some.lib +?msvc:usr/bin/noversion.dll +?msvc:usr/bin/noversion.pdb +?msvc:usr/lib/noversion.lib +?msvc:usr/bin/onlyversion-1.dll +?msvc:usr/lib/onlyversion.lib +?msvc:usr/bin/onlysoversion-5.dll +?msvc:usr/lib/onlysoversion.lib +?msvc:usr/libexec/customdir.dll +?msvc:usr/libexec/customdir.lib +?msvc:usr/lib/module.dll +?gcc:usr/bin/?libsome-0.dll +?gcc:usr/lib/libsome.dll.a +?gcc:usr/bin/?libnoversion.dll +?gcc:usr/lib/libnoversion.dll.a +?gcc:usr/bin/?libonlyversion-1.dll +?gcc:usr/lib/libonlyversion.dll.a +?gcc:usr/bin/?libonlysoversion-5.dll +?gcc:usr/lib/libonlysoversion.dll.a +?gcc:usr/libexec/?libcustomdir.dll +?gcc:usr/libexec/libcustomdir.dll.a +?gcc:usr/lib/?libmodule.dll diff --git a/test cases/windows/7 mingw dll versioning/lib.c b/test cases/windows/8 dll versioning/lib.c index cf7dfdd..cf7dfdd 100644 --- a/test cases/windows/7 mingw dll versioning/lib.c +++ b/test cases/windows/8 dll versioning/lib.c diff --git a/test cases/windows/8 msvc dll versioning/meson.build b/test cases/windows/8 dll versioning/meson.build index 4074747..80acf88 100644 --- a/test cases/windows/8 msvc dll versioning/meson.build +++ b/test cases/windows/8 dll versioning/meson.build @@ -2,12 +2,8 @@ project('msvc dll versioning', 'c') cc = meson.get_compiler('c') -if cc.get_id() != 'msvc' - error('MESON_SKIP_TEST: test is only for msvc') -endif - -# Test that MSVC creates correctly-named dll files and .lib files, -# and also installs them in the right place +# Test that we create correctly-named dll and import lib files, +# and also install them in the right place some = shared_library('some', 'lib.c', version : '1.2.3', soversion : '0', diff --git a/test cases/windows/8 msvc dll versioning/exe.orig.c b/test cases/windows/8 msvc dll versioning/exe.orig.c deleted file mode 100644 index 86c4adc..0000000 --- a/test cases/windows/8 msvc dll versioning/exe.orig.c +++ /dev/null @@ -1,9 +0,0 @@ -int myFunc (void); - -int -main (int argc, char *argv[]) -{ - if (myFunc() == 55) - return 0; - return 1; -} diff --git a/test cases/windows/8 msvc dll versioning/installed_files.txt b/test cases/windows/8 msvc dll versioning/installed_files.txt deleted file mode 100644 index df43343..0000000 --- a/test cases/windows/8 msvc dll versioning/installed_files.txt +++ /dev/null @@ -1,13 +0,0 @@ -usr/bin/some-0.dll -usr/bin/some-0.pdb -usr/lib/some.lib -usr/bin/noversion.dll -usr/bin/noversion.pdb -usr/lib/noversion.lib -usr/bin/onlyversion-1.dll -usr/lib/onlyversion.lib -usr/bin/onlysoversion-5.dll -usr/lib/onlysoversion.lib -usr/libexec/customdir.dll -usr/libexec/customdir.lib -usr/lib/module.dll diff --git a/test cases/windows/8 msvc dll versioning/lib.c b/test cases/windows/8 msvc dll versioning/lib.c deleted file mode 100644 index cf7dfdd..0000000 --- a/test cases/windows/8 msvc dll versioning/lib.c +++ /dev/null @@ -1,6 +0,0 @@ -#ifdef _WIN32 -__declspec(dllexport) -#endif -int myFunc() { - return 55; -} |