diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | mesonbuild/build.py | 12 | ||||
-rw-r--r-- | mesonbuild/environment.py | 6 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 13 | ||||
-rwxr-xr-x | run_project_tests.py | 3 | ||||
-rw-r--r-- | test cases/common/127 cpp and asm/meson.build | 9 | ||||
-rw-r--r-- | test cases/common/16 configure file/meson.build | 4 |
7 files changed, 39 insertions, 10 deletions
@@ -13,7 +13,7 @@ build system. ####Dependencies - [Python](http://python.org) (version 3.4 or newer) - - [Ninja](https://ninja-build.org) + - [Ninja](https://ninja-build.org) (version 1.5 or newer) ####Installing from source diff --git a/mesonbuild/build.py b/mesonbuild/build.py index f895531..037b195 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1,4 +1,4 @@ -# Copyright 2012-2014 The Meson development team +# Copyright 2012-2017 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -726,11 +726,14 @@ class BuildTarget(): elif isinstance(dep, dependencies.Dependency): self.external_deps.append(dep) self.process_sourcelist(dep.get_sources()) + elif isinstance(dep, BuildTarget): + raise InvalidArguments('''Tried to use a build target as a dependency. +You probably should put it in link_with instead.''') else: # This is a bit of a hack. We do not want Build to know anything # about the interpreter so we can't import it and use isinstance. # This should be reliable enough. - if hasattr(dep, 'subproject'): + if hasattr(dep, 'args_frozen'): raise InvalidArguments('Tried to use subproject object as a dependency.\n' 'You probably wanted to use a dependency declared in it instead.\n' 'Access it by calling get_variable() on the subproject object.') @@ -1484,8 +1487,11 @@ class ConfigurationData(): def __repr__(self): return repr(self.values) + def __contains__(self, value): + return value in self.values + def get(self, name): - return self.values[name] # (val, desc) + return self.values[name] # (val, desc) def keys(self): return self.values.keys() diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 48f5865..e4a55b3 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -36,16 +36,16 @@ def find_coverage_tools(): genhtml_exe = None return (gcovr_exe, lcov_exe, genhtml_exe) -def detect_ninja(): +def detect_ninja(version='1.5'): for n in ['ninja', 'ninja-build']: try: - p, version = Popen_safe([n, '--version'])[0:2] + p, found = Popen_safe([n, '--version'])[0:2] except (FileNotFoundError, PermissionError): # Doesn't exist in PATH or isn't executable continue # Perhaps we should add a way for the caller to know the failure mode # (not found or too old) - if p.returncode == 0 and mesonlib.version_compare(version, ">=1.6"): + if p.returncode == 0 and mesonlib.version_compare(found, '>=' + version): return n def detect_native_windows_arch(): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 82aca60..382c04c 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1,4 +1,4 @@ -# Copyright 2012-2016 The Meson development team +# Copyright 2012-2017 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,6 +164,7 @@ class ConfigurationDataHolder(MutableInterpreterObject): 'set10': self.set10_method, 'set_quoted': self.set_quoted_method, 'has': self.has_method, + 'get': self.get_method, }) def is_used(self): @@ -208,6 +209,16 @@ class ConfigurationDataHolder(MutableInterpreterObject): def has_method(self, args, kwargs): return args[0] in self.held_object.values + def get_method(self, args, kwargs): + if len(args) < 1 or len(args) > 2: + raise InterpreterException('Get method takes one or two arguments.') + name = args[0] + if name in self.held_object: + return self.held_object.get(name)[0] + if len(args) > 1: + return args[1] + raise InterpreterException('Entry %s not in configuration data.' % name) + def get(self, name): return self.held_object.values[name] # (val, desc) diff --git a/run_project_tests.py b/run_project_tests.py index 18988fb..2834254 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -112,7 +112,8 @@ def setup_commands(backend): test_commands = ['xcodebuild', '-target', 'RUN_TESTS'] else: backend_flags = [] - ninja_command = environment.detect_ninja() + # We need at least 1.6 because of -w dupbuild=err + ninja_command = environment.detect_ninja(version='1.6') if ninja_command is None: raise RuntimeError('Could not find Ninja v1.6 or newer') if do_debug: diff --git a/test cases/common/127 cpp and asm/meson.build b/test cases/common/127 cpp and asm/meson.build index 55c3d3c..ac7adb3 100644 --- a/test cases/common/127 cpp and asm/meson.build +++ b/test cases/common/127 cpp and asm/meson.build @@ -1,9 +1,16 @@ project('c++ and assembly test', 'cpp') +cpu = host_machine.cpu_family() + +supported_cpus = ['arm', 'x86', 'x86_64'] + +if not supported_cpus.contains(cpu) + error('MESON_SKIP_TEST unsupported cpu:' + cpu) +endif + sources = ['trivial.cc'] # If the compiler cannot compile assembly, don't use it if meson.get_compiler('cpp').get_id() != 'msvc' - cpu = host_machine.cpu_family() sources += ['retval-' + cpu + '.S'] cpp_args = ['-DUSE_ASM'] message('Using ASM') diff --git a/test cases/common/16 configure file/meson.build b/test cases/common/16 configure file/meson.build index ae3ad27..0c5b981 100644 --- a/test cases/common/16 configure file/meson.build +++ b/test cases/common/16 configure file/meson.build @@ -7,6 +7,10 @@ conf.set('other', 'string 2') conf.set('second', ' bonus') conf.set('BE_TRUE', true) +assert(conf.get('var') == 'mystring', 'Get function is not working.') +assert(conf.get('var', 'default') == 'mystring', 'Get function is not working.') +assert(conf.get('notthere', 'default') == 'default', 'Default value getting is not working.') + cfile = configure_file(input : 'config.h.in', output : 'config.h', configuration : conf) |