mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
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.
This commit is contained in:
29
meson.build
29
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())
|
||||
|
Reference in New Issue
Block a user