diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-04-08 01:08:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-08 01:08:51 +0300 |
commit | d6e71d0c566416c0ba940323c6f2734695c999d0 (patch) | |
tree | f87bf2eddd51f69213419b117162274725c480a9 | |
parent | 09dd9e20df33c2ce91ec3304df6ad3909147987b (diff) | |
parent | 1105ba3afdf2f533782c5cc5ee984745989a1914 (diff) | |
download | meson-d6e71d0c566416c0ba940323c6f2734695c999d0.zip meson-d6e71d0c566416c0ba940323c6f2734695c999d0.tar.gz meson-d6e71d0c566416c0ba940323c6f2734695c999d0.tar.bz2 |
Merge pull request #3312 from MathieuDuponchelle/alwaysfallback
new wrap-mode: forcefallback
-rw-r--r-- | data/shell-completions/zsh/_meson | 2 | ||||
-rw-r--r-- | docs/markdown/FAQ.md | 6 | ||||
-rw-r--r-- | docs/markdown/snippets/new-wrap-mode.md | 3 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 11 | ||||
-rw-r--r-- | mesonbuild/wrap/__init__.py | 7 | ||||
-rwxr-xr-x | run_unittests.py | 6 | ||||
-rw-r--r-- | test cases/unit/27 forcefallback/meson.build | 8 | ||||
-rw-r--r-- | test cases/unit/27 forcefallback/subprojects/notzlib/meson.build | 7 | ||||
-rw-r--r-- | test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.c | 6 | ||||
-rw-r--r-- | test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.h | 18 | ||||
-rw-r--r-- | test cases/unit/27 forcefallback/test_not_zlib.c | 8 |
11 files changed, 76 insertions, 6 deletions
diff --git a/data/shell-completions/zsh/_meson b/data/shell-completions/zsh/_meson index 877d700..481d04c 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 f4cf89b..398604a 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` since 0.46.0. diff --git a/docs/markdown/snippets/new-wrap-mode.md b/docs/markdown/snippets/new-wrap-mode.md new file mode 100644 index 0000000..e33dd83 --- /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 e973c1e..b04d586 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 019634c..6e2bc83 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') diff --git a/run_unittests.py b/run_unittests.py index 9f0ae3f..4f688cd 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -950,6 +950,12 @@ class AllPlatformTests(BasePlatformTests): self.uninstall() self.assertPathDoesNotExist(exename) + def test_forcefallback(self): + testdir = os.path.join(self.unit_test_dir, '27 forcefallback') + self.init(testdir, ['--wrap-mode=forcefallback']) + self.build() + self.run_tests() + def test_testsetups(self): if not shutil.which('valgrind'): raise unittest.SkipTest('Valgrind not installed.') diff --git a/test cases/unit/27 forcefallback/meson.build b/test cases/unit/27 forcefallback/meson.build new file mode 100644 index 0000000..e6a90ea --- /dev/null +++ b/test cases/unit/27 forcefallback/meson.build @@ -0,0 +1,8 @@ +project('mainproj', 'c', + default_options : ['wrap_mode=forcefallback']) + +zlib_dep = dependency('zlib', fallback: ['notzlib', 'zlib_dep']) + +test_not_zlib = executable('test_not_zlib', ['test_not_zlib.c'], dependencies: [zlib_dep]) + +test('test_not_zlib', test_not_zlib) diff --git a/test cases/unit/27 forcefallback/subprojects/notzlib/meson.build b/test cases/unit/27 forcefallback/subprojects/notzlib/meson.build new file mode 100644 index 0000000..254a136 --- /dev/null +++ b/test cases/unit/27 forcefallback/subprojects/notzlib/meson.build @@ -0,0 +1,7 @@ +project('notzlib', 'c') + +notzlib_sources = ['notzlib.c'] + +notzlib = library('notzlib', notzlib_sources) + +zlib_dep = declare_dependency(link_with: notzlib, include_directories: include_directories(['.'])) diff --git a/test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.c b/test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.c new file mode 100644 index 0000000..c3b6bf9 --- /dev/null +++ b/test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.c @@ -0,0 +1,6 @@ +#include "notzlib.h" + +int not_a_zlib_function (void) +{ + return 42; +} diff --git a/test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.h b/test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.h new file mode 100644 index 0000000..695921d --- /dev/null +++ b/test cases/unit/27 forcefallback/subprojects/notzlib/notzlib.h @@ -0,0 +1,18 @@ +#pragma once + +#if defined _WIN32 || defined __CYGWIN__ +#if defined BUILDING_DLL + #define DLL_PUBLIC __declspec(dllexport) +#else + #define DLL_PUBLIC __declspec(dllimport) +#endif +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +int DLL_PUBLIC not_a_zlib_function (void); diff --git a/test cases/unit/27 forcefallback/test_not_zlib.c b/test cases/unit/27 forcefallback/test_not_zlib.c new file mode 100644 index 0000000..36256af --- /dev/null +++ b/test cases/unit/27 forcefallback/test_not_zlib.c @@ -0,0 +1,8 @@ +#include <notzlib.h> + +int main (int ac, char **av) +{ + if (not_a_zlib_function () != 42) + return 1; + return 0; +} |