Make the name of the executable implib configurable

pull/1955/head
Jon Turney 8 years ago
parent 3110c209f7
commit 8f859a5105
  1. 2
      docs/markdown/Reference-manual.md
  2. 11
      mesonbuild/build.py
  3. 6
      test cases/windows/12 exe implib/installed_files.txt
  4. 8
      test cases/windows/12 exe implib/meson.build

@ -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. - `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 - `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 - `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. 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.

@ -1135,14 +1135,17 @@ class Executable(BuildTarget):
# The import library that GCC would generate (and prefer) # The import library that GCC would generate (and prefer)
self.gcc_import_filename = None self.gcc_import_filename = None
# if implib:true appears, this target is linkwith:-able, but that only # if implib appears, this target is linkwith:-able, but that only means
# means something on Windows platforms. # something on Windows platforms.
self.is_linkwithable = False self.is_linkwithable = False
if 'implib' in kwargs and kwargs['implib']: 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 self.is_linkwithable = True
if for_windows(is_cross, environment) or for_cygwin(is_cross, environment): if for_windows(is_cross, environment) or for_cygwin(is_cross, environment):
self.vs_import_filename = '{0}.lib'.format(self.name) self.vs_import_filename = '{0}.lib'.format(implib_basename)
self.gcc_import_filename = 'lib{0}.exe.a'.format(self.name) self.gcc_import_filename = 'lib{0}.a'.format(implib_basename)
if self.get_using_msvc(): if self.get_using_msvc():
self.import_filename = self.vs_import_filename self.import_filename = self.vs_import_filename

@ -1,4 +1,8 @@
usr/bin/prog.exe usr/bin/prog.exe
usr/bin/prog.pdb usr/bin/prog.pdb
usr/bin/prog2.exe
usr/bin/prog2.pdb
?gcc:usr/lib/libprog.exe.a ?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

@ -1,7 +1,7 @@
project('wintest', 'c') project('wintest', 'c')
# Test that we can produce an implib for an executable on Windows, and that it # Test that we can produce an implib for an executable on Windows, and that it's
# is installed along with the executable # name can be set, and that it is installed along with the executable
prog = executable('prog', 'prog.c', install: true, implib: true) executable('prog', 'prog.c', install: true, implib: true)
test('wintest', prog) executable('prog2', 'prog.c', install: true, implib: 'burble')

Loading…
Cancel
Save