aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/linkers
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2023-12-01 13:55:09 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2023-12-23 13:32:49 +0200
commit4761e4cad946b42daa8723672957e9c1eaeaa5be (patch)
tree328144b20f11726c407cd60e037c372cb279e32d /mesonbuild/linkers
parent360d81e4aa3eb1230997a7a1c74130bca00fd896 (diff)
downloadmeson-4761e4cad946b42daa8723672957e9c1eaeaa5be.zip
meson-4761e4cad946b42daa8723672957e9c1eaeaa5be.tar.gz
meson-4761e4cad946b42daa8723672957e9c1eaeaa5be.tar.bz2
Remove `get_buildtype_args` function
This is a first step to make `buildtype` a true alias of `debug` and `optimization` options. See #10808. Relates to: - #11645 - #12096 - #5920 - #5814 - #8220 - #8493 - #9540 - #10487 - #12265 - #8308 - #8214 - #7194 - #11732
Diffstat (limited to 'mesonbuild/linkers')
-rw-r--r--mesonbuild/linkers/linkers.py59
1 files changed, 27 insertions, 32 deletions
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index 0e18129..e4db015 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -45,7 +45,7 @@ class StaticLinker:
def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
return []
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
return []
def get_output_args(self, target: str) -> T.List[str]:
@@ -103,13 +103,14 @@ class DynamicLinker(metaclass=abc.ABCMeta):
"""Base class for dynamic linkers."""
- _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = {
+ _OPTIMIZATION_ARGS: T.Dict[str, T.List[str]] = {
'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
+ '0': [],
+ 'g': [],
+ '1': [],
+ '2': [],
+ '3': [],
+ 's': [],
}
@abc.abstractproperty
@@ -189,6 +190,11 @@ class DynamicLinker(metaclass=abc.ABCMeta):
"""
return []
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
+ # We can override these in children by just overriding the
+ # _OPTIMIZATION_ARGS value.
+ return mesonlib.listify([self._apply_prefix(a) for a in self._OPTIMIZATION_ARGS[optimization_level]])
+
def get_std_shared_lib_args(self) -> T.List[str]:
return []
@@ -210,11 +216,6 @@ class DynamicLinker(metaclass=abc.ABCMeta):
def sanitizer_args(self, value: str) -> T.List[str]:
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # We can override these in children by just overriding the
- # _BUILDTYPE_ARGS value.
- return self._BUILDTYPE_ARGS[buildtype]
-
def get_asneeded_args(self) -> T.List[str]:
return []
@@ -580,13 +581,14 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
for_machine = MachineChoice.HOST
def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]: ...
- _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = {
+ _OPTIMIZATION_ARGS: T.Dict[str, T.List[str]] = {
'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': ['-O1'],
- 'minsize': [],
- 'custom': [],
+ '0': [],
+ 'g': [],
+ '1': [],
+ '2': [],
+ '3': ['-O1'],
+ 's': [],
}
_SUBSYSTEMS: T.Dict[str, str] = {
@@ -601,11 +603,6 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
"boot_application": "16",
}
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # We can override these in children by just overriding the
- # _BUILDTYPE_ARGS value.
- return mesonlib.listify([self._apply_prefix(a) for a in self._BUILDTYPE_ARGS[buildtype]])
-
def get_pie_args(self) -> T.List[str]:
return ['-pie']
@@ -1231,15 +1228,16 @@ class VisualStudioLikeLinkerMixin(DynamicLinkerBase):
for_machine = MachineChoice.HOST
def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]: ...
- _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = {
+ _OPTIMIZATION_ARGS: T.Dict[str, T.List[str]] = {
'plain': [],
- 'debug': [],
- 'debugoptimized': [],
+ '0': [],
+ 'g': [],
+ '1': [],
+ '2': [],
# The otherwise implicit REF and ICF linker optimisations are disabled by
# /DEBUG. REF implies ICF.
- 'release': ['/OPT:REF'],
- 'minsize': ['/INCREMENTAL:NO', '/OPT:REF'],
- 'custom': [],
+ '3': ['/OPT:REF'],
+ 's': ['/INCREMENTAL:NO', '/OPT:REF'],
}
def __init__(self, exelist: T.List[str], for_machine: mesonlib.MachineChoice,
@@ -1250,9 +1248,6 @@ class VisualStudioLikeLinkerMixin(DynamicLinkerBase):
self.machine = machine
self.direct = direct
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return mesonlib.listify([self._apply_prefix(a) for a in self._BUILDTYPE_ARGS[buildtype]])
-
def invoked_by_compiler(self) -> bool:
return not self.direct