aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-08-08 12:27:04 -0400
committerJohn Ericson <git@JohnEricson.me>2019-06-09 13:13:20 -0400
commit32e827dcdc451e1c5dde952cf08e4b654eac7057 (patch)
treec6c6377ff8b45e9e50caa8100fc14333342932fa /mesonbuild/mesonlib.py
parent69005d6b1db5e0bf9cbf5b9c4bb3b5d6a346aadb (diff)
downloadmeson-32e827dcdc451e1c5dde952cf08e4b654eac7057.zip
meson-32e827dcdc451e1c5dde952cf08e4b654eac7057.tar.gz
meson-32e827dcdc451e1c5dde952cf08e4b654eac7057.tar.bz2
Use `env.machines.*` to avoid some `is_cross`
This is a small example of the `is_cross` removal the that abstraction enables.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py60
1 files changed, 21 insertions, 39 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index e3ddf28..1b07d85 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -463,93 +463,75 @@ def is_dragonflybsd() -> bool:
def is_freebsd() -> bool:
return platform.system().lower() == 'freebsd'
-def _get_machine_is_cross(env, is_cross):
- """
- This is not morally correct, but works for now. For cross builds the build
- and host machines differ. `is_cross == true` means the host machine, while
- `is_cross == false` means the build machine. Both are used in practice,
- even though the documentation refers to the host machine implying we should
- hard-code it. For non-cross builds `is_cross == false` is passed but the
- host and build machines are identical so it doesn't matter.
-
- Users for `for_*` should instead specify up front which machine they want
- and query that like:
-
- env.machines[MachineChoice.HOST].is_haiku()
-
- """
- for_machine = MachineChoice.HOST if is_cross else MachineChoice.BUILD
- return env.machines[for_machine]
-
-def for_windows(is_cross, env):
+def for_windows(env):
"""
Host machine is windows?
- Deprecated: Please use `env.machines[for_machine].is_windows()`.
+ Deprecated: Please use `env.machines.host.is_windows()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_windows()
+ return env.machines.host.is_windows()
-def for_cygwin(is_cross, env):
+def for_cygwin(env):
"""
Host machine is cygwin?
- Deprecated: Please use `env.machines[for_machine].is_cygwin()`.
+ Deprecated: Please use `env.machines.host.is_cygwin()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_cygwin()
+ return env.machines.host.is_cygwin()
-def for_linux(is_cross, env):
+def for_linux(env):
"""
Host machine is linux?
- Deprecated: Please use `env.machines[for_machine].is_linux()`.
+ Deprecated: Please use `env.machines.host.is_linux()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_linux()
+ return env.machines.host.is_linux()
-def for_darwin(is_cross, env):
+def for_darwin(env):
"""
Host machine is Darwin (iOS/OS X)?
- Deprecated: Please use `env.machines[for_machine].is_darwin()`.
+ Deprecated: Please use `env.machines.host.is_darwin()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_darwin()
+ return env.machines.host.is_darwin()
-def for_android(is_cross, env):
+def for_android(env):
"""
Host machine is Android?
- Deprecated: Please use `env.machines[for_machine].is_android()`.
+ Deprecated: Please use `env.machines.host.is_android()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_android()
+ return env.machines.host.is_android()
-def for_haiku(is_cross, env):
+def for_haiku(env):
"""
Host machine is Haiku?
- Deprecated: Please use `env.machines[for_machine].is_haiku()`.
+ Deprecated: Please use `env.machines.host.is_haiku()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_haiku()
+ return env.machines.host.is_haiku()
-def for_openbsd(is_cross, env):
+def for_openbsd(env):
"""
Host machine is OpenBSD?
- Deprecated: Please use `env.machines[for_machine].is_openbsd()`.
+ Deprecated: Please use `env.machines.host.is_openbsd()`.
Note: 'host' is the machine on which compiled binaries will run
"""
- return _get_machine_is_cross(env, is_cross).is_openbsd()
+ return env.machines.host.is_openbsd()
def exe_exists(arglist: List[str]) -> bool:
try: