diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2023-09-29 11:40:53 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2023-09-29 15:52:03 -0700 |
| commit | 937aab09c0971276da9dee239505c1233562708e (patch) | |
| tree | 1e2756138bb22d95fcaf0f3f6217101988dae6b1 | |
| parent | c9bdf441dd5e9d910069fb7dc7a8efe391b5ae07 (diff) | |
| download | meson-937aab09c0971276da9dee239505c1233562708e.tar.gz | |
interpreter: handle implib/export_dynamic conflicts in the interpreter
This differentiates export_dynamic being explicitly set to False from it
being unset. This allows us to deprecate explicitly setting
export_dynamic to false, but setting implib. This is already the case in
the other direction, if implib is False but export_dynamic is enabled
then we get a hard error.
This also moves the validation up to the Interpreter and out of the
build level.
| -rw-r--r-- | mesonbuild/build.py | 4 | ||||
| -rw-r--r-- | mesonbuild/interpreter/interpreter.py | 16 | ||||
| -rw-r--r-- | mesonbuild/interpreter/kwargs.py | 2 | ||||
| -rw-r--r-- | mesonbuild/interpreter/type_checking.py | 2 |
4 files changed, 18 insertions, 6 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 013733561..621b6c780 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1938,10 +1938,6 @@ class Executable(BuildTarget): 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') - if self.implib: - self.export_dynamic = True - if self.export_dynamic and self.implib is False: - raise InvalidArguments('"implib" keyword argument must not be false for if "export_dynamic" is true') # Only linkwithable if using export_dynamic self.is_linkwithable = self.export_dynamic # Remember that this exe was returned by `find_program()` through an override diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 794d2533b..cd3c5a59b 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -3327,6 +3327,7 @@ class Interpreter(InterpreterBase, HoldableObject): kwargs['include_directories'] = self.extract_incdirs(kwargs) if targetclass is build.Executable: + kwargs = T.cast('kwtypes.Executable', kwargs) if kwargs['gui_app'] is not None: if kwargs['win_subsystem'] is not None: raise InvalidArguments.from_node( @@ -3337,6 +3338,21 @@ class Interpreter(InterpreterBase, HoldableObject): if kwargs['win_subsystem'] is None: kwargs['win_subsystem'] = 'console' + if kwargs['implib']: + if kwargs['export_dynamic'] is False: + FeatureDeprecated.single_use('implib overrides explict export_dynamic off', '1.3.0', self.subprojct, + 'Do not set ths if want export_dynamic disabled if implib is enabled', + location=node) + kwargs['export_dynamic'] = True + 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 + target = targetclass(name, self.subdir, self.subproject, for_machine, srcs, struct, objs, self.environment, self.compilers[for_machine], kwargs) diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py index d0bfbc434..015886ecf 100644 --- a/mesonbuild/interpreter/kwargs.py +++ b/mesonbuild/interpreter/kwargs.py @@ -340,7 +340,7 @@ class _LibraryMixin(TypedDict): class Executable(_BuildTarget): - export_dynamic: bool + export_dynamic: T.Optional[bool] gui_app: T.Optional[bool] implib: T.Optional[T.Union[str, bool]] pie: T.Optional[bool] diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 3487a09d0..4fb11c497 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -588,7 +588,7 @@ _DARWIN_VERSIONS_KW: KwargInfo[T.List[T.Union[str, int]]] = KwargInfo( # Arguments exclusive to Executable. These are separated to make integrating # them into build_target easier _EXCLUSIVE_EXECUTABLE_KWS: T.List[KwargInfo] = [ - KwargInfo('export_dynamic', bool, default=False, since='0.45.0'), + 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('pie', (bool, NoneType)), |
