aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-06-02 23:29:33 +0200
committerXavier Claessens <xclaesse@gmail.com>2020-06-16 13:45:40 -0400
commit20709af4d2a2f7f4ece3ecd3a9c65da3075be891 (patch)
tree6049dc6e0d08d558330885dbb2d773cc7a27fd83
parentf40e1567f5b38000b47bfbdf307f843c07645f19 (diff)
downloadmeson-20709af4d2a2f7f4ece3ecd3a9c65da3075be891.zip
meson-20709af4d2a2f7f4ece3ecd3a9c65da3075be891.tar.gz
meson-20709af4d2a2f7f4ece3ecd3a9c65da3075be891.tar.bz2
interpreter: add support for --force-fallback-for
This new command line option allows specifying dependencies for which to force fallback. See the documentation for more information Fixes: #7218
-rw-r--r--docs/markdown/Builtin-options.md1
-rw-r--r--docs/markdown/Subprojects.md16
-rw-r--r--docs/markdown/snippets/force_fallback_for.md10
-rw-r--r--mesonbuild/coredata.py1
-rw-r--r--mesonbuild/interpreter.py11
-rwxr-xr-xrun_unittests.py6
6 files changed, 43 insertions, 2 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md
index 0fa127a..e7101d5 100644
--- a/docs/markdown/Builtin-options.md
+++ b/docs/markdown/Builtin-options.md
@@ -79,6 +79,7 @@ for details.
| warning_level {0, 1, 2, 3} | 1 | Set the warning level. From 0 = none to 3 = highest | no |
| werror | false | Treat warnings as errors | no |
| wrap_mode {default, nofallback,<br>nodownload, forcefallback} | default | Wrap mode to use | no |
+| force_fallback_for | [] | Force fallback for those dependencies | no |
<a name="build-type-options"></a>
For setting optimization levels and toggling debug, you can either set the
diff --git a/docs/markdown/Subprojects.md b/docs/markdown/Subprojects.md
index 8232da9..9c54d69 100644
--- a/docs/markdown/Subprojects.md
+++ b/docs/markdown/Subprojects.md
@@ -212,6 +212,9 @@ the following command-line options:
calls, and those are meant to be used for sources that cannot be
provided by the system, such as copylibs.
+ This option may be overriden by `--force-fallback-for` for specific
+ dependencies.
+
* **--wrap-mode=forcefallback**
Meson will not look at the system for any dependencies which have
@@ -220,6 +223,19 @@ the following command-line options:
want to specifically build against the library sources provided by
your subprojects.
+* **--force-fallback-for=list,of,dependencies**
+
+ Meson will not look at the system for any dependencies listed there,
+ provided a fallback was supplied when the dependency was declared.
+
+ This option takes precedence over `--wrap-mode=nofallback`, and when
+ used in combination with `--wrap-mode=nodownload` will only work
+ if the dependency has already been downloaded.
+
+ This is useful when your project has many fallback dependencies,
+ but you only want to build against the library sources for a few
+ of them.
+
## Download subprojects
*Since 0.49.0*
diff --git a/docs/markdown/snippets/force_fallback_for.md b/docs/markdown/snippets/force_fallback_for.md
new file mode 100644
index 0000000..b6af209
--- /dev/null
+++ b/docs/markdown/snippets/force_fallback_for.md
@@ -0,0 +1,10 @@
+## Force fallback for
+
+A newly-added `--force-fallback-for` command line option can now be used to
+force fallback for specific subprojects.
+
+Example:
+
+```
+meson build --force-fallback-for=foo,bar
+```
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index fdba84e..94f977f 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -1129,6 +1129,7 @@ builtin_options = OrderedDict([
('warning_level', BuiltinOption(UserComboOption, 'Compiler warning level to use', '1', choices=['0', '1', '2', '3'])),
('werror', BuiltinOption(UserBooleanOption, 'Treat warnings as errors', False, yielding=False)),
('wrap_mode', BuiltinOption(UserComboOption, 'Wrap mode', 'default', choices=['default', 'nofallback', 'nodownload', 'forcefallback'])),
+ ('force_fallback_for', BuiltinOption(UserArrayOption, 'Force fallback for those subprojects', [])),
])
builtin_options_per_machine = OrderedDict([
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 76dbebd..bfbb189 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -3568,7 +3568,8 @@ external dependencies (including libraries) must go to "dependencies".''')
return self.get_subproject_dep(name, display_name, dirname, varname, kwargs)
wrap_mode = self.coredata.get_builtin_option('wrap_mode')
- forcefallback = wrap_mode == WrapMode.forcefallback and has_fallback
+ force_fallback_for = self.coredata.get_builtin_option('force_fallback_for')
+ forcefallback = (wrap_mode == WrapMode.forcefallback or name in force_fallback_for) and has_fallback
if name != '' and not forcefallback:
self._handle_featurenew_dependencies(name)
kwargs['required'] = required and not has_fallback
@@ -3622,7 +3623,13 @@ external dependencies (including libraries) must go to "dependencies".''')
def dependency_fallback(self, name, display_name, kwargs):
required = kwargs.get('required', True)
- if self.coredata.get_builtin_option('wrap_mode') == WrapMode.nofallback:
+
+ # Explicitly listed fallback preferences for specific subprojects
+ # take precedence over wrap-mode
+ if name in self.coredata.get_builtin_option('force_fallback_for'):
+ mlog.log('Looking for a fallback subproject for the dependency',
+ mlog.bold(display_name), 'because:\nUse of fallback was forced for that specific subproject')
+ elif self.coredata.get_builtin_option('wrap_mode') == WrapMode.nofallback:
mlog.log('Not looking for a fallback subproject for the dependency',
mlog.bold(display_name), 'because:\nUse of fallback '
'dependencies is disabled.')
diff --git a/run_unittests.py b/run_unittests.py
index 93c1659..827e3c8 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2287,6 +2287,12 @@ class AllPlatformTests(BasePlatformTests):
self.build()
self.run_tests()
+ def test_force_fallback_for(self):
+ testdir = os.path.join(self.unit_test_dir, '31 forcefallback')
+ self.init(testdir, extra_args=['--force-fallback-for=zlib,foo'])
+ self.build()
+ self.run_tests()
+
def test_env_ops_dont_stack(self):
'''
Test that env ops prepend/append do not stack, and that this usage issues a warning