aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml4
-rw-r--r--authors.txt87
-rw-r--r--docs/markdown/Pkgconfig-module.md1
-rw-r--r--docs/markdown/Reference-manual.md10
-rw-r--r--docs/markdown/Release-notes-for-0.41.0.md14
-rw-r--r--docs/markdown/Running-Meson.md2
-rw-r--r--docs/markdown/Syntax.md2
-rw-r--r--docs/markdown/legal.md2
-rw-r--r--mesonbuild/backend/backends.py13
-rw-r--r--mesonbuild/backend/ninjabackend.py23
-rw-r--r--mesonbuild/backend/vs2010backend.py8
-rw-r--r--mesonbuild/compilers.py12
-rw-r--r--mesonbuild/coredata.py2
-rw-r--r--mesonbuild/dependencies.py43
-rw-r--r--mesonbuild/interpreter.py78
-rw-r--r--mesonbuild/mesonlib.py8
-rw-r--r--mesonbuild/mintro.py6
-rw-r--r--mesonbuild/modules/pkgconfig.py33
-rwxr-xr-xrun_project_tests.py10
-rwxr-xr-xrun_tests.py8
-rwxr-xr-xrun_unittests.py14
-rw-r--r--test cases/common/51 pkgconfig-gen/meson.build4
-rw-r--r--test cases/failing/47 pkgconfig variables reserved/meson.build16
-rw-r--r--test cases/failing/47 pkgconfig variables reserved/simple.c5
-rw-r--r--test cases/failing/47 pkgconfig variables reserved/simple.h6
-rw-r--r--test cases/failing/48 pkgconfig variables zero length/meson.build16
-rw-r--r--test cases/failing/48 pkgconfig variables zero length/simple.c5
-rw-r--r--test cases/failing/48 pkgconfig variables zero length/simple.h6
-rw-r--r--test cases/failing/49 pkgconfig variables zero length value/meson.build16
-rw-r--r--test cases/failing/49 pkgconfig variables zero length value/simple.c5
-rw-r--r--test cases/failing/49 pkgconfig variables zero length value/simple.h6
-rw-r--r--test cases/failing/50 pkgconfig variables not key value/meson.build16
-rw-r--r--test cases/failing/50 pkgconfig variables not key value/simple.c5
-rw-r--r--test cases/failing/50 pkgconfig variables not key value/simple.h6
-rw-r--r--test cases/frameworks/14 doxygen/installed_files.txt4
-rw-r--r--test cases/linuxlike/1 pkg-config/meson.build1
-rw-r--r--test cases/linuxlike/5 dependency versions/meson.build46
37 files changed, 347 insertions, 196 deletions
diff --git a/.travis.yml b/.travis.yml
index fbb11ac..5f4318d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,13 +31,13 @@ matrix:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ninja python3; fi
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull jpakkane/mesonci:yakkety; fi
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull jpakkane/mesonci:zesty; fi
# We need to copy the current checkout inside the Docker container,
# because it has the MR id to be tested checked out.
script:
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo FROM jpakkane/mesonci:yakkety > Dockerfile; fi
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo FROM jpakkane/mesonci:zesty > Dockerfile; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo ADD . /root >> Dockerfile; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build -t withgit .; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run withgit /bin/sh -c "cd /root && TRAVIS=true CC=$CC CXX=$CXX OBJC=$CC OBJCXX=$CXX ./run_tests.py -- $MESON_ARGS"; fi
diff --git a/authors.txt b/authors.txt
deleted file mode 100644
index 8a02848..0000000
--- a/authors.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-Authors of Meson build system
-
-Meson was originally designed and created by Jussi Pakkanen.
-
-
-The following people have submitted patches for the project
-
-Peter Koval
-Masashi Fujita
-Juhani Simola
-Robin McCorkell
-Axel Waggershauser
-Igor Gnatenko
-Hemmo Nieminen
-mfrischknecht
-Matthew Bekkema
-Afief Halumi
-Thibault Saunier
-Mathieu Duponchelle
-Jouni Roivas
-Rafaël Kooi
-Marko Raatikainen
-German Diago Gomez
-Kyle Manna
-Haakon Sporsheim
-Wink Saville
-Yoav Alon
-Martin Ejdestig
-Rémi Nicole
-Damián Nohales
-Nirbheek Chauhan
-Nicolas Schneider
-Luke Adams
-Rogiel Sulzbach
-Tim-Philipp Müller
-Emmanuele Bassi
-Martin Hostettler
-Sam Thursfield
-Noam Meltzer
-Vincent Szolnoky
-Zhe Wang
-Wim Taymans
-Matthias Klumpp
-Elliott Sales de Andrade
-Patrick Griffis
-Iain Lane
-Daniel Brendle
-Franz Zapata
-Emanuele Aina
-Guillaume Poirier-Morency
-Scott D Phillips
-Gautier Pelloux-Prayer
-Alexandre Foley
-Jouni Kosonen
-Aurelien Jarno
-Mark Schulte
-Paulo Antonio Alvarez
-Olexa Bilaniuk
-Daniel Stone
-Marc-Antoine Perennou
-Matthieu Gautier
-Kseniia Vasilchuk
-Philipp Geier
-Mike Sinkovsky
-Dima Krasner
-Fabio Porcedda
-Rodrigo Lourenço
-Sebastian Stang
-Marc Becker
-Michal Sojka
-Aaron Small
-Joe Baldino
-Peter Harris
-Roger Boerdijk
-melak47
-Philipp Ittershagen
-Dylan Baker
-Aaron Plattner
-Jon Turney
-Wade Berrier
-Richard Hughes
-Rafael Fontenelle
-Michael Olbrich
-Ernestas Kulik
-Thomas Hindoe Paaboel Andersen
-Paolo Borelli
-Mike Gilbert
diff --git a/docs/markdown/Pkgconfig-module.md b/docs/markdown/Pkgconfig-module.md
index 51fe6b2..6b9a968 100644
--- a/docs/markdown/Pkgconfig-module.md
+++ b/docs/markdown/Pkgconfig-module.md
@@ -20,3 +20,4 @@ The generated file's properties are specified with the following keyword argumen
- `requires_private` list of strings to put in the `Requires.private` field
- `libraries_private` list of strings to put in the `Libraries.private` field
- `install_dir` the directory to install to, defaults to the value of option `libdir` followed by `/pkgconfig`
+- `variables` a list of strings with custom variables to add to the generated file. The strings must be in the form `name=value` and may reference other pkgconfig variables, e.g. `datadir=${prefix}/share`. The names `prefix`, `libdir` and `installdir` are reserved and may not be used.
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 0e7cc57..c64419b 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -266,6 +266,16 @@ Meson will also autodetect scripts with a shebang line and run them with the exe
`program_name2` and later positional arguments are used as fallback strings to search for. This is meant to be used for cases where the program may have many alternative names, such as `foo` and `foo.py`. The function will check for the arguments one by one and the first one that is found is returned. Meson versions earlier than 0.37.0 only accept one argument.
+If you need to check for a program in a non-standard location, you can just pass an absolute path to `find_program`, e.g.
+```
+setcap = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
+```
+
+It is also possible to pass an array to `find_program` in case you need to construct the set of paths to search on the fly:
+```
+setcap = find_program(['setcap', '/usr/sbin/setcap', '/sbin/setcap'], required : false)
+```
+
If none of the programs are found, Meson will abort. You can tell it not to by setting the keyword argument `required` to false, and then use the `.found()` method on the returned object to check whether it was found or not.
The returned object also has methods that are documented in the [object methods section](#external-program-object) below.
diff --git a/docs/markdown/Release-notes-for-0.41.0.md b/docs/markdown/Release-notes-for-0.41.0.md
index a2a64de..8a7f263 100644
--- a/docs/markdown/Release-notes-for-0.41.0.md
+++ b/docs/markdown/Release-notes-for-0.41.0.md
@@ -24,3 +24,17 @@ The ninja backend now quotes special characters that may be interpreted by
ninja itself, providing better interoperability with custom commands. This
support may not be perfect; please report any issues found with special
characters to the issue tracker.
+
+## Pkgconfig support for custom variables
+
+The Pkgconfig module object can add arbitrary variables to the generated .pc
+file with the new `variables` keyword:
+```meson
+pkg.generate(libraries : libs,
+ subdirs : h,
+ version : '1.0',
+ name : 'libsimple',
+ filebase : 'simple',
+ description : 'A simple demo library.',
+ variables : ['datadir=${prefix}/data'])
+```
diff --git a/docs/markdown/Running-Meson.md b/docs/markdown/Running-Meson.md
index 2dbb755..0e8da43 100644
--- a/docs/markdown/Running-Meson.md
+++ b/docs/markdown/Running-Meson.md
@@ -58,7 +58,7 @@ If you are not using an IDE, Meson uses the [Ninja build system](https://ninja-b
ninja
-The main usability difference between Ninja and Make is that Ninja will automatically detect the number of CPUs in your computer and parallelize itself accordingly. You can override the amount of parallel processes used with the command line argument `-j <num processes>`.
+The main usability difference between Ninja and Make is that Ninja will automatically detect the number of CPUs in your computer and parallelize itself accordingly. You can override the amount of parallel processes used with the command line argument `-j <num processes>`.
It should be noted that after the initial configure step `ninja` is the only command you ever need to type to compile. No matter how you alter your source tree (short of moving it to a completely new location), Meson will detect the changes and regenerate itself accordingly. This is especially handy if you have multiple build directories. Often one of them is used for development (the "debug" build) and others only every now and then (such as a "static analysis" build). Any configuration can be built just by `cd`'ing to the corresponding directory and running Ninja.
diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md
index 6f43887..2a7428b 100644
--- a/docs/markdown/Syntax.md
+++ b/docs/markdown/Syntax.md
@@ -103,7 +103,7 @@ Strings also support a number of other methods that return transformed copies.
```meson
# Similar to the Python str.strip(). Removes leading/ending spaces and newlines
define = ' -Dsomedefine '
-stripped_define = target.strip()
+stripped_define = define.strip()
# 'stripped_define' now has the value '-Dsomedefine'
```
diff --git a/docs/markdown/legal.md b/docs/markdown/legal.md
index 56ab70b..474d129 100644
--- a/docs/markdown/legal.md
+++ b/docs/markdown/legal.md
@@ -1,6 +1,6 @@
# Legal information
-Meson is copyrighted by all members of the Meson development team. For details see the <tt>authors.txt</tt> file that comes with the source code. Meson is licensed under the [Apache 2 license].
+Meson is copyrighted by all members of the Meson development team. Meson is licensed under the [Apache 2 license].
Meson is a registered trademark of Jussi Pakkanen.
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 419d04f..b903f4c 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -419,7 +419,18 @@ class Backend:
# NOTE: We must preserve the order in which external deps are
# specified, so we reverse the list before iterating over it.
for dep in reversed(target.get_external_deps()):
- commands += dep.get_compile_args()
+ if compiler.language == 'vala':
+ if isinstance(dep, dependencies.PkgConfigDependency):
+ if dep.name == 'glib-2.0' and dep.version_reqs is not None:
+ for req in dep.version_reqs:
+ if req.startswith(('>=', '==')):
+ commands += ['--target-glib', req[2:]]
+ break
+ commands += ['--pkg', dep.name]
+ elif isinstance(dep, dependencies.ExternalLibrary):
+ commands += dep.get_lang_args('vala')
+ else:
+ commands += dep.get_compile_args()
# Qt needs -fPIC for executables
# XXX: We should move to -fPIC for all executables
if isinstance(target, build.Executable):
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index bbae408..797fb64 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1070,20 +1070,11 @@ int dummy;
vala_c_src.append(vala_c_file)
valac_outputs.append(vala_c_file)
- # TODO: Use self.generate_basic_compiler_args to get something more
- # consistent Until then, we should be careful to preserve the
- # precedence of arguments if it changes upstream.
- args = []
- args += valac.get_buildtype_args(self.get_option_for_target('buildtype', target))
- args += self.build.get_project_args(valac, target.subproject)
- args += self.build.get_global_args(valac)
- args += self.environment.coredata.external_args[valac.get_language()]
-
+ args = self.generate_basic_compiler_args(target, valac)
# Tell Valac to output everything in our private directory. Sadly this
# means it will also preserve the directory components of Vala sources
# found inside the build tree (generated sources).
args += ['-d', c_out_dir]
- args += ['-C']
if not isinstance(target, build.Executable):
# Library name
args += ['--library=' + target.name]
@@ -1112,18 +1103,6 @@ int dummy;
# Install GIR to default location if requested by user
if len(target.install_dir) > 3 and target.install_dir[3] is True:
target.install_dir[3] = os.path.join(self.environment.get_datadir(), 'gir-1.0')
- if self.get_option_for_target('werror', target):
- args += valac.get_werror_args()
- for d in target.get_external_deps():
- if isinstance(d, dependencies.PkgConfigDependency):
- if d.name == 'glib-2.0' and d.version_reqs is not None:
- for req in d.version_reqs:
- if req.startswith(('>=', '==')):
- args += ['--target-glib', req[2:]]
- break
- args += ['--pkg', d.name]
- elif isinstance(d, dependencies.ExternalLibrary):
- args += d.get_lang_args('vala')
# Detect gresources and add --gresources arguments for each
for (gres, gensrc) in other_src[1].items():
if isinstance(gensrc, modules.GResourceTarget):
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 533edf0..f97ab87 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -379,7 +379,7 @@ class Vs2010Backend(backends.Backend):
pl.text = self.platform
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
- guidelem.text = self.environment.coredata.test_guid
+ guidelem.text = '{%s}' % self.environment.coredata.test_guid
kw = ET.SubElement(globalgroup, 'Keyword')
kw.text = self.platform + 'Proj'
p = ET.SubElement(globalgroup, 'Platform')
@@ -636,7 +636,7 @@ class Vs2010Backend(backends.Backend):
# Globals
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
- guidelem.text = guid
+ guidelem.text = '{%s}' % guid
kw = ET.SubElement(globalgroup, 'Keyword')
kw.text = self.platform + 'Proj'
ns = ET.SubElement(globalgroup, 'RootNamespace')
@@ -1050,7 +1050,7 @@ class Vs2010Backend(backends.Backend):
pl.text = self.platform
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
- guidelem.text = self.environment.coredata.test_guid
+ guidelem.text = '{%s}' % self.environment.coredata.test_guid
kw = ET.SubElement(globalgroup, 'Keyword')
kw.text = self.platform + 'Proj'
p = ET.SubElement(globalgroup, 'Platform')
@@ -1130,7 +1130,7 @@ if %%errorlevel%% neq 0 goto :VCEnd'''
pl.text = self.platform
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
- guidelem.text = self.environment.coredata.test_guid
+ guidelem.text = '{%s}' % self.environment.coredata.test_guid
kw = ET.SubElement(globalgroup, 'Keyword')
kw.text = self.platform + 'Proj'
p = ET.SubElement(globalgroup, 'Platform')
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 406c719..a36f184 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -1678,6 +1678,18 @@ class ValaCompiler(Compiler):
def get_compile_only_args(self):
return ['-C']
+ def get_pic_args(self):
+ return []
+
+ def get_always_args(self):
+ return ['-C']
+
+ def get_warn_args(self, warning_level):
+ return []
+
+ def get_no_warn_args(self):
+ return ['--disable-warnings']
+
def get_werror_args(self):
return ['--fatal-warnings']
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 2dd57a9..6c091c8 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -160,7 +160,7 @@ class CoreData:
self.wrap_mode = options.wrap_mode
self.compilers = OrderedDict()
self.cross_compilers = OrderedDict()
- self.deps = {}
+ self.deps = OrderedDict()
self.modules = {}
# Only to print a warning if it changes between Meson invocations.
self.pkgconf_envvar = os.environ.get('PKG_CONFIG_PATH', '')
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index 37e2cbd..d9a7c9c 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -27,9 +27,10 @@ import subprocess
import sysconfig
from enum import Enum
from collections import OrderedDict
-from . mesonlib import MesonException, version_compare, version_compare_many, Popen_safe
from . import mlog
from . import mesonlib
+from .mesonlib import Popen_safe, flatten
+from .mesonlib import MesonException, version_compare, version_compare_many
from .environment import detect_cpu_family, for_windows
class DependencyException(MesonException):
@@ -103,6 +104,7 @@ class InternalDependency(Dependency):
def __init__(self, version, incdirs, compile_args, link_args, libraries, sources, ext_deps):
super().__init__('internal', {})
self.version = version
+ self.is_found = True
self.include_directories = incdirs
self.compile_args = compile_args
self.link_args = link_args
@@ -127,6 +129,7 @@ class PkgConfigDependency(Dependency):
def __init__(self, name, environment, kwargs):
Dependency.__init__(self, 'pkgconfig', kwargs)
self.is_libtool = False
+ self.version_reqs = kwargs.get('version', None)
self.required = kwargs.get('required', True)
self.static = kwargs.get('static', False)
self.silent = kwargs.get('silent', False)
@@ -187,7 +190,6 @@ class PkgConfigDependency(Dependency):
''.format(self.type_string, name))
return
found_msg = [self.type_string + ' dependency', mlog.bold(name), 'found:']
- self.version_reqs = kwargs.get('version', None)
if self.version_reqs is None:
self.is_found = True
else:
@@ -1635,6 +1637,7 @@ class LLVMDependency(Dependency):
llvmconfig = None
_llvmconfig_found = False
__best_found = None
+ __cpp_blacklist = {'-DNDEBUG'}
def __init__(self, environment, kwargs):
super().__init__('llvm-config', kwargs)
@@ -1651,7 +1654,7 @@ class LLVMDependency(Dependency):
self.check_llvmconfig(req_version)
if not self._llvmconfig_found:
if self.__best_found is not None:
- mlog.log('found {!r} but need:'.format(self.version),
+ mlog.log('found {!r} but need:'.format(self.__best_found),
req_version)
else:
mlog.log("No llvm-config found; can't detect dependency")
@@ -1680,7 +1683,7 @@ class LLVMDependency(Dependency):
p, out = Popen_safe([self.llvmconfig, '--cppflags'])[:2]
if p.returncode != 0:
raise DependencyException('Could not generate includedir for LLVM.')
- self.cargs = shlex.split(out)
+ self.cargs = list(mesonlib.OrderedSet(shlex.split(out)).difference(self.__cpp_blacklist))
p, out = Popen_safe([self.llvmconfig, '--components'])[:2]
if p.returncode != 0:
@@ -1742,21 +1745,23 @@ class LLVMDependency(Dependency):
return True
-def get_dep_identifier(name, kwargs):
- elements = [name]
- modlist = kwargs.get('modules', [])
- if isinstance(modlist, str):
- modlist = [modlist]
- for module in modlist:
- elements.append(module)
- # We use a tuple because we need a non-mutable structure to use as the key
- # of a dictionary and a string has potential for name collisions
- identifier = tuple(elements)
- identifier += ('main', kwargs.get('main', False))
- identifier += ('static', kwargs.get('static', False))
- if 'fallback' in kwargs:
- f = kwargs.get('fallback')
- identifier += ('fallback', f[0], f[1])
+def get_dep_identifier(name, kwargs, want_cross):
+ # Need immutable objects since the identifier will be used as a dict key
+ version_reqs = flatten(kwargs.get('version', []))
+ if isinstance(version_reqs, list):
+ version_reqs = frozenset(version_reqs)
+ identifier = (name, version_reqs, want_cross)
+ for key, value in kwargs.items():
+ # 'version' is embedded above as the second element for easy access
+ # 'native' is handled above with `want_cross`
+ # 'required' is irrelevant for caching; the caller handles it separately
+ # 'fallback' subprojects cannot be cached -- they must be initialized
+ if key in ('version', 'native', 'required', 'fallback',):
+ continue
+ # All keyword arguments are strings, ints, or lists (or lists of lists)
+ if isinstance(value, list):
+ value = frozenset(flatten(value))
+ identifier += (key, value)
return identifier
def find_external_dependency(name, environment, kwargs):
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 80d482e..5df26cc 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -23,7 +23,8 @@ from . import compilers
from .wrap import wrap, WrapMode
from . import mesonlib
from .mesonlib import FileMode, Popen_safe, get_meson_script
-from .dependencies import InternalDependency, Dependency, ExternalProgram
+from .dependencies import ExternalProgram
+from .dependencies import InternalDependency, Dependency, DependencyException
from .interpreterbase import InterpreterBase
from .interpreterbase import check_stringlist, noPosargs, noKwargs, stringArgs
from .interpreterbase import InterpreterException, InvalidArguments, InvalidCode
@@ -1852,13 +1853,7 @@ class Interpreter(InterpreterBase):
def func_find_library(self, node, args, kwargs):
mlog.log(mlog.red('DEPRECATION:'), 'find_library() is removed, use the corresponding method in compiler object instead.')
- def func_dependency(self, node, args, kwargs):
- self.validate_arguments(args, 1, [str])
- name = args[0]
- if '<' in name or '>' in name or '=' in name:
- raise InvalidArguments('Characters <, > and = are forbidden in dependency names. To specify'
- 'version\n requirements use the \'version\' keyword argument instead.')
- identifier = dependencies.get_dep_identifier(name, kwargs)
+ def _find_cached_dep(self, name, kwargs):
# Check if we want this as a cross-dep or a native-dep
# FIXME: Not all dependencies support such a distinction right now,
# and we repeat this check inside dependencies that do. We need to
@@ -1868,60 +1863,79 @@ class Interpreter(InterpreterBase):
want_cross = not kwargs['native']
else:
want_cross = is_cross
- # Check if we've already searched for and found this dep
+ identifier = dependencies.get_dep_identifier(name, kwargs, want_cross)
cached_dep = None
+ # Check if we've already searched for and found this dep
if identifier in self.coredata.deps:
cached_dep = self.coredata.deps[identifier]
- if 'version' in kwargs:
- wanted = kwargs['version']
- found = cached_dep.get_version()
- if not cached_dep.found() or \
- not mesonlib.version_compare_many(found, wanted)[0]:
- # Cached dep has the wrong version. Check if an external
- # dependency or a fallback dependency provides it.
- cached_dep = None
- # Don't re-use cached dep if it wasn't required but this one is,
- # so we properly go into fallback/error code paths
- if kwargs.get('required', True) and not getattr(cached_dep, 'required', False):
- cached_dep = None
- # Don't reuse cached dep if one is a cross-dep and the other is a native dep
- if not getattr(cached_dep, 'want_cross', is_cross) == want_cross:
- cached_dep = None
+ else:
+ # Check if exactly the same dep with different version requirements
+ # was found already.
+ wanted = identifier[1]
+ for trial, trial_dep in self.coredata.deps.items():
+ # trial[1], identifier[1] are the version requirements
+ if trial[0] != identifier[0] or trial[2:] != identifier[2:]:
+ continue
+ found = trial_dep.get_version()
+ if not wanted or mesonlib.version_compare_many(found, wanted)[0]:
+ # We either don't care about the version, or our
+ # version requirements matched the trial dep's version.
+ cached_dep = trial_dep
+ break
+ return identifier, cached_dep
+
+ def func_dependency(self, node, args, kwargs):
+ self.validate_arguments(args, 1, [str])
+ name = args[0]
+ if '<' in name or '>' in name or '=' in name:
+ raise InvalidArguments('Characters <, > and = are forbidden in dependency names. To specify'
+ 'version\n requirements use the \'version\' keyword argument instead.')
+ identifier, cached_dep = self._find_cached_dep(name, kwargs)
if cached_dep:
+ if kwargs.get('required', True) and not cached_dep.found():
+ m = 'Dependency {!r} was already checked and was not found'
+ raise DependencyException(m.format(name))
dep = cached_dep
else:
# We need to actually search for this dep
exception = None
dep = None
- # If the fallback has already been configured (possibly by a higher level project)
- # try to use it before using the native version
+ # If the dependency has already been configured, possibly by
+ # a higher level project, try to use it first.
if 'fallback' in kwargs:
dirname, varname = self.get_subproject_infos(kwargs)
if dirname in self.subprojects:
+ subproject = self.subprojects[dirname]
try:
- dep = self.subprojects[dirname].get_variable_method([varname], {})
- dep = dep.held_object
+ # Never add fallback deps to self.coredata.deps
+ return subproject.get_variable_method([varname], {})
except KeyError:
pass
+ # Search for it outside the project
if not dep:
try:
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
- except dependencies.DependencyException as e:
+ except DependencyException as e:
exception = e
pass
+ # Search inside the projects list
if not dep or not dep.found():
if 'fallback' in kwargs:
fallback_dep = self.dependency_fallback(name, kwargs)
if fallback_dep:
+ # Never add fallback deps to self.coredata.deps since we
+ # cannot cache them. They must always be evaluated else
+ # we won't actually read all the build files.
return fallback_dep
-
if not dep:
raise exception
- self.coredata.deps[identifier] = dep
+ # Only store found-deps in the cache
+ if dep.found():
+ self.coredata.deps[identifier] = dep
return DependencyHolder(dep)
def get_subproject_infos(self, kwargs):
@@ -2230,7 +2244,7 @@ class Interpreter(InterpreterBase):
absname = os.path.join(self.environment.get_source_dir(), buildfilename)
if not os.path.isfile(absname):
self.subdir = prev_subdir
- raise InterpreterException('Nonexistent build def file %s.' % buildfilename)
+ raise InterpreterException('Non-existent build file {!r}'.format(buildfilename))
with open(absname, encoding='utf8') as f:
code = f.read()
assert(isinstance(code, str))
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index fbd732a..54e8016 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -305,7 +305,7 @@ def version_compare(vstr1, vstr2, strict=False):
return cmpop(varr1, varr2)
def version_compare_many(vstr1, conditions):
- if not isinstance(conditions, (list, tuple)):
+ if not isinstance(conditions, (list, tuple, frozenset)):
conditions = [conditions]
found = []
not_found = []
@@ -708,7 +708,8 @@ class OrderedSet(collections.MutableSet):
def __repr__(self):
# Don't print 'OrderedSet("")' for an empty set.
if self.__container:
- return 'OrderedSet("{}")'.format('", "'.join(self.__container.keys()))
+ return 'OrderedSet("{}")'.format(
+ '", "'.join(repr(e) for e in self.__container.keys()))
return 'OrderedSet()'
def add(self, value):
@@ -721,3 +722,6 @@ class OrderedSet(collections.MutableSet):
def update(self, iterable):
for item in iterable:
self.__container[item] = None
+
+ def difference(self, set_):
+ return type(self)(e for e in self if e not in set_)
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index c12c4dd..88ea16e 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -161,12 +161,12 @@ def list_buildsystem_files(coredata, builddata):
print(json.dumps(filelist))
def list_deps(coredata):
- result = {}
- for d in coredata.deps.values():
+ result = []
+ for d in coredata.deps:
if d.found():
args = {'compile_args': d.get_compile_args(),
'link_args': d.get_link_args()}
- result[d.name] = args
+ result += [d.name, args]
print(json.dumps(result))
def list_tests(testdata):
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index e79371f..09c615a 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -43,7 +43,7 @@ class PkgConfigModule(ExtensionModule):
def generate_pkgconfig_file(self, state, libraries, subdirs, name, description,
url, version, pcfile, pub_reqs, priv_reqs,
- conflicts, priv_libs):
+ conflicts, priv_libs, variables):
coredata = state.environment.get_coredata()
outdir = state.environment.scratch_dir
fname = os.path.join(outdir, pcfile)
@@ -53,6 +53,8 @@ class PkgConfigModule(ExtensionModule):
# 'os.path.join' for details)
ofile.write('libdir=%s\n' % os.path.join('${prefix}', coredata.get_builtin_option('libdir')))
ofile.write('includedir=%s\n' % os.path.join('${prefix}', coredata.get_builtin_option('includedir')))
+ for k, v in variables:
+ ofile.write('%s=%s\n' % (k, v))
ofile.write('\n')
ofile.write('Name: %s\n' % name)
if len(description) > 0:
@@ -136,6 +138,33 @@ class PkgConfigModule(ExtensionModule):
pub_reqs = mesonlib.stringlistify(kwargs.get('requires', []))
priv_reqs = mesonlib.stringlistify(kwargs.get('requires_private', []))
conflicts = mesonlib.stringlistify(kwargs.get('conflicts', []))
+
+ def parse_variable_list(stringlist):
+ reserved = ['prefix', 'libdir', 'includedir']
+ variables = []
+ for var in stringlist:
+ # foo=bar=baz is ('foo', 'bar=baz')
+ l = var.split('=', 1)
+ if len(l) < 2:
+ raise mesonlib.MesonException('Variables must be in \'name=value\' format')
+
+ name, value = l[0].strip(), l[1].strip()
+ if not name or not value:
+ raise mesonlib.MesonException('Variables must be in \'name=value\' format')
+
+ # Variable names must not contain whitespaces
+ if any(c.isspace() for c in name):
+ raise mesonlib.MesonException('Invalid whitespace in assignment "{}"'.format(var))
+
+ if name in reserved:
+ raise mesonlib.MesonException('Variable "{}" is reserved'.format(name))
+
+ variables.append((name, value))
+
+ return variables
+
+ variables = parse_variable_list(mesonlib.stringlistify(kwargs.get('variables', [])))
+
pcfile = filebase + '.pc'
pkgroot = kwargs.get('install_dir', None)
if pkgroot is None:
@@ -144,7 +173,7 @@ class PkgConfigModule(ExtensionModule):
raise mesonlib.MesonException('Install_dir must be a string.')
self.generate_pkgconfig_file(state, libs, subdirs, name, description, url,
version, pcfile, pub_reqs, priv_reqs,
- conflicts, priv_libs)
+ conflicts, priv_libs, variables)
res = build.Data(mesonlib.File(True, state.environment.get_scratch_dir(), pcfile), pkgroot)
return ModuleReturnValue(res, [res])
diff --git a/run_project_tests.py b/run_project_tests.py
index 1abc199..b8ef0e9 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -36,6 +36,7 @@ import concurrent.futures as conc
import re
from run_tests import get_backend_commands, get_backend_args_for_dir, Backend
+from run_tests import ensure_backend_detects_changes
class BuildStep(Enum):
@@ -342,6 +343,10 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
return TestResult('Test that should have failed succeeded', BuildStep.configure, stdo, stde, mesonlog, gen_time)
if returncode != 0:
return TestResult('Generating the build system failed.', BuildStep.configure, stdo, stde, mesonlog, gen_time)
+ # Touch the meson.build file to force a regenerate so we can test that
+ # regeneration works before a build is run.
+ ensure_backend_detects_changes(backend)
+ os.utime(os.path.join(testdir, 'meson.build'))
# Build with subprocess
dir_args = get_backend_args_for_dir(backend, test_build_dir)
build_start = time.time()
@@ -356,9 +361,8 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
if pc.returncode != 0:
return TestResult('Compiling source code failed.', BuildStep.build, stdo, stde, mesonlog, gen_time, build_time)
# Touch the meson.build file to force a regenerate so we can test that
- # regeneration works. We need to sleep for 0.2s because Ninja tracks mtimes
- # at a low resolution: https://github.com/ninja-build/ninja/issues/371
- time.sleep(0.2)
+ # regeneration works after a build is complete.
+ ensure_backend_detects_changes(backend)
os.utime(os.path.join(testdir, 'meson.build'))
test_start = time.time()
# Test in-process
diff --git a/run_tests.py b/run_tests.py
index d0a67e8..a374839 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -16,6 +16,7 @@
import os
import sys
+import time
import shutil
import subprocess
import platform
@@ -98,6 +99,13 @@ def get_backend_commands(backend, debug=False):
raise AssertionError('Unknown backend: {!r}'.format(backend))
return cmd, clean_cmd, test_cmd, install_cmd, uninstall_cmd
+def ensure_backend_detects_changes(backend):
+ # This is needed to increase the difference between build.ninja's
+ # timestamp and the timestamp of whatever you changed due to a Ninja
+ # bug: https://github.com/ninja-build/ninja/issues/371
+ if backend is Backend.ninja:
+ time.sleep(1)
+
def get_fake_options(prefix):
import argparse
opts = argparse.Namespace()
diff --git a/run_unittests.py b/run_unittests.py
index d285e6a..86e5a98 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -30,6 +30,7 @@ from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
from run_tests import exe_suffix, get_fake_options, FakeEnvironment
from run_tests import get_builddir_target_args, get_backend_commands, Backend
+from run_tests import ensure_backend_detects_changes
def get_soname(fname):
@@ -355,13 +356,6 @@ class BasePlatformTests(unittest.TestCase):
# XCode backend is untested with unit tests, help welcome!
self.no_rebuild_stdout = 'UNKNOWN BACKEND {!r}'.format(self.backend.name)
- def ensure_backend_detects_changes(self):
- # This is needed to increase the difference between build.ninja's
- # timestamp and the timestamp of whatever you changed due to a Ninja
- # bug: https://github.com/ninja-build/ninja/issues/371
- if self.backend is Backend.ninja:
- time.sleep(1)
-
def _print_meson_log(self):
log = os.path.join(self.logdir, 'meson-log.txt')
if not os.path.isfile(log):
@@ -439,14 +433,14 @@ class BasePlatformTests(unittest.TestCase):
def setconf(self, arg, will_build=True):
if will_build:
- self.ensure_backend_detects_changes()
+ ensure_backend_detects_changes(self.backend)
self._run(self.mconf_command + [arg, self.builddir])
def wipe(self):
shutil.rmtree(self.builddir)
def utime(self, f):
- self.ensure_backend_detects_changes()
+ ensure_backend_detects_changes(self.backend)
os.utime(f)
def get_compdb(self):
@@ -1180,6 +1174,8 @@ class LinuxlikeTests(BasePlatformTests):
self.assertTrue(simple_dep.found())
self.assertEqual(simple_dep.get_version(), '1.0')
self.assertIn('-lfoo', simple_dep.get_link_args())
+ self.assertEqual(simple_dep.get_pkgconfig_variable('foo'), 'bar')
+ self.assertPathEqual(simple_dep.get_pkgconfig_variable('datadir'), '/usr/data')
def test_vala_c_warnings(self):
'''
diff --git a/test cases/common/51 pkgconfig-gen/meson.build b/test cases/common/51 pkgconfig-gen/meson.build
index e1e41d9..68ee812 100644
--- a/test cases/common/51 pkgconfig-gen/meson.build
+++ b/test cases/common/51 pkgconfig-gen/meson.build
@@ -41,4 +41,6 @@ pkgg.generate(
libraries : lib2,
name : 'libfoo',
version : libver,
- description : 'A foo library.')
+ description : 'A foo library.',
+ variables : ['foo=bar', 'datadir=${prefix}/data']
+)
diff --git a/test cases/failing/47 pkgconfig variables reserved/meson.build b/test cases/failing/47 pkgconfig variables reserved/meson.build
new file mode 100644
index 0000000..82ae995
--- /dev/null
+++ b/test cases/failing/47 pkgconfig variables reserved/meson.build
@@ -0,0 +1,16 @@
+project('variables-reserved-test', 'c', version : '1.0')
+
+pkgg = import('pkgconfig')
+lib = shared_library('simple', 'simple.c')
+libver = '1.0'
+h = install_headers('simple.h')
+
+pkgg.generate(
+ libraries : [lib, '-lz'],
+ subdirs : '.',
+ version : libver,
+ name : 'libsimple',
+ filebase : 'simple',
+ description : 'A simple demo library.',
+ variables : [ 'prefix=/tmp/' ]
+)
diff --git a/test cases/failing/47 pkgconfig variables reserved/simple.c b/test cases/failing/47 pkgconfig variables reserved/simple.c
new file mode 100644
index 0000000..e8a6d83
--- /dev/null
+++ b/test cases/failing/47 pkgconfig variables reserved/simple.c
@@ -0,0 +1,5 @@
+#include"simple.h"
+
+int simple_function() {
+ return 42;
+}
diff --git a/test cases/failing/47 pkgconfig variables reserved/simple.h b/test cases/failing/47 pkgconfig variables reserved/simple.h
new file mode 100644
index 0000000..bb52e6d
--- /dev/null
+++ b/test cases/failing/47 pkgconfig variables reserved/simple.h
@@ -0,0 +1,6 @@
+#ifndef SIMPLE_H_
+#define SIMPLE_H_
+
+int simple_function();
+
+#endif
diff --git a/test cases/failing/48 pkgconfig variables zero length/meson.build b/test cases/failing/48 pkgconfig variables zero length/meson.build
new file mode 100644
index 0000000..65d3344
--- /dev/null
+++ b/test cases/failing/48 pkgconfig variables zero length/meson.build
@@ -0,0 +1,16 @@
+project('variables-zero-length-test', 'c', version : '1.0')
+
+pkgg = import('pkgconfig')
+lib = shared_library('simple', 'simple.c')
+libver = '1.0'
+h = install_headers('simple.h')
+
+pkgg.generate(
+ libraries : [lib, '-lz'],
+ subdirs : '.',
+ version : libver,
+ name : 'libsimple',
+ filebase : 'simple',
+ description : 'A simple demo library.',
+ variables : [ '=value' ]
+)
diff --git a/test cases/failing/48 pkgconfig variables zero length/simple.c b/test cases/failing/48 pkgconfig variables zero length/simple.c
new file mode 100644
index 0000000..e8a6d83
--- /dev/null
+++ b/test cases/failing/48 pkgconfig variables zero length/simple.c
@@ -0,0 +1,5 @@
+#include"simple.h"
+
+int simple_function() {
+ return 42;
+}
diff --git a/test cases/failing/48 pkgconfig variables zero length/simple.h b/test cases/failing/48 pkgconfig variables zero length/simple.h
new file mode 100644
index 0000000..bb52e6d
--- /dev/null
+++ b/test cases/failing/48 pkgconfig variables zero length/simple.h
@@ -0,0 +1,6 @@
+#ifndef SIMPLE_H_
+#define SIMPLE_H_
+
+int simple_function();
+
+#endif
diff --git a/test cases/failing/49 pkgconfig variables zero length value/meson.build b/test cases/failing/49 pkgconfig variables zero length value/meson.build
new file mode 100644
index 0000000..33977b2
--- /dev/null
+++ b/test cases/failing/49 pkgconfig variables zero length value/meson.build
@@ -0,0 +1,16 @@
+project('variables-zero-length-value-test', 'c', version : '1.0')
+
+pkgg = import('pkgconfig')
+lib = shared_library('simple', 'simple.c')
+libver = '1.0'
+h = install_headers('simple.h')
+
+pkgg.generate(
+ libraries : [lib, '-lz'],
+ subdirs : '.',
+ version : libver,
+ name : 'libsimple',
+ filebase : 'simple',
+ description : 'A simple demo library.',
+ variables : [ 'key=' ]
+)
diff --git a/test cases/failing/49 pkgconfig variables zero length value/simple.c b/test cases/failing/49 pkgconfig variables zero length value/simple.c
new file mode 100644
index 0000000..e8a6d83
--- /dev/null
+++ b/test cases/failing/49 pkgconfig variables zero length value/simple.c
@@ -0,0 +1,5 @@
+#include"simple.h"
+
+int simple_function() {
+ return 42;
+}
diff --git a/test cases/failing/49 pkgconfig variables zero length value/simple.h b/test cases/failing/49 pkgconfig variables zero length value/simple.h
new file mode 100644
index 0000000..bb52e6d
--- /dev/null
+++ b/test cases/failing/49 pkgconfig variables zero length value/simple.h
@@ -0,0 +1,6 @@
+#ifndef SIMPLE_H_
+#define SIMPLE_H_
+
+int simple_function();
+
+#endif
diff --git a/test cases/failing/50 pkgconfig variables not key value/meson.build b/test cases/failing/50 pkgconfig variables not key value/meson.build
new file mode 100644
index 0000000..02fa737
--- /dev/null
+++ b/test cases/failing/50 pkgconfig variables not key value/meson.build
@@ -0,0 +1,16 @@
+project('variables-not-key-value-test', 'c', version : '1.0')
+
+pkgg = import('pkgconfig')
+lib = shared_library('simple', 'simple.c')
+libver = '1.0'
+h = install_headers('simple.h')
+
+pkgg.generate(
+ libraries : [lib, '-lz'],
+ subdirs : '.',
+ version : libver,
+ name : 'libsimple',
+ filebase : 'simple',
+ description : 'A simple demo library.',
+ variables : [ 'this_should_be_key_value' ]
+)
diff --git a/test cases/failing/50 pkgconfig variables not key value/simple.c b/test cases/failing/50 pkgconfig variables not key value/simple.c
new file mode 100644
index 0000000..e8a6d83
--- /dev/null
+++ b/test cases/failing/50 pkgconfig variables not key value/simple.c
@@ -0,0 +1,5 @@
+#include"simple.h"
+
+int simple_function() {
+ return 42;
+}
diff --git a/test cases/failing/50 pkgconfig variables not key value/simple.h b/test cases/failing/50 pkgconfig variables not key value/simple.h
new file mode 100644
index 0000000..bb52e6d
--- /dev/null
+++ b/test cases/failing/50 pkgconfig variables not key value/simple.h
@@ -0,0 +1,6 @@
+#ifndef SIMPLE_H_
+#define SIMPLE_H_
+
+int simple_function();
+
+#endif
diff --git a/test cases/frameworks/14 doxygen/installed_files.txt b/test cases/frameworks/14 doxygen/installed_files.txt
index 72afb2e..e4f70e3 100644
--- a/test cases/frameworks/14 doxygen/installed_files.txt
+++ b/test cases/frameworks/14 doxygen/installed_files.txt
@@ -1,6 +1,4 @@
usr/share/doc/spede/html/annotated.html
-usr/share/doc/spede/html/arrowdown.png
-usr/share/doc/spede/html/arrowright.png
usr/share/doc/spede/html/bc_s.png
usr/share/doc/spede/html/bdwn.png
usr/share/doc/spede/html/classComedy_1_1Comedian.html
@@ -29,6 +27,8 @@ usr/share/doc/spede/html/functions_func.html
usr/share/doc/spede/html/hierarchy.html
usr/share/doc/spede/html/index.html
usr/share/doc/spede/html/jquery.js
+usr/share/doc/spede/html/menu.js
+usr/share/doc/spede/html/menudata.js
usr/share/doc/spede/html/namespaceComedy.html
usr/share/doc/spede/html/namespacemembers.html
usr/share/doc/spede/html/namespacemembers_func.html
diff --git a/test cases/linuxlike/1 pkg-config/meson.build b/test cases/linuxlike/1 pkg-config/meson.build
index 36a4545..7e43821 100644
--- a/test cases/linuxlike/1 pkg-config/meson.build
+++ b/test cases/linuxlike/1 pkg-config/meson.build
@@ -45,4 +45,3 @@ inc = include_directories('incdir')
r = cc.run(code, include_directories : inc, dependencies : zlibdep)
assert(r.returncode() == 0, 'Running manual zlib test failed.')
-
diff --git a/test cases/linuxlike/5 dependency versions/meson.build b/test cases/linuxlike/5 dependency versions/meson.build
index 1b01cd6..5c2c262 100644
--- a/test cases/linuxlike/5 dependency versions/meson.build
+++ b/test cases/linuxlike/5 dependency versions/meson.build
@@ -21,10 +21,18 @@ if dependency('zlib', version : ['<=1.0', '>=9999', '=' + zlib.version()], requi
error('zlib <=1.0 >=9999 should not have been found')
endif
+# Test that a versionless zlib is found after not finding an optional zlib dep with version reqs
+zlibopt = dependency('zlib', required : false)
+assert(zlibopt.found() == true, 'zlib not found')
+
# Test https://github.com/mesonbuild/meson/pull/610
dependency('somebrokenlib', version : '>=2.0', required : false)
dependency('somebrokenlib', version : '>=1.0', required : false)
+# Search for an external dependency that won't be found, but must later be
+# found via fallbacks
+somelibnotfound = dependency('somelib', required : false)
+assert(somelibnotfound.found() == false, 'somelibnotfound was found?')
# Find internal dependency without version
somelibver = dependency('somelib',
fallback : ['somelibnover', 'some_dep'])
@@ -37,17 +45,51 @@ somelib = dependency('somelib',
somelibver = dependency('somelib',
version : '>= 0.3',
fallback : ['somelibver', 'some_dep'])
-# Find somelib again, but with a fallback that will fail
+# Find somelib again, but with a fallback that will fail because subproject does not exist
somelibfail = dependency('somelib',
version : '>= 0.2',
required : false,
fallback : ['somelibfail', 'some_dep'])
assert(somelibfail.found() == false, 'somelibfail found via wrong fallback')
+# Find somelib again, but with a fallback that will fail because dependency does not exist
+somefail_dep = dependency('somelib',
+ version : '>= 0.2',
+ required : false,
+ fallback : ['somelib', 'somefail_dep'])
+assert(somefail_dep.found() == false, 'somefail_dep found via wrong fallback')
-fakezlib_dep = dependency('zlib',
+# Fallback should only be used if the primary was not found
+fallbackzlib_dep = dependency('zlib',
+ fallback : ['somelib', 'fakezlib_dep'])
+assert(fallbackzlib_dep.type_name() == 'pkgconfig', 'fallbackzlib_dep should be of type "pkgconfig", not ' + fallbackzlib_dep.type_name())
+# Check that the above dependency was pkgconfig because the fallback wasn't
+# checked, not because the fallback didn't work
+fakezlib_dep = dependency('fakezlib',
fallback : ['somelib', 'fakezlib_dep'])
assert(fakezlib_dep.type_name() == 'internal', 'fakezlib_dep should be of type "internal", not ' + fakezlib_dep.type_name())
+# Check that you can find a dependency by not specifying a version after not
+# finding it by specifying a version. We add `static: true` here so that the
+# previously cached zlib dependencies don't get checked.
+dependency('zlib', static : true, version : '>=8000', required : false)
+dependency('zlib', static : true)
+
+# Check that you can find a dependency by specifying a correct version after
+# not finding it by specifying a wrong one. We add `method: pkg-config` here so that
+# the previously cached zlib dependencies don't get checked.
+bzip2 = dependency('zlib', method : 'pkg-config', version : '>=9000', required : false)
+bzip2 = dependency('zlib', method : 'pkg-config', version : '>=1.0')
+
+if meson.is_cross_build()
+ # Test caching of native and cross dependencies
+ # https://github.com/mesonbuild/meson/issues/1736
+ cross_prefix = dependency('zlib').get_pkgconfig_variable('prefix')
+ native_prefix = dependency('zlib', native : true).get_pkgconfig_variable('prefix')
+ assert(cross_prefix != '', 'cross zlib prefix is not defined')
+ assert(native_prefix != '', 'native zlib prefix is not defined')
+ assert(native_prefix != cross_prefix, 'native prefix == cross_prefix == ' + native_prefix)
+endif
+
foreach d : ['sdl2', 'gnustep', 'wx', 'gl', 'python3', 'boost', 'gtest', 'gmock']
dep = dependency(d, required : false)
if dep.found()