From a1ef957e349583f9affdce5b5a4f094860e91037 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 6 Feb 2023 23:29:27 -0500 Subject: 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. --- mesonbuild/linkers/linkers.py | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) (limited to 'mesonbuild/linkers/linkers.py') 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'] -- cgit v1.1