aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-07-25 22:50:35 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-07-27 00:55:27 +0300
commit463d08d5459a05807e63c833b56614bc8c59643a (patch)
tree28183ff6af3991f549f8eb9151a8a2c56e477ebe
parenteb3cdb6f8d380da19231affd176deb8088481a5a (diff)
downloadmeson-463d08d5459a05807e63c833b56614bc8c59643a.zip
meson-463d08d5459a05807e63c833b56614bc8c59643a.tar.gz
meson-463d08d5459a05807e63c833b56614bc8c59643a.tar.bz2
Now host_machine, build_machine and target_machine are properly separated and return correct values.
-rw-r--r--cross/ubuntu-armhf.txt5
-rw-r--r--cross/ubuntu-mingw.txt8
-rw-r--r--environment.py8
-rw-r--r--interpreter.py88
-rwxr-xr-xmeson.py3
-rw-r--r--ninjabackend.py2
-rw-r--r--test cases/common/26 endian/meson.build2
-rw-r--r--test cases/common/31 find program/meson.build2
-rw-r--r--test cases/common/38 run program/meson.build4
-rw-r--r--test cases/common/55 file grabber/meson.build2
-rw-r--r--test cases/common/59 object generator/meson.build2
-rw-r--r--test cases/objc/2 nsstring/meson.build2
-rw-r--r--test cases/prebuilt object/1 basic/meson.build2
13 files changed, 77 insertions, 53 deletions
diff --git a/cross/ubuntu-armhf.txt b/cross/ubuntu-armhf.txt
index 273d293..73e3f67 100644
--- a/cross/ubuntu-armhf.txt
+++ b/cross/ubuntu-armhf.txt
@@ -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'
diff --git a/cross/ubuntu-mingw.txt b/cross/ubuntu-mingw.txt
index 248151f..dd87e5e 100644
--- a/cross/ubuntu-mingw.txt
+++ b/cross/ubuntu-mingw.txt
@@ -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'
diff --git a/environment.py b/environment.py
index 987dbc8..82c909e 100644
--- a/environment.py
+++ b/environment.py
@@ -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
diff --git a/interpreter.py b/interpreter.py
index c74a900..4811c90 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -170,7 +170,7 @@ class ConfigureFileHolder(InterpreterObject):
class ConfigurationDataHolder(InterpreterObject):
def __init__(self):
super().__init__()
- self.used = False # These objects become immutable after use in configure_file.
+ self.used = False # These objects become immutable after use in configure_file.
self.held_object = build.ConfigurationData()
self.methods.update({'set': self.set_method,
'set10': self.set10_method,
@@ -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 is_big_endian_method(self, args, kwargs):
- return sys.byteorder != 'little'
+ def cpu_method(self, args, kwargs):
+ return self.info['cpu']
+
+ def endian_method(self, args, kwargs):
+ return self.info['endian']
class IncludeDirsHolder(InterpreterObject):
def __init__(self, curdir, dirs):
@@ -736,7 +742,7 @@ class MesonMain(InterpreterObject):
def has_exe_wrapper_method(self, args, kwargs):
if self.is_cross_build_method(None, None):
return 'exe_wrap' in self.build.environment.cross_info.config['binaries']
- return True # This is semantically confusing.
+ return True # This is semantically confusing.
def is_cross_build_method(self, args, kwargs):
return self.build.environment.is_cross_build()
@@ -778,7 +784,7 @@ class Interpreter():
self.subproject_dir = subproject_dir
option_file = os.path.join(self.source_root, self.subdir, 'meson_options.txt')
if os.path.exists(option_file):
- oi = optinterpreter.OptionInterpreter(self.subproject,\
+ oi = optinterpreter.OptionInterpreter(self.subproject, \
self.build.environment.cmd_line_options)
oi.process(option_file)
self.build.environment.merge_options(oi.options)
@@ -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()
@@ -920,7 +938,7 @@ class Interpreter():
e.colno = cur.colno
e.file = os.path.join(self.subdir, 'meson.build')
raise e
- i += 1 # In THE FUTURE jump over blocks and stuff.
+ i += 1 # In THE FUTURE jump over blocks and stuff.
def get_variable(self, varname):
if varname in self.builtin:
@@ -1021,7 +1039,7 @@ class Interpreter():
def validate_arguments(self, args, argcount, arg_types):
if argcount is not None:
if argcount != len(args):
- raise InvalidArguments('Expected %d arguments, got %d.' %
+ raise InvalidArguments('Expected %d arguments, got %d.' %
(argcount, len(args)))
for i in range(min(len(args), len(arg_types))):
wanted = arg_types[i]
@@ -1155,7 +1173,7 @@ class Interpreter():
@stringArgs
def func_project(self, node, args, kwargs):
- if len(args)< 2:
+ if len(args) < 2:
raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
if list(kwargs.keys()) != ['subproject_dir'] and len(kwargs) != 0:
raise InvalidArguments('project() only accepts the keyword argument "subproject_dir"')
@@ -1189,7 +1207,7 @@ class Interpreter():
arg = posargs[0]
if isinstance(arg, list):
- argstr = stringifyUserArguments(arg)
+ argstr = stringifyUserArguments(arg)
elif isinstance(arg, str):
argstr = arg
elif isinstance(arg, int):
@@ -1234,19 +1252,19 @@ class Interpreter():
elif lang == 'java':
comp = self.environment.detect_java_compiler()
if is_cross:
- cross_comp = comp # Java is platform independent.
+ cross_comp = comp # Java is platform independent.
elif lang == 'cs':
comp = self.environment.detect_cs_compiler()
if is_cross:
- cross_comp = comp # C# is platform independent.
+ cross_comp = comp # C# is platform independent.
elif lang == 'vala':
comp = self.environment.detect_vala_compiler()
if is_cross:
- cross_comp = comp # Vala is too (I think).
+ cross_comp = comp # Vala is too (I think).
elif lang == 'rust':
comp = self.environment.detect_rust_compiler()
if is_cross:
- cross_comp = comp # FIXME, probably not correct.
+ cross_comp = comp # FIXME, probably not correct.
elif lang == 'fortran':
comp = self.environment.detect_fortran_compiler(False)
if is_cross:
@@ -1320,7 +1338,7 @@ class Interpreter():
if identifier in self.coredata.deps:
dep = self.coredata.deps[identifier]
else:
- dep = dependencies.Dependency() # Returns always false for dep.found()
+ dep = dependencies.Dependency() # Returns always false for dep.found()
if not dep.found():
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
self.coredata.deps[identifier] = dep
@@ -1358,7 +1376,7 @@ class Interpreter():
if not isinstance(fallback, str):
raise InterpreterException('Keyword argument must exist and be a string.')
replace_string = kwargs.pop('replace_string', '@VCS_TAG@')
- regex_selector = '(.*)' # default regex selector for custom command: use complete output
+ regex_selector = '(.*)' # default regex selector for custom command: use complete output
vcs_cmd = kwargs.get('command', None)
if vcs_cmd and not isinstance(vcs_cmd, list):
vcs_cmd = [vcs_cmd]
@@ -1373,7 +1391,7 @@ class Interpreter():
vcs_cmd = vcs['get_rev'].split()
regex_selector = vcs['rev_regex']
else:
- vcs_cmd = [' '] # executing this cmd will fail in vcstagger.py and force to use the fallback string
+ vcs_cmd = [' '] # executing this cmd will fail in vcstagger.py and force to use the fallback string
scriptfile = os.path.join(self.environment.get_script_dir(), 'vcstagger.py')
# vcstagger.py parameters: infile, outfile, fallback, source_dir, replace_string, regex_selector, command...
kwargs['command'] = [sys.executable, scriptfile, '@INPUT0@', '@OUTPUT0@', fallback, source_dir, replace_string, regex_selector] + vcs_cmd
@@ -1504,7 +1522,7 @@ class Interpreter():
@stringArgs
def func_install_subdir(self, node, args, kwargs):
- if len(args ) != 1:
+ if len(args) != 1:
raise InvalidArguments('Install_subdir requires exactly one argument.')
if not 'install_dir' in kwargs:
raise InvalidArguments('Missing keyword argument install_dir')
@@ -1543,7 +1561,7 @@ class Interpreter():
elif 'command' in kwargs:
res = self.func_run_command(node, kwargs['command'], {})
if res.returncode != 0:
- raise InterpreterException('Running configure command failed.\n%s\n%s' %
+ raise InterpreterException('Running configure command failed.\n%s\n%s' %
(res.stdout, res.stderr))
else:
raise InterpreterException('Configure_file must have either "configuration" or "command".')
@@ -1670,7 +1688,7 @@ class Interpreter():
def check_sources_exist(self, subdir, sources):
for s in sources:
if not isinstance(s, str):
- continue # This means a generated source and they always exist.
+ continue # This means a generated source and they always exist.
fname = os.path.join(subdir, s)
if not os.path.isfile(fname):
raise InterpreterException('Tried to add non-existing source %s.' % s)
@@ -1752,7 +1770,7 @@ class Interpreter():
args = args.arguments
for (i, arg) in enumerate(args):
arg = self.to_native(self.evaluate_statement(arg))
- if isinstance(arg, bool): # Python boolean is upper case.
+ if isinstance(arg, bool): # Python boolean is upper case.
arg = str(arg).lower()
templ = templ.replace('@{}@'.format(i), str(arg))
return templ
diff --git a/meson.py b/meson.py
index e988f03..6628a48 100755
--- a/meson.py
+++ b/meson.py
@@ -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
diff --git a/ninjabackend.py b/ninjabackend.py
index 74d09dd..ecdecb9 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -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=[]):
diff --git a/test cases/common/26 endian/meson.build b/test cases/common/26 endian/meson.build
index abb26a4..80186fe 100644
--- a/test cases/common/26 endian/meson.build
+++ b/test cases/common/26 endian/meson.build
@@ -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
diff --git a/test cases/common/31 find program/meson.build b/test cases/common/31 find program/meson.build
index 16b6cb5..cc3bba7 100644
--- a/test cases/common/31 find program/meson.build
+++ b/test cases/common/31 find program/meson.build
@@ -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
diff --git a/test cases/common/38 run program/meson.build b/test cases/common/38 run program/meson.build
index 4f02a35..f0bc9ce 100644
--- a/test cases/common/38 run program/meson.build
+++ b/test cases/common/38 run program/meson.build
@@ -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')
diff --git a/test cases/common/55 file grabber/meson.build b/test cases/common/55 file grabber/meson.build
index f5c5b3c..d9ee2d3 100644
--- a/test cases/common/55 file grabber/meson.build
+++ b/test cases/common/55 file grabber/meson.build
@@ -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
diff --git a/test cases/common/59 object generator/meson.build b/test cases/common/59 object generator/meson.build
index 61349c2..ffdc1b9 100644
--- a/test cases/common/59 object generator/meson.build
+++ b/test cases/common/59 object generator/meson.build
@@ -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'
diff --git a/test cases/objc/2 nsstring/meson.build b/test cases/objc/2 nsstring/meson.build
index add96cf..8bb06cb 100644
--- a/test cases/objc/2 nsstring/meson.build
+++ b/test cases/objc/2 nsstring/meson.build
@@ -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')
diff --git a/test cases/prebuilt object/1 basic/meson.build b/test cases/prebuilt object/1 basic/meson.build
index 01b2b9a..befb764 100644
--- a/test cases/prebuilt object/1 basic/meson.build
+++ b/test cases/prebuilt object/1 basic/meson.build
@@ -9,7 +9,7 @@
project('prebuilt object', 'c')
-if host.name() == 'windows'
+if host_machine.name() == 'windows'
prebuilt = 'prebuilt.obj'
else
prebuilt = 'prebuilt.o'