|
|
|
@ -305,29 +305,35 @@ class GeneratedListHolder(InterpreterObject): |
|
|
|
|
class Build(InterpreterObject): |
|
|
|
|
def __init__(self): |
|
|
|
|
InterpreterObject.__init__(self) |
|
|
|
|
self.methods.update({'name' : self.get_name_method, |
|
|
|
|
self.methods.update({'name' : self.name_method, |
|
|
|
|
'endian' : self.endian_method, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
def get_name_method(self, args, kwargs): |
|
|
|
|
def name_method(self, args, kwargs): |
|
|
|
|
return platform.system().lower() |
|
|
|
|
|
|
|
|
|
# This currently returns data for the current environment. |
|
|
|
|
# It should return info for the target host. |
|
|
|
|
class Host(InterpreterObject): |
|
|
|
|
def __init__(self, envir): |
|
|
|
|
def endian_method(self, args, kwargs): |
|
|
|
|
return sys.byteorder |
|
|
|
|
|
|
|
|
|
# This class will provide both host_machine and |
|
|
|
|
# target_machine |
|
|
|
|
class CrossMachineInfo(InterpreterObject): |
|
|
|
|
def __init__(self, cross_info): |
|
|
|
|
InterpreterObject.__init__(self) |
|
|
|
|
self.environment = envir |
|
|
|
|
self.methods.update({'name' : self.get_name_method, |
|
|
|
|
'is_big_endian' : self.is_big_endian_method, |
|
|
|
|
self.info = cross_info |
|
|
|
|
self.methods.update({'name' : self.name_method, |
|
|
|
|
'cpu' : self.cpu_method, |
|
|
|
|
'endian' : self.endian_method, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
def get_name_method(self, args, kwargs): |
|
|
|
|
if self.environment.is_cross_build(): |
|
|
|
|
return self.environment.cross_info.config['hostmachine']['name'] |
|
|
|
|
return platform.system().lower() |
|
|
|
|
def name_method(self, args, kwargs): |
|
|
|
|
return self.info['name'] |
|
|
|
|
|
|
|
|
|
def cpu_method(self, args, kwargs): |
|
|
|
|
return self.info['cpu'] |
|
|
|
|
|
|
|
|
|
def is_big_endian_method(self, args, kwargs): |
|
|
|
|
return sys.byteorder != 'little' |
|
|
|
|
def endian_method(self, args, kwargs): |
|
|
|
|
return self.info['endian'] |
|
|
|
|
|
|
|
|
|
class IncludeDirsHolder(InterpreterObject): |
|
|
|
|
def __init__(self, curdir, dirs): |
|
|
|
@ -797,8 +803,20 @@ class Interpreter(): |
|
|
|
|
self.sanity_check_ast() |
|
|
|
|
self.variables = {} |
|
|
|
|
self.builtin = {} |
|
|
|
|
self.builtin['build'] = Build() |
|
|
|
|
self.builtin['host'] = Host(build.environment) |
|
|
|
|
self.builtin['build_machine'] = Build() |
|
|
|
|
if not self.build.environment.is_cross_build(): |
|
|
|
|
self.builtin['host_machine'] = self.builtin['build_machine'] |
|
|
|
|
self.builtin['target_machine'] = self.builtin['build_machine'] |
|
|
|
|
else: |
|
|
|
|
cross_info = self.build.environment.cross_info |
|
|
|
|
if cross_info.has_host(): |
|
|
|
|
self.builtin['host_machine'] = CrossMachineInfo(cross_info.config['host_machine']) |
|
|
|
|
else: |
|
|
|
|
self.builtin['host_machine'] = self.builtin['build_machine'] |
|
|
|
|
if cross_info.has_target(): |
|
|
|
|
self.builtin['target_machine'] = CrossMachineInfo(cross_info.config['target_machine']) |
|
|
|
|
else: |
|
|
|
|
self.builtin['target_machine'] = self.builtin['host_machine'] |
|
|
|
|
self.builtin['meson'] = MesonMain(build, self) |
|
|
|
|
self.environment = build.environment |
|
|
|
|
self.build_func_dict() |
|
|
|
|