From 8f859a510506318f91f639b67807a3dbdd4d0fbc Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 22 Jun 2017 20:18:15 +0100 Subject: [PATCH] Make the name of the executable implib configurable --- docs/markdown/Reference-manual.md | 2 +- mesonbuild/build.py | 11 +++++++---- test cases/windows/12 exe implib/installed_files.txt | 6 +++++- test cases/windows/12 exe implib/meson.build | 8 ++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 261d89894..4989cef61 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -248,7 +248,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, used when the returned build target object appears elsewhere in `link_with:`, on platforms where this is meaningful (e.g. Windows), since 0.42.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/mesonbuild/build.py b/mesonbuild/build.py index df24c7fbe..89b96f5be 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1135,14 +1135,17 @@ class Executable(BuildTarget): # The import library that GCC would generate (and prefer) self.gcc_import_filename = None - # if implib:true appears, this target is linkwith:-able, but that only - # means something on Windows platforms. + # 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(self.name) - self.gcc_import_filename = 'lib{0}.exe.a'.format(self.name) + 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 diff --git a/test cases/windows/12 exe implib/installed_files.txt b/test cases/windows/12 exe implib/installed_files.txt index d0ea8f6c4..bd2abe92b 100644 --- a/test cases/windows/12 exe implib/installed_files.txt +++ b/test cases/windows/12 exe implib/installed_files.txt @@ -1,4 +1,8 @@ usr/bin/prog.exe usr/bin/prog.pdb +usr/bin/prog2.exe +usr/bin/prog2.pdb ?gcc:usr/lib/libprog.exe.a -?msvc:usr/lib/prog.lib +?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 index 2393e794c..2526c651a 100644 --- a/test cases/windows/12 exe implib/meson.build +++ b/test cases/windows/12 exe implib/meson.build @@ -1,7 +1,7 @@ project('wintest', 'c') -# Test that we can produce an implib for an executable on Windows, and that it -# is installed along with the executable +# 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 -prog = executable('prog', 'prog.c', install: true, implib: true) -test('wintest', prog) +executable('prog', 'prog.c', install: true, implib: true) +executable('prog2', 'prog.c', install: true, implib: 'burble')