Skip to content

Commit

Permalink
Added cpu family property to system information.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Oct 17, 2015
1 parent 1c186d4 commit 572ce0f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions cross/iphone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ has_function_hfkerhisadf = false

[host_machine]
system = 'ios'
cpu_family = 'arm'
cpu = 'armv7'
endian = 'little'

3 changes: 2 additions & 1 deletion cross/ubuntu-armhf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ has_function_hfkerhisadf = false

[host_machine]
system = 'linux'
cpu = 'arm'
cpu_family = 'arm'
cpu = 'armv7' # Not sure if correct.
endian = 'little'
1 change: 1 addition & 0 deletions cross/ubuntu-faketarget.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@

[target_machine]
system = 'linux'
cpu_family = 'mips'
cpu = 'mips'
endian = 'little'
6 changes: 4 additions & 2 deletions cross/ubuntu-mingw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ root = '/usr/i686-w64-mingw32'

[host_machine]
system = 'windows'
cpu = 'x86'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

[target_machine]
system = 'darwin'
cpu = 'arm'
cpu_family = 'arm'
cpu = 'armv7h' # Don't know if this is correct.
endian = 'little'
13 changes: 9 additions & 4 deletions interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class BuildMachine(InterpreterObject):
def __init__(self):
InterpreterObject.__init__(self)
self.methods.update({'system' : self.system_method,
'cpu_family' : self.cpu_family_method,
'cpu' : self.cpu_method,
'endian' : self.endian_method,
})
Expand All @@ -316,18 +317,18 @@ def __init__(self):
# 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):
def cpu_family_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 cpu_method(self, args, kwargs):
return platform.machine().lower()

def system_method(self, args, kwargs):
return platform.system().lower()

Expand All @@ -342,6 +343,7 @@ def __init__(self, cross_info):
self.info = cross_info
self.methods.update({'system' : self.system_method,
'cpu' : self.cpu_method,
'cpu_family' : self.cpu_family_method,
'endian' : self.endian_method,
})

Expand All @@ -351,6 +353,9 @@ def system_method(self, args, kwargs):
def cpu_method(self, args, kwargs):
return self.info['cpu']

def cpu_family_method(self, args, kwargs):
return self.info['cpu_family']

def endian_method(self, args, kwargs):
return self.info['endian']

Expand Down
3 changes: 3 additions & 0 deletions meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ def generate(self):

intr = interpreter.Interpreter(b, g)
if env.is_cross_build():
mlog.log('Host machine cpu family:', mlog.bold(intr.builtin['host_machine'].cpu_family_method([], {})))
mlog.log('Host machine cpu:', mlog.bold(intr.builtin['host_machine'].cpu_method([], {})))
mlog.log('Target machine cpu family:', mlog.bold(intr.builtin['target_machine'].cpu_family_method([], {})))
mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].cpu_method([], {})))
mlog.log('Build machine cpu family:', mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {})))
mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {})))
intr.run()
g.generate(intr)
Expand Down

0 comments on commit 572ce0f

Please sign in to comment.