interpreter: Rename has_exe_wrapper -> can_run_host_binaries

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.
pull/7152/head
Dylan Baker 5 years ago
parent 4e9e35f3bd
commit a63e36f7b1
  1. 7
      docs/markdown/Cross-compilation.md
  2. 12
      docs/markdown/Reference-manual.md
  3. 5
      docs/markdown/snippets/can_run_host_binaries.md
  4. 14
      mesonbuild/interpreter.py
  5. 2
      test cases/common/36 tryrun/meson.build
  6. 2
      test cases/common/93 selfbuilt custom/meson.build
  7. 2
      test cases/unit/36 exe_wrapper behaviour/meson.build

@ -231,13 +231,10 @@ The main *meson* object provides two functions to determine cross
compilation status.
```meson
meson.is_cross_build() # returns true when cross compiling
meson.has_exe_wrapper() # returns true if an exe wrapper has been defined
meson.is_cross_build() # returns true when cross compiling
meson.can_run_host_binaries() # returns true if the host binaries can be run, either with a wrapper or natively
```
Note that the latter gives undefined return value when doing a native
build.
You can run system checks on both the system compiler or the cross
compiler. You just have to specify which one to use.

@ -1836,10 +1836,14 @@ the following methods.
If `native: false` or not specified, variable is retrieved from the
cross-file if cross-compiling, and from the native-file when not cross-compiling.
- `has_exe_wrapper()` returns true when doing a cross build if there
is a wrapper command that can be used to execute cross built
binaries (for example when cross compiling from Linux to Windows,
one can use `wine` as the wrapper).
- `can_run_host_binaries()` returns true if the build machine can run
binaries compiled for the host. This returns true unless you are
cross compiling, need a helper to run host binaries, and don't have one.
For example when cross compiling from Linux to Windows, one can use `wine`
as the helper. *New in 0.55.0*
- `has_exe_wrapper()` alias of `can_run_host_binaries`
*Deprecated since 0.55.0*
- `install_dependency_manifest(output_name)` installs a manifest file
containing a list of all subprojects, their versions and license

@ -0,0 +1,5 @@
## Rename has_exe_wrapper -> can_run_host_binaries
The old name was confusing as it didn't really match the behavior of the
function. The old name remains as an alias (the behavior hasn't changed), but
is now deprecated.

@ -1873,6 +1873,7 @@ class MesonMain(InterpreterObject):
self.methods.update({'get_compiler': self.get_compiler_method,
'is_cross_build': self.is_cross_build_method,
'has_exe_wrapper': self.has_exe_wrapper_method,
'can_run_host_binaries': self.can_run_host_binaries_method,
'is_unity': self.is_unity_method,
'is_subproject': self.is_subproject_method,
'current_source_dir': self.current_source_dir_method,
@ -2023,9 +2024,16 @@ class MesonMain(InterpreterObject):
@noPosargs
@permittedKwargs({})
def has_exe_wrapper_method(self, args, kwargs):
if self.is_cross_build_method(None, None) and \
self.build.environment.need_exe_wrapper():
@FeatureDeprecated('meson.has_exe_wrapper', '0.55.0', 'use meson.can_run_host_binaries instead.')
def has_exe_wrapper_method(self, args: T.Tuple[object, ...], kwargs: T.Dict[str, object]) -> bool:
return self.can_run_host_binaries_method(args, kwargs)
@noPosargs
@permittedKwargs({})
@FeatureNew('meson.can_run_host_binaries', '0.55.0')
def can_run_host_binaries_method(self, args: T.Tuple[object, ...], kwargs: T.Dict[str, object]) -> bool:
if (self.is_cross_build_method(None, None) and
self.build.environment.need_exe_wrapper()):
if self.build.environment.exe_wrapper is None:
return False
# We return True when exe_wrap is defined, when it's not needed, and

@ -2,7 +2,7 @@ project('tryrun', 'c', 'cpp')
# Complex to exercise all code paths.
if meson.is_cross_build()
if meson.has_exe_wrapper()
if meson.can_run_host_binaries()
compilers = [meson.get_compiler('c', native : false), meson.get_compiler('cpp', native : false)]
else
compilers = [meson.get_compiler('c', native : true), meson.get_compiler('cpp', native : true)]

@ -26,7 +26,7 @@ ctlib = custom_target('ctlib',
build_by_default : true,
)
if meson.is_cross_build() and meson.has_exe_wrapper()
if meson.is_cross_build() and meson.can_run_host_binaries()
checkarg_host = executable('checkarg_host', 'checkarg.cpp')
ctlib_host = custom_target(

@ -1,7 +1,7 @@
project('exe wrapper behaviour', 'c')
assert(meson.is_cross_build(), 'not setup as cross build')
assert(meson.has_exe_wrapper(), 'exe wrapper not defined?')
assert(meson.has_exe_wrapper(), 'exe wrapper not defined?') # intentionally not changed to can_run_host_binaries,
exe = executable('prog', 'prog.c')

Loading…
Cancel
Save