aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Users.md2
-rw-r--r--mesonbuild/compilers.py37
-rw-r--r--test cases/d/8 has multi arguments/meson.build8
3 files changed, 46 insertions, 1 deletions
diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md
index 0d24d6b..8cfaf94 100644
--- a/docs/markdown/Users.md
+++ b/docs/markdown/Users.md
@@ -9,7 +9,7 @@ If you have a project that uses Meson that you want to add to this list, let us
- [AQEMU](https://github.com/tobimensch/aqemu), a Qt GUI for QEMU virtual machines, since version 0.9.3
- [Arduino sample project](https://github.com/jpakkane/mesonarduino)
- [Emeus](https://github.com/ebassi/emeus), Constraint based layout manager for GTK+
- - [Frida.re](https://github.com/frida/frida-core), a code tracing framework
+ - [Frida](https://www.frida.re/), a dynamic binary instrumentation toolkit
- [GLib](https://github.com/centricular/glib/), cross-platform C library used by GTK+ (not merged yet)
- [Gnome Builder](https://git.gnome.org/browse/gnome-builder/), an IDE for the Gnome platform
- [Gnome MPV](https://github.com/gnome-mpv/gnome-mpv), Gnome frontend to the mpv video player
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 86ed2f4..e7c02b2 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -1915,6 +1915,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/meson.build b/test cases/d/8 has multi arguments/meson.build
new file mode 100644
index 0000000..31af648
--- /dev/null
+++ b/test cases/d/8 has multi arguments/meson.build
@@ -0,0 +1,8 @@
+project('D has arguments test', 'd')
+
+compiler = meson.get_compiler('d')
+
+assert(compiler.compiles('int i;'), 'Basic code test does not comple: ' + compiler.get_id())
+assert(compiler.has_multi_arguments(['-I.', '-J.']), 'Multi argument test does not work: ' + compiler.get_id())
+assert(compiler.has_argument('-I.'), 'Basic argument test does not work: ' + compiler.get_id())
+assert(compiler.has_argument('-flag_a_d_compiler_defenaitly_does_not_have') == false, 'Basic argument test does not work: ' + compiler.get_id())