aboutsummaryrefslogtreecommitdiff
path: root/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-07-25 23:08:13 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-07-27 00:55:27 +0300
commit37b2a195bd24d71044474129cdf4af3540770618 (patch)
tree239d718c31e4ff655d494bfcb52ff133b9cfc9ad /interpreter.py
parent463d08d5459a05807e63c833b56614bc8c59643a (diff)
downloadmeson-37b2a195bd24d71044474129cdf4af3540770618.zip
meson-37b2a195bd24d71044474129cdf4af3540770618.tar.gz
meson-37b2a195bd24d71044474129cdf4af3540770618.tar.bz2
Get build machine's CPU info too.
Diffstat (limited to 'interpreter.py')
-rw-r--r--interpreter.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/interpreter.py b/interpreter.py
index 4811c90..acee7ba 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -302,13 +302,29 @@ class GeneratedListHolder(InterpreterObject):
def add_file(self, a):
self.held_object.add_file(a)
-class Build(InterpreterObject):
+class BuildMachine(InterpreterObject):
def __init__(self):
InterpreterObject.__init__(self)
self.methods.update({'name' : self.name_method,
'endian' : self.endian_method,
})
+ # Python is inconsistent in its platform module.
+ # It returns different values for the same cpu.
+ # For x86 it might return 'x86', 'i686' or somesuch.
+ # Do some canonicalization.
+ def cpu_method(self, args, kwargs):
+ trial = platform.machine().lower()
+ if trial.startswith('i') and trial.endswith('86'):
+ return 'x86'
+ # This might be wrong. Maybe we should return the more
+ # specific string such as 'armv7l'. Need to get user
+ # feedback first.
+ if trial.startswith('arm'):
+ return 'arm'
+ # Add fixes here as bugs are reported.
+ return trial
+
def name_method(self, args, kwargs):
return platform.system().lower()
@@ -803,7 +819,7 @@ class Interpreter():
self.sanity_check_ast()
self.variables = {}
self.builtin = {}
- self.builtin['build_machine'] = Build()
+ self.builtin['build_machine'] = BuildMachine()
if not self.build.environment.is_cross_build():
self.builtin['host_machine'] = self.builtin['build_machine']
self.builtin['target_machine'] = self.builtin['build_machine']