aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/linkers/linkers.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-02-06 23:29:27 -0500
committerEli Schwartz <eschwartz@archlinux.org>2023-06-26 13:10:33 -0400
commita1ef957e349583f9affdce5b5a4f094860e91037 (patch)
tree01e0fd479c9b5c47b63b779bfb698e6c0785df4e /mesonbuild/linkers/linkers.py
parent6fad02db04534519e96f1ba66a178c6c9735554f (diff)
downloadmeson-a1ef957e349583f9affdce5b5a4f094860e91037.zip
meson-a1ef957e349583f9affdce5b5a4f094860e91037.tar.gz
meson-a1ef957e349583f9affdce5b5a4f094860e91037.tar.bz2
linkers: delay implementations import until detect is run
This saves on a 1500-line import at startup and may be skipped entirely if no compiled languages are used. In exchange, we move the implementation to a new file that is imported instead. Followup to commit ab20eb5bbc21ae855bcd211131132d2778602bcf.
Diffstat (limited to 'mesonbuild/linkers/linkers.py')
-rw-r--r--mesonbuild/linkers/linkers.py36
1 files changed, 4 insertions, 32 deletions
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index 21e0eeb..d7868f2 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -14,10 +14,10 @@
from __future__ import annotations
import abc
-import enum
import os
import typing as T
+from .base import ArLikeLinker, RSPFileSyntax
from .. import mesonlib
from ..mesonlib import EnvironmentException, MesonException
from ..arglist import CompilerArgs
@@ -28,15 +28,6 @@ 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
@@ -168,26 +159,7 @@ class IntelVisualStudioLinker(VisualStudioLikeLinker, StaticLinker):
VisualStudioLikeLinker.__init__(self, machine)
-class ArLikeLinker(StaticLinker):
- # POSIX requires supporting the dash, GNU permits omitting it
- std_args = ['-csr']
-
- def can_linker_accept_rsp(self) -> bool:
- # armar / AIX can't accept arguments using the @rsp syntax
- # in fact, only the 'ar' id can
- return False
-
- def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
- return self.std_args
-
- def get_output_args(self, target: str) -> T.List[str]:
- return [target]
-
- def rsp_file_syntax(self) -> RSPFileSyntax:
- return RSPFileSyntax.GCC
-
-
-class ArLinker(ArLikeLinker):
+class ArLinker(ArLikeLinker, StaticLinker):
id = 'ar'
def __init__(self, for_machine: mesonlib.MachineChoice, exelist: T.List[str]):
@@ -227,7 +199,7 @@ class AppleArLinker(ArLinker):
id = 'applear'
-class ArmarLinker(ArLikeLinker):
+class ArmarLinker(ArLikeLinker, StaticLinker):
id = 'armar'
@@ -322,7 +294,7 @@ class C2000Linker(TILinker):
id = 'ar2000'
-class AIXArLinker(ArLikeLinker):
+class AIXArLinker(ArLikeLinker, StaticLinker):
id = 'aixar'
std_args = ['-csr', '-Xany']