Sometimes, distros want to configure a project so that it does not
use any bundled library. In this case, meson.build might want
to do something like this, where slirp is a combo option
with values auto/system/internal:
slirp = dependency('', required: false)
if get_option('slirp') != 'internal'
slirp = dependency('slirp',
required: get_option('slirp') == 'system')
endif
if not slirp.found()
slirp = subproject('libslirp', ...) .variable('...')
endif
and we cannot use "fallback" because the "system" value should never
look for a subproject.
This worked until 0.54.x, but in 0.55.x this breaks because of the
automatic subproject search. Note that the desired effect here is
backwards compared to the policy of doing an automatic search on
"required: true"; we only want to do the search if "required" is false!
It would be possible to look for the dependency with `required: false`
and issue the error manually, but it's ugly and it may produce an error
message that looks "different" from Meson's.
Instead, with this change it is possible to achieve this effect in an
even simpler way:
slirp = dependency('slirp',
required: get_option('slirp') != 'auto',
allow_fallback: get_option('slirp') == 'system' ? false : ['slirp', 'libslirp_dep'])
The patch also adds support for "allow_fallback: true", which is
simple and enables automatic fallback to a wrap even for non-required
dependencies.
Automatic fallback to subprojects is complicated and should be
pointed out outside the "fallback" keyword argument. It is also
surprising that fallback to a subproject will not happen if
override_dependency has already been used with the request
dependency. Document all this.
Those function are common source of issue when used in a subproject because they
point to the parent project root which is rarely what is expected and is a
violation of subproject isolation.
This means that, in the common case of a simple meson.build which
doesn't contain any 'native: true' targets, we won't require a native
compiler when cross-compiling, without needing any changes in the
meson.build.
Documentation of most methods mentions method arguments enclosed in
parentheses. Two methods are an exception and we fix them here to make
the manual more consistent.
Should be "sources" not "source"
```
../meson.build:162: WARNING: Passed invalid keyword argument "source".
WARNING: This will become a hard error in the future.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 131, in run
return options.run_func(options)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/msetup.py", line 245, in run
app.generate()
File "/usr/local/lib/python3.7/site-packages/mesonbuild/msetup.py", line 159, in generate
self._generate(env)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/msetup.py", line 192, in _generate
intr.run()
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreter.py", line 4359, in run
super().run()
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 465, in run
self.evaluate_codeblock(self.ast, start=1)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 490, in evaluate_codeblock
raise e
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 483, in evaluate_codeblock
self.evaluate_statement(cur)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 498, in evaluate_statement
self.assignment(cur)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 1151, in assignment
value = self.evaluate_statement(node.value)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 500, in evaluate_statement
return self.method_call(cur)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 895, in method_call
return obj.method_call(method_name, args, self.kwargs_string_keys(kwargs))
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 39, in method_call
return method(args, kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
return f(*wrapped_args, **wrapped_kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 151, in wrapped
return f(*wrapped_args, **wrapped_kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 213, in wrapped
return f(*wrapped_args, **wrapped_kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreter.py", line 484, in partial_dependency_method
pdep = self.held_object.get_partial_dependency(**kwargs)
TypeError: get_partial_dependency() got an unexpected keyword argument 'source'
FAILED: build.ninja
```
D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.
Fixes#7082
The implementation of this function has changed enough that the name
doesn't really reflect what it actually does. It basically returns true
unless you're cross compiling, need and exe_wrapper, and don't have one.
The original function remains but is marked as deprecated.
This makes one small change the meson source language, which is that it
defines that can_run_host_binaries will return true in build == host
compilation, which was the behavior that already existed. Previously
this was undefined in build == host compilation.
Gtest can output junit results with a command line switch. We can parse
this to get more detailed results than the returncode, and put those in
our own Junit output. We basically just throw away the top level
'testsuites' object, then fixup the names of the tests, and shove that
into our junit.
- ExternalProgramHolder has path() method while CustomTargetHolder and
BuildTargetHolder have full_path().
- The returned ExternalProgramHolder's path() method was broken, because
build.Executable object has no get_path() method, it needs the
backend.
- find_program('overridden_prog', version : '>=1.0') was broken because
it needs to execute the exe that is not yet built. Now assume the
program has the (sub)project version.
- If the version check fails, interpreter uses
ExternalProgramHolder.get_name() for the error message but
build.Executable does not implement get_name() method.
Refine documentation of the default name_prefix, so people don't get the
impression they can write logic which uses 'lib' as the default, when
they should be defaulting to '[]', to let us take care of the
complexities.
Similar to meson.override_find_program() but overrides the result of the
dependency() function.
Also ensure that dependency() always returns the same result when
looking for the same dependency, this fixes cases where parts of the
project could be using a system library and other parts use the library
provided by a subproject.
As any child of BuildTargetHolder might need the name of the object,
provides a method to get object name.
This is useful in gst-build to display the plugin name and not
the filename.
This is a significant speed-up on Windows because terminals are
slow to print things out.
Speed-up in gst-build on Windows:
```
meson install:
before: 5.1 seconds
after: 4.0 seconds
```
This improves the common case of a simple meson.build which doesn't
contain any 'native: true' targets to not require a native compiler when
cross-compiling, without needing any changes in the meson.build.
v2:
Do it the right way around!
Currently it's just like if all builtin/base/compiler options are
yielding. This patch makes possible to have non-yielding builtin
options. The value in is overriden in this order:
- Value from parent project
- Value from subproject's default_options if set
- Value from subproject() default_options if set
- Value from command line if set
The documentation of "order-only" dependencies is limited and their
various purposes are especially not clear. See issue #6391 for a recent
example, search the internet for many more. So mention the particular
purpose here while making the documentation barely longer.