Now host_machine, build_machine and target_machine are properly separated and return correct values.

pull/214/head
Jussi Pakkanen 9 years ago
parent eb3cdb6f8d
commit 463d08d545
  1. 5
      cross/ubuntu-armhf.txt
  2. 8
      cross/ubuntu-mingw.txt
  3. 8
      environment.py
  4. 52
      interpreter.py
  5. 3
      meson.py
  6. 2
      ninjabackend.py
  7. 2
      test cases/common/26 endian/meson.build
  8. 2
      test cases/common/31 find program/meson.build
  9. 4
      test cases/common/38 run program/meson.build
  10. 2
      test cases/common/55 file grabber/meson.build
  11. 2
      test cases/common/59 object generator/meson.build
  12. 2
      test cases/objc/2 nsstring/meson.build
  13. 2
      test cases/prebuilt object/1 basic/meson.build

@ -1,6 +1,6 @@
[binaries]
# we could set exe_wrapper = qemu-arm-static but to test the case
# when cross compiled binaries can't be built we don't do that
# when cross compiled binaries can't be run we don't do that
c = '/usr/bin/arm-linux-gnueabihf-gcc'
cpp = '/usr/bin/arm-linux-gnueabihf-g++'
ar = '/usr/arm-linux-gnueabihf/bin/ar'
@ -21,6 +21,7 @@ alignment_double = 4 # Don't know if this is correct...
has_function_printf = true
has_function_hfkerhisadf = false
[hostmachine]
[host_machine]
name = 'linux'
cpu = 'arm'
endian = 'little'

@ -1,5 +1,5 @@
# Something crazy: compiling on Linux a crosscompiler that
# runs on Windows and generates code for iOS.
# runs on Windows and generates code for OSX.
[binaries]
exe_wrapper = 'wine' # A command used to run generated executables.
@ -11,10 +11,12 @@ strip = '/usr/bin/i686-w64-mingw32-strip'
[properties]
root = '/usr/i686-w64-mingw32'
[hostmachine]
[host_machine]
name = 'windows'
cpu = 'x86'
endian = 'little'
[targetmachine]
[target_machine]
name='darwin'
cpu='arm'
endian = 'little'

@ -91,7 +91,7 @@ class Environment():
cross = self.is_cross_build()
if (not cross and mesonlib.is_windows()) \
or (cross and self.cross_info.has_host() and self.cross_info.config['hostmachine']['name'] == 'windows'):
or (cross and self.cross_info.has_host() and self.cross_info.config['host_machine']['name'] == 'windows'):
self.exe_suffix = 'exe'
self.import_lib_suffix = 'lib'
self.shared_lib_suffix = 'dll'
@ -102,7 +102,7 @@ class Environment():
else:
self.exe_suffix = ''
if (not cross and mesonlib.is_osx()) or \
(cross and self.cross_info.has_host() and self.cross_info.config['hostmachine']['name'] == 'darwin'):
(cross and self.cross_info.has_host() and self.cross_info.config['host_machine']['name'] == 'darwin'):
self.shared_lib_suffix = 'dylib'
else:
self.shared_lib_suffix = 'so'
@ -623,7 +623,7 @@ class CrossBuildInfo():
raise EnvironmentException('Malformed value in cross file variable %s.' % varname)
def has_host(self):
return 'hostmachine' in self.config
return 'host_machine' in self.config
def has_target(self):
return 'targetmachine' in self.config
return 'target_machine' in self.config

@ -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()

@ -126,6 +126,9 @@ itself as required.'''
mlog.log('Build type:', mlog.bold('native build'))
b = build.Build(env)
intr = interpreter.Interpreter(b)
if env.is_cross_build():
mlog.log('Host machine cpu:', mlog.bold(intr.builtin['host_machine'].info['cpu']))
mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].info['cpu']))
intr.run()
if self.options.backend == 'ninja':
import ninjabackend

@ -1268,7 +1268,7 @@ rule FORTRAN_DEP_HACK
symname = os.path.join(targetdir, target_name + '.symbols')
elem = NinjaBuildElement(symname, 'SHSYM', target_name)
if self.environment.is_cross_build():
elem.add_item('CROSS', '--cross-host=' + self.environment.cross_info.config['hostmachine']['name'])
elem.add_item('CROSS', '--cross-host=' + self.environment.cross_info.config['host_machine']['name'])
elem.write(outfile)
def generate_link(self, target, outfile, outname, obj_list, linker, extra_args=[]):

@ -1,6 +1,6 @@
project('endian check', 'c')
if host.is_big_endian()
if host_machine.endian() == 'big'
add_global_arguments('-DIS_BE', language : 'c')
endif

@ -1,6 +1,6 @@
project('find program', 'c')
if build.name() == 'windows'
if build_machine.name() == 'windows'
# Things Windows does not provide:
# - an executable to copy files without prompting
# - working command line quoting

@ -1,6 +1,6 @@
project('run command', 'c')
if build.name() == 'windows'
if build_machine.name() == 'windows'
c = run_command('cmd', '/c', 'echo', 'hello')
else
c = run_command('echo', 'hello')
@ -24,7 +24,7 @@ endif
# Now the same with a script.
if build.name() == 'windows'
if build_machine.name() == 'windows'
cs = run_command('scripts/hello.bat')
else
cs = run_command('scripts/hello.sh')

@ -9,7 +9,7 @@ project('grabber', 'c')
# acceptable to you, then we're certainly not going to stop you. Just don't
# file bugs when it fails. :)
if build.name() == 'windows'
if build_machine.name() == 'windows'
c = run_command('grabber.bat')
grabber = find_program('grabber2.bat')
else

@ -6,7 +6,7 @@ python = find_program('python3')
# Code will not be rebuilt if it changes.
comp = '@0@/@1@'.format(meson.current_source_dir(), 'obj_generator.py')
if host.name() == 'windows'
if host_machine.name() == 'windows'
outputname = '@BASENAME@.obj'
else
outputname = '@BASENAME@.o'

@ -1,6 +1,6 @@
project('nsstring', 'objc')
if host.name() == 'darwin'
if host_machine.name() == 'darwin'
dep = dependency('appleframeworks', modules : 'foundation')
else
dep = dependency('gnustep')

@ -9,7 +9,7 @@
project('prebuilt object', 'c')
if host.name() == 'windows'
if host_machine.name() == 'windows'
prebuilt = 'prebuilt.obj'
else
prebuilt = 'prebuilt.o'

Loading…
Cancel
Save