aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-02-19 23:06:37 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-20 19:26:16 +0200
commit0c1c387703c04c8052161b7506c07f216329b232 (patch)
tree21c7c7a5213adac5e702be14f4d2f43fed053f56
parent79865474c72b6b7ac32586b683644b78adfff778 (diff)
downloadmeson-0c1c387703c04c8052161b7506c07f216329b232.zip
meson-0c1c387703c04c8052161b7506c07f216329b232.tar.gz
meson-0c1c387703c04c8052161b7506c07f216329b232.tar.bz2
gnome: Fix depend_files listing for compile_resources
Also add a unit test that will test all codepaths for old Glib tools versions. Closes https://github.com/mesonbuild/meson/issues/2860
-rw-r--r--mesonbuild/modules/gnome.py40
-rwxr-xr-xrun_unittests.py21
-rw-r--r--test cases/frameworks/7 gnome/meson.build13
-rw-r--r--test cases/frameworks/7 gnome/resources/meson.build2
4 files changed, 53 insertions, 23 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 218e3b3..569011e 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -15,13 +15,11 @@
'''This module provides helper functions for Gnome/GLib related
functionality such as gobject-introspection, gresources and gtk-doc'''
-from .. import build
import os
import copy
import subprocess
-from . import ModuleReturnValue
-from ..mesonlib import MesonException, OrderedSet, Popen_safe, extract_as_list
-from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
+
+from .. import build
from .. import mlog
from .. import mesonlib
from .. import compilers
@@ -29,6 +27,9 @@ from .. import interpreter
from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import find_program, get_include_args
from . import ExtensionModule
+from . import ModuleReturnValue
+from ..mesonlib import MesonException, OrderedSet, Popen_safe, extract_as_list
+from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
from ..interpreterbase import noKwargs, permittedKwargs
# gresource compilation is broken due to the way
@@ -233,17 +234,6 @@ class GnomeModule(ExtensionModule):
dep_files = stdout.split('\n')[:-1]
- # In generate-dependencies mode, glib-compile-resources doesn't raise
- # an error for missing resources but instead prints whatever filename
- # was listed in the input file. That's good because it means we can
- # handle resource files that get generated as part of the build, as
- # follows.
- #
- # If there are multiple generated resource files with the same basename
- # then this code will get confused.
- def exists_in_srcdir(f):
- return os.path.exists(os.path.join(state.environment.get_source_dir(), f))
-
depends = []
subdirs = []
for resfile in dep_files[:]:
@@ -267,21 +257,29 @@ class GnomeModule(ExtensionModule):
break
if fname is not None:
dep_files.remove(resfile)
- dep_files.append(
- mesonlib.File(
- is_built=True,
- subdir=dep.get_subdir(),
- fname=fname))
depends.append(dep)
subdirs.append(dep.get_subdir())
break
else:
- if not exists_in_srcdir(resfile):
+ # In generate-dependencies mode, glib-compile-resources doesn't raise
+ # an error for missing resources but instead prints whatever filename
+ # was listed in the input file. That's good because it means we can
+ # handle resource files that get generated as part of the build, as
+ # follows.
+ #
+ # If there are multiple generated resource files with the same basename
+ # then this code will get confused.
+ try:
+ f = mesonlib.File.from_source_file(state.environment.get_source_dir(),
+ ".", resfile)
+ except MesonException:
raise MesonException(
'Resource "%s" listed in "%s" was not found. If this is a '
'generated file, pass the target that generates it to '
'gnome.compile_resources() using the "dependencies" '
'keyword argument.' % (resfile, input_file))
+ dep_files.remove(resfile)
+ dep_files.append(f)
return dep_files, depends, subdirs
def _get_link_args(self, state, lib, depends=None, include_rpath=False,
diff --git a/run_unittests.py b/run_unittests.py
index 3a66211..ac627da 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -33,6 +33,7 @@ import mesonbuild.compilers
import mesonbuild.environment
import mesonbuild.mesonlib
import mesonbuild.coredata
+import mesonbuild.modules.gnome
from mesonbuild.interpreter import ObjectHolder
from mesonbuild.mesonlib import (
is_linux, is_windows, is_osx, is_cygwin, is_dragonflybsd,
@@ -525,7 +526,10 @@ class BasePlatformTests(unittest.TestCase):
self.privatedir = os.path.join(self.builddir, 'meson-private')
if inprocess:
try:
- out = run_configure(self.meson_mainfile, self.meson_args + args + extra_args)[1]
+ (returncode, out, _) = run_configure(self.meson_mainfile, self.meson_args + args + extra_args)
+ if returncode != 0:
+ self._print_meson_log()
+ raise RuntimeError('Configure failed')
except:
self._print_meson_log()
raise
@@ -2598,6 +2602,21 @@ endian = 'little'
self.init(testdir)
self.build()
+ def test_old_gnome_module_codepaths(self):
+ '''
+ A lot of code in the GNOME module is conditional on the version of the
+ glib tools that are installed, and breakages in the old code can slip
+ by once the CI has a newer glib version. So we force the GNOME module
+ to pretend that it's running on an ancient glib so the fallback code is
+ also tested.
+ '''
+ testdir = os.path.join(self.framework_test_dir, '7 gnome')
+ os.environ['MESON_UNIT_TEST_PRETEND_GLIB_OLD'] = "1"
+ mesonbuild.modules.gnome.native_glib_version = '2.20'
+ self.init(testdir, inprocess=True)
+ self.build()
+ mesonbuild.modules.gnome.native_glib_version = None
+
class LinuxArmCrossCompileTests(BasePlatformTests):
'''
diff --git a/test cases/frameworks/7 gnome/meson.build b/test cases/frameworks/7 gnome/meson.build
index c75c049..bb9d09f 100644
--- a/test cases/frameworks/7 gnome/meson.build
+++ b/test cases/frameworks/7 gnome/meson.build
@@ -9,6 +9,19 @@ if cc.get_id() == 'intel'
add_global_arguments('-wd2282', language : 'c')
endif
+py3 = import('python3').find_python()
+pycode = '''import os, sys
+if "MESON_UNIT_TEST_PRETEND_GLIB_OLD" in os.environ:
+ sys.exit(0)
+sys.exit(1)
+'''
+
+pretend_glib_old = false
+res = run_command(py3, '-c', pycode)
+if res.returncode() == 0
+ pretend_glib_old = true
+endif
+
gnome = import('gnome')
gio = dependency('gio-2.0')
giounix = dependency('gio-unix-2.0')
diff --git a/test cases/frameworks/7 gnome/resources/meson.build b/test cases/frameworks/7 gnome/resources/meson.build
index 3ebb2f5..b945cda 100644
--- a/test cases/frameworks/7 gnome/resources/meson.build
+++ b/test cases/frameworks/7 gnome/resources/meson.build
@@ -29,7 +29,7 @@ gnome.compile_resources('simple-resources',
)
test('simple resource test (gresource)', find_program('resources.py'))
-if glib.version() >= '2.52.0'
+if not pretend_glib_old and glib.version() >= '2.52.0'
# This test cannot pass if GLib version is older than 9.99.9.
# Meson will raise an error if the user tries to use the 'dependencies'
# argument and the version of GLib is too old for generated resource