summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-01-10 15:00:36 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-10-15 10:21:46 -0700
commit67510c167c131d405a9ce6d8269d3042b81d94b5 (patch)
treec1a9088c705f194c8391122d6e18af304e113d24
parent020e58b59972a6cbfb78841021a87cd5162a9a77 (diff)
downloadmeson-67510c167c131d405a9ce6d8269d3042b81d94b5.tar.gz
build: remove build layer validation of Executable(implib)
This includes cleaning up some of the type handling to account for cleanups that are done at the DSL level.
-rw-r--r--docs/yaml/functions/executable.yaml11
-rw-r--r--mesonbuild/build.py10
-rw-r--r--mesonbuild/interpreter/interpreter.py5
-rw-r--r--mesonbuild/interpreter/type_checking.py9
4 files changed, 20 insertions, 15 deletions
diff --git a/docs/yaml/functions/executable.yaml b/docs/yaml/functions/executable.yaml
index 1e463edf0..c819a3842 100644
--- a/docs/yaml/functions/executable.yaml
+++ b/docs/yaml/functions/executable.yaml
@@ -37,15 +37,18 @@ kwargs:
since: 0.45.0
description: |
when set to true causes the target's symbols to be
- dynamically exported, allowing modules built using the
- [[shared_module]] function to refer to functions,
- variables and other symbols defined in the executable itself. Implies
- the `implib` argument.
+ dynamically exported, allowing modules built using the
+ [[shared_module]] function to refer to functions,
+ variables and other symbols defined in the executable itself.
implib:
type: bool | str
since: 0.42.0
description: |
+ When set to a string, that will be the name of a generated import library.
+
+ *Since 1.10.0* passing a boolean value is deprecated.
+
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
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index e3f5672c6..99e86c3f6 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -112,7 +112,7 @@ if T.TYPE_CHECKING:
class ExecutableKeywordArguments(BuildTargetKeywordArguments, total=False):
- implib: T.Union[str, bool, None]
+ implib: T.Optional[str]
export_dynamic: bool
pie: bool
vs_module_defs: T.Union[str, File, CustomTarget, CustomTargetIndex]
@@ -2231,9 +2231,7 @@ class Executable(BuildTarget):
self.export_dynamic = kwargs.get('export_dynamic', False)
if not isinstance(self.export_dynamic, bool):
raise InvalidArguments('"export_dynamic" keyword argument must be a boolean')
- self.implib = kwargs.get('implib')
- if not isinstance(self.implib, (bool, str, type(None))):
- raise InvalidArguments('"export_dynamic" keyword argument must be a boolean or string')
+ self.implib_name = kwargs.get('implib')
# Only linkwithable if using export_dynamic
self.is_linkwithable = self.export_dynamic
# Remember that this exe was returned by `find_program()` through an override
@@ -2287,9 +2285,7 @@ class Executable(BuildTarget):
# If using export_dynamic, set the import library name
if self.export_dynamic:
- implib_basename = self.name + '.exe'
- if isinstance(self.implib, str):
- implib_basename = self.implib
+ implib_basename = self.implib_name or self.name + '.exe'
if machine.is_windows() or machine.is_cygwin():
if self.get_using_msvc():
self.import_filename = f'{implib_basename}.lib'
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 72e937904..51671bfc5 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -3541,11 +3541,10 @@ class Interpreter(InterpreterBase, HoldableObject):
elif kwargs['export_dynamic']:
if kwargs['implib'] is False:
raise InvalidArguments('"implib" keyword" must not be false if "export_dynamic" is set and not false.')
- kwargs['implib'] = True
if kwargs['export_dynamic'] is None:
kwargs['export_dynamic'] = False
- if kwargs['implib'] is None:
- kwargs['implib'] = False
+ if isinstance(kwargs['implib'], bool):
+ kwargs['implib'] = None
target = targetclass(name, self.subdir, self.subproject, for_machine, srcs, struct, objs,
self.environment, self.compilers[for_machine], kwargs)
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index 27beba6ae..a54a69ff0 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -730,7 +730,14 @@ _DARWIN_VERSIONS_KW: KwargInfo[T.List[T.Union[str, int]]] = KwargInfo(
_EXCLUSIVE_EXECUTABLE_KWS: T.List[KwargInfo] = [
KwargInfo('export_dynamic', (bool, NoneType), since='0.45.0'),
KwargInfo('gui_app', (bool, NoneType), deprecated='0.56.0', deprecated_message="Use 'win_subsystem' instead"),
- KwargInfo('implib', (bool, str, NoneType), since='0.42.0'),
+ KwargInfo(
+ 'implib',
+ (bool, str, NoneType),
+ since='0.42.0',
+ deprecated_values={
+ bool: ('1.10.0', 'Use "export_dynamic" keyword instead'),
+ },
+ ),
KwargInfo('pie', (bool, NoneType)),
KwargInfo(
'win_subsystem',