[gimp] meson: fix CC_VERSION.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] meson: fix CC_VERSION.
- Date: Thu, 14 Nov 2019 19:48:39 +0000 (UTC)
commit ea379ef5a9f2409e8ea1ebe12d6ac8e462456d08
Author: Jehan <jehan girinstud io>
Date: Thu Nov 14 13:30:01 2019 +0100
meson: fix CC_VERSION.
The way we use CC_VERSION macro is to give information on the compiler
used during build. This information may be useful when debugging in
particular. So we can't just use `cc.version()` which only gives a
version number, not even the name of the compiler.
Restore the logics of autotools where we were using the result of `cc
-v` (for gcc and clang) and testing various CLI options for other
compilers.
Also this test may fail on meson because of various bugs, which I now
reported and provided patch for (hopefully soon merged). In particular,
when using ccache, the command run fails (also I have to change newlines
in C-style `\n` myself as meson's set_quoted() creates broken header
when newlines are present).
If it fails, let's at least store the compiler name + its version, still
more useful than version only.
meson.build | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index c11afbedc8..81f509325e 100644
--- a/meson.build
+++ b/meson.build
@@ -1339,7 +1339,34 @@ conf.set('HAVE_FUNC_ATTRIBUTE_DESTRUCTOR',
# Compiler
conf.set_quoted('CC', cc.get_id())
-conf.set_quoted('CC_VERSION', cc.version())
+
+cc_version=''
+if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
+ cc_cmd = run_command(cc, '-v')
+ # Note: the call might actually fail when using ccache.
+ # See: https://github.com/mesonbuild/meson/issues/6174
+ if cc_cmd.returncode() == 0
+ cc_version = cc_cmd.stdout() + cc_cmd.stderr()
+ endif
+else
+ # Various compilers have various options. Try most common ones. This
+ # list of options comes from autotools checks.
+ foreach arg : [ '--version', '-v', '-V', '-qversion' ]
+ cc_cmd = run_command(cc, arg)
+ if cc_cmd.returncode() == 0
+ cc_version = cc_cmd.stdout()
+ endif
+ endforeach
+endif
+if cc_version == ''
+ # We didn't manage to get a meaningful verbose version from the
+ # compiler. Just save its name and version.
+ cc_version = cc.get_id() + ' ' + cc.version()
+else
+ # See also: https://github.com/mesonbuild/meson/pull/6179
+ cc_version = '\\n'.join(cc_version.split('\n'))
+endif
+conf.set_quoted('CC_VERSION', cc_version)
# Names
conf.set_quoted('GIMP_PACKAGE', meson.project_name())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]