aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-10-25 19:48:42 +0300
committerGitHub <noreply@github.com>2018-10-25 19:48:42 +0300
commit6f6afe24a791d73bcb5106a7ca4cf6ec76eadeb6 (patch)
tree35414b82aa2ec2882cb9eb457f5a840f470b31e8 /mesonbuild/environment.py
parent0a217f40d717a1a0c2c7207ca494d314faba5106 (diff)
parent68d0adf4d268e15a35a5ce706f7a31b127a7fba7 (diff)
downloadmeson-6f6afe24a791d73bcb5106a7ca4cf6ec76eadeb6.zip
meson-6f6afe24a791d73bcb5106a7ca4cf6ec76eadeb6.tar.gz
meson-6f6afe24a791d73bcb5106a7ca4cf6ec76eadeb6.tar.bz2
Merge pull request #4326 from Ericson2314/per-machine
Start leveraging MachineInfo with for_* methods
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py84
1 files changed, 79 insertions, 5 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index c1a3654..8c6c60e 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -17,7 +17,7 @@ import configparser, os, platform, re, sys, shlex, shutil, subprocess
from . import coredata
from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker
from . import mesonlib
-from .mesonlib import EnvironmentException, Popen_safe
+from .mesonlib import EnvironmentException, PerMachine, Popen_safe
from . import mlog
from . import compilers
@@ -1130,6 +1130,20 @@ class MachineInfo:
self.cpu = cpu
self.endian = endian
+ def __eq__(self, other):
+ if self.__class__ is not other.__class__:
+ return NotImplemented
+ return \
+ self.system == other.system and \
+ self.cpu_family == other.cpu_family and \
+ self.cpu == other.cpu and \
+ self.endian == other.endian
+
+ def __ne__(self, other):
+ if self.__class__ is not other.__class__:
+ return NotImplemented
+ return not self.__eq__(other)
+
@staticmethod
def detect(compilers = None):
"""Detect the machine we're running on
@@ -1167,11 +1181,71 @@ class MachineInfo:
literal['cpu'],
endian)
-class MachineInfos:
+ def is_windows(self):
+ """
+ Machine is windows?
+ """
+ return self.system == 'windows'
+
+ def is_cygwin(self):
+ """
+ Machine is cygwin?
+ """
+ return self.system == 'cygwin'
+
+ def is_linux(self):
+ """
+ Machine is linux?
+ """
+ return self.system == 'linux'
+
+ def is_darwin(self):
+ """
+ Machine is Darwin (iOS/OS X)?
+ """
+ return self.system in ('darwin', 'ios')
+
+ def is_android(self):
+ """
+ Machine is Android?
+ """
+ return self.system == 'android'
+
+ def is_haiku(self):
+ """
+ Machine is Haiku?
+ """
+ return self.system == 'haiku'
+
+ def is_openbsd(self):
+ """
+ Machine is OpenBSD?
+ """
+ return self.system == 'openbsd'
+
+ # Various prefixes and suffixes for import libraries, shared libraries,
+ # static libraries, and executables.
+ # Versioning is added to these names in the backends as-needed.
+
+ def get_exe_suffix(self):
+ if self.is_windows() or self.is_cygwin():
+ return 'exe'
+ else:
+ return ''
+
+ def get_object_suffix(self):
+ if self.is_windows():
+ return 'obj'
+ else:
+ return 'o'
+
+ def libdir_layout_is_win(self):
+ return self.is_windows() \
+ or self.is_cygwin()
+
+class MachineInfos(PerMachine):
def __init__(self):
- self.build = None
- self.host = None
- self.target = None
+ super().__init__(None, None, None)
def default_missing(self):
"""Default host to buid and target to host.