aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers.py37
-rw-r--r--test cases/d/8 has multi arguments/installed_files.txt0
-rw-r--r--test cases/d/8 has multi arguments/meson.build6
3 files changed, 43 insertions, 0 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 97a1064..171aa5c 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -1914,6 +1914,43 @@ class DCompiler(Compiler):
paths = paths + ':' + padding
return ['-L-rpath={}'.format(paths)]
+ def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'):
+ if extra_args is None:
+ extra_args = []
+ elif isinstance(extra_args, str):
+ extra_args = [extra_args]
+ if dependencies is None:
+ dependencies = []
+ elif not isinstance(dependencies, list):
+ dependencies = [dependencies]
+ # Collect compiler arguments
+ args = CompilerArgs(self)
+ for d in dependencies:
+ # Add compile flags needed by dependencies
+ args += d.get_compile_args()
+ if mode == 'link':
+ # Add link flags needed to find dependencies
+ args += d.get_link_args()
+
+ if mode == 'compile':
+ # Add DFLAGS from the env
+ args += env.coredata.external_args[self.language]
+ elif mode == 'link':
+ # Add LDFLAGS from the env
+ args += env.coredata.external_link_args[self.language]
+ # extra_args must override all other arguments, so we add them last
+ args += extra_args
+ return args
+
+ def compiles(self, code, env, extra_args=None, dependencies=None, mode='compile'):
+ args = self._get_compiler_check_args(env, extra_args, dependencies, mode)
+
+ with self.compile(code, args, mode) as p:
+ return p.returncode == 0
+
+ def has_multi_arguments(self, args, env):
+ return self.compiles('int i;\n', env, extra_args=args)
+
@classmethod
def translate_args_to_nongnu(cls, args):
dcargs = []
diff --git a/test cases/d/8 has multi arguments/installed_files.txt b/test cases/d/8 has multi arguments/installed_files.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/d/8 has multi arguments/installed_files.txt
diff --git a/test cases/d/8 has multi arguments/meson.build b/test cases/d/8 has multi arguments/meson.build
new file mode 100644
index 0000000..2153cfd
--- /dev/null
+++ b/test cases/d/8 has multi arguments/meson.build
@@ -0,0 +1,6 @@
+project('D has arguments test', 'd')
+
+compiler = meson.get_compiler('d')
+
+compiler.compiles('int i;')
+compiler.has_argument('-I.')