From 31f0242a6fad3f15dc42f81927b5627c73516958 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Sat, 24 Mar 2018 23:44:50 +0100 Subject: [PATCH] new wrap-mode: forcefallback This can be useful to make sure that a project builds when its fallbacks are used on systems where external dependencies satisfy the version requirements, or to easily hack on the sources of a dependency for which a fallback exists. --- data/shell-completions/zsh/_meson | 2 +- docs/markdown/FAQ.md | 6 ++++++ docs/markdown/snippets/new-wrap-mode.md | 3 +++ mesonbuild/interpreter.py | 11 +++++++---- mesonbuild/wrap/__init__.py | 7 ++++++- 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 docs/markdown/snippets/new-wrap-mode.md diff --git a/data/shell-completions/zsh/_meson b/data/shell-completions/zsh/_meson index 877d70078..481d04cc5 100644 --- a/data/shell-completions/zsh/_meson +++ b/data/shell-completions/zsh/_meson @@ -31,7 +31,7 @@ local -i ret local __meson_backends="(ninja xcode ${(j. .)${:-vs{,2010,2015,2017}}})" local __meson_build_types="(plain debug debugoptimized minsize release)" -local __meson_wrap_modes="(WrapMode.{default,nofallback,nodownload})" +local __meson_wrap_modes="(WrapMode.{default,nofallback,nodownload,forcefallback})" local -a meson_commands=( 'setup:set up a build directory' diff --git a/docs/markdown/FAQ.md b/docs/markdown/FAQ.md index f4cf89bec..dffef8aa9 100644 --- a/docs/markdown/FAQ.md +++ b/docs/markdown/FAQ.md @@ -288,3 +288,9 @@ has a option called `wrap-mode` which can be used to disable wrap downloads altogether with `--wrap-mode=nodownload`. You can also disable dependency fallbacks altogether with `--wrap-mode=nofallback`, which also implies the `nodownload` option. + +If on the other hand, you want meson to always use the fallback +for dependencies, even when an external dependency exists and could +satisfy the version requirements, for example in order to make +sure your project builds when fallbacks are used, you can use +`--wrap-mode=forcefallback`. diff --git a/docs/markdown/snippets/new-wrap-mode.md b/docs/markdown/snippets/new-wrap-mode.md new file mode 100644 index 000000000..e33dd83e6 --- /dev/null +++ b/docs/markdown/snippets/new-wrap-mode.md @@ -0,0 +1,3 @@ +A new wrap mode was added, `--wrap-mode=forcefallback`. When this is set, +dependencies for which a fallback was provided will always use it, even +if an external dependency exists and satisfies the version requirements. diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 88565afb8..acb86f010 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2404,10 +2404,13 @@ to directly access options of other subprojects.''') dep = None # Search for it outside the project - try: - dep = dependencies.find_external_dependency(name, self.environment, kwargs) - except DependencyException as e: - exception = e + if self.coredata.wrap_mode != WrapMode.forcefallback or 'fallback' not in kwargs: + try: + dep = dependencies.find_external_dependency(name, self.environment, kwargs) + except DependencyException as e: + exception = e + else: + exception = DependencyException("fallback for %s not found" % name) # Search inside the projects list if not dep or not dep.found(): diff --git a/mesonbuild/wrap/__init__.py b/mesonbuild/wrap/__init__.py index 019634ca1..6e2bc832d 100644 --- a/mesonbuild/wrap/__init__.py +++ b/mesonbuild/wrap/__init__.py @@ -25,7 +25,12 @@ from enum import Enum # to use 'nofallback' so that any 'copylib' wraps will be # download as subprojects. # +# --wrap-mode=forcefallback will ignore external dependencies, +# even if they match the version requirements, and automatically +# use the fallback if one was provided. This is useful for example +# to make sure a project builds when using the fallbacks. +# # Note that these options do not affect subprojects that # are git submodules since those are only usable in git # repositories, and you almost always want to download them. -WrapMode = Enum('WrapMode', 'default nofallback nodownload') +WrapMode = Enum('WrapMode', 'default nofallback nodownload forcefallback')