aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/linkers.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-03-09 14:04:02 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-03-14 22:05:55 -0700
commit320412b3bbe97d8779d715f992f7a88d3a461ace (patch)
treea5c15017ca17eacef97278441e46f59ac36136cc /mesonbuild/linkers.py
parentbe86199221046fa5527b93b8c7231c6c3af344d4 (diff)
downloadmeson-320412b3bbe97d8779d715f992f7a88d3a461ace.zip
meson-320412b3bbe97d8779d715f992f7a88d3a461ace.tar.gz
meson-320412b3bbe97d8779d715f992f7a88d3a461ace.tar.bz2
compilers/linkers: Add a methhod for getting the rspfile syntax
Diffstat (limited to 'mesonbuild/linkers.py')
-rw-r--r--mesonbuild/linkers.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py
index 2807003..acb2c44 100644
--- a/mesonbuild/linkers.py
+++ b/mesonbuild/linkers.py
@@ -13,6 +13,7 @@
# limitations under the License.
import abc
+import enum
import os
import typing as T
@@ -25,8 +26,19 @@ if T.TYPE_CHECKING:
from .mesonlib import MachineChoice
+@enum.unique
+class RSPFileSyntax(enum.Enum):
+
+ """Which RSP file syntax the compiler supports."""
+
+ MSVC = enum.auto()
+ GCC = enum.auto()
+
+
class StaticLinker:
+ id: str
+
def __init__(self, exelist: T.List[str]):
self.exelist = exelist
@@ -93,6 +105,15 @@ class StaticLinker:
def get_linker_always_args(self) -> T.List[str]:
return []
+ def rsp_file_syntax(self) -> RSPFileSyntax:
+ """The format of the RSP file that this compiler supports.
+
+ If `self.can_linker_accept_rsp()` returns True, then this needs to
+ be implemented
+ """
+ assert not self.can_linker_accept_rsp(), f'{self.id} linker accepts RSP, but doesn\' provide a supported format, this is a bug'
+ raise mesonlib.EnvironmentException(f'{self.id} does no implemnt rsp format, this shouldn\'t be called')
+
class VisualStudioLikeLinker:
always_args = ['/NOLOGO']
@@ -123,6 +144,9 @@ class VisualStudioLikeLinker:
from .compilers import VisualStudioCCompiler
return VisualStudioCCompiler.native_args_to_unix(args)
+ def rsp_file_syntax(self) -> RSPFileSyntax:
+ return RSPFileSyntax.MSVC
+
class VisualStudioLinker(VisualStudioLikeLinker, StaticLinker):
@@ -164,6 +188,9 @@ class ArLinker(StaticLinker):
def get_output_args(self, target: str) -> T.List[str]:
return [target]
+ def rsp_file_syntax(self) -> RSPFileSyntax:
+ return RSPFileSyntax.GCC
+
class ArmarLinker(ArLinker): # lgtm [py/missing-call-to-init]
@@ -178,10 +205,11 @@ class ArmarLinker(ArLinker): # lgtm [py/missing-call-to-init]
class DLinker(StaticLinker):
- def __init__(self, exelist: T.List[str], arch: str):
+ def __init__(self, exelist: T.List[str], arch: str, *, rsp_syntax: RSPFileSyntax = RSPFileSyntax.GCC):
super().__init__(exelist)
self.id = exelist[0]
self.arch = arch
+ self.__rsp_syntax = rsp_syntax
def get_std_link_args(self) -> T.List[str]:
return ['-lib']
@@ -198,6 +226,9 @@ class DLinker(StaticLinker):
return ['-m32']
return []
+ def rsp_file_syntax(self) -> RSPFileSyntax:
+ return self.__rsp_syntax
+
class CcrxLinker(StaticLinker):
@@ -355,6 +386,14 @@ class DynamicLinker(metaclass=abc.ABCMeta):
# avoid issues with quoting and max argument length
return mesonlib.is_windows()
+ def rsp_file_syntax(self) -> RSPFileSyntax:
+ """The format of the RSP file that this compiler supports.
+
+ If `self.can_linker_accept_rsp()` returns True, then this needs to
+ be implemented
+ """
+ return RSPFileSyntax.GCC
+
def get_always_args(self) -> T.List[str]:
return self.always_args.copy()
@@ -1137,6 +1176,9 @@ class VisualStudioLikeLinkerMixin:
"""The command to generate the import library."""
return self._apply_prefix(['/IMPLIB:' + implibname])
+ def rsp_file_syntax(self) -> RSPFileSyntax:
+ return RSPFileSyntax.MSVC
+
class MSVCDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):