aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-06-11 12:44:53 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-06-22 12:06:10 -0700
commit93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0 (patch)
treed5913f089b2a69de191e5c67b1e8dc8010742b6d /mesonbuild/compilers/mixins
parent9d0ad66c29fccd2ff72c2b40da02cdb2b03ccba6 (diff)
downloadmeson-93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0.zip
meson-93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0.tar.gz
meson-93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0.tar.bz2
compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler, and we really need at least per-lanaguage if not per-compiler CompilerArgs classes, let's get the CompilerArgs instance from the compiler using a method.
Diffstat (limited to 'mesonbuild/compilers/mixins')
-rw-r--r--mesonbuild/compilers/mixins/clike.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index b32ac29..455fbe2 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -32,6 +32,7 @@ from pathlib import Path
from ... import arglist
from ... import mesonlib
from ... import mlog
+from ...arglist import CompilerArgs
from ...mesonlib import LibType
from .. import compilers
from .visualstudio import VisualStudioLikeCompiler
@@ -40,6 +41,18 @@ if T.TYPE_CHECKING:
from ...environment import Environment
+class CLikeCompilerArgs(CompilerArgs):
+ prepend_prefixes = ('-I', '-L')
+ dedup2_prefixes = ('-I', '-isystem', '-L', '-D', '-U')
+
+ # NOTE: not thorough. A list of potential corner cases can be found in
+ # https://github.com/mesonbuild/meson/pull/4593#pullrequestreview-182016038
+ dedup1_prefixes = ('-l', '-Wl,-l', '-Wl,--export-dynamic')
+ dedup1_suffixes = ('.lib', '.dll', '.so', '.dylib', '.a')
+
+ dedup1_args = ('-c', '-S', '-E', '-pipe', '-pthread')
+
+
class CLikeCompiler:
"""Shared bits for the C and CPP Compilers."""
@@ -62,6 +75,9 @@ class CLikeCompiler:
else:
self.exe_wrapper = exe_wrapper.get_command()
+ def compiler_args(self, args: T.Optional[T.Iterable[str]] = None) -> CLikeCompilerArgs:
+ return CLikeCompilerArgs(self, args)
+
def needs_static_linker(self):
return True # When compiling static libraries, so yes.
@@ -339,7 +355,7 @@ class CLikeCompiler:
elif not isinstance(dependencies, list):
dependencies = [dependencies]
# Collect compiler arguments
- cargs = arglist.CompilerArgs(self)
+ cargs = self.compiler_args()
largs = []
for d in dependencies:
# Add compile flags needed by dependencies