diff options
26 files changed, 258 insertions, 54 deletions
diff --git a/ci/install-dmd.ps1 b/ci/install-dmd.ps1 index aeacdf2..fd13317 100644 --- a/ci/install-dmd.ps1 +++ b/ci/install-dmd.ps1 @@ -9,8 +9,8 @@ $ProgressPreference = "SilentlyContinue" $dmd_install = "C:\D" $dmd_version_file = "C:\cache\DMD_LATEST" -#echo "Fetching latest DMD version..." if (!$Version) { + #echo "Fetching latest DMD version..." $dmd_latest_url = "http://downloads.dlang.org/releases/LATEST" $retries = 10 for ($i = 1; $i -le $retries; $i++) { diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index 47fce8b..bd07524 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -483,6 +483,18 @@ Meson substitutes `modules` to `wx-config` invocation, it generates - `compile_args` using `wx-config --cxxflags $modules...` - `link_args` using `wx-config --libs $modules...` +## Shaderc + +*(added 0.51.0)* + +Shaderc currently does not ship with any means of detection. Nevertheless, Meson +can try to detect it using `pkg-config`, but will default to looking for the +appropriate library manually. If the `static` keyword argument is `true`, +`shaderc_combined` is preferred. Otherwise, `shaderc_shared` is preferred. Note +that it is not possible to obtain the shaderc version using this method. + +`method` may be `auto`, `pkg-config` or `system`. + ### Example ```meson diff --git a/docs/markdown/snippets/sanity-check.md b/docs/markdown/snippets/sanity-check.md new file mode 100644 index 0000000..d5ed80d --- /dev/null +++ b/docs/markdown/snippets/sanity-check.md @@ -0,0 +1,17 @@ +## Sanity checking compilers with user flags + +Sanity checks previously only used user-specified flags for cross compilers, but +now do in all cases. + +All compilers meson might decide to use for the build are "sanity checked" +before other tests are run. This usually involves building simple executable and +trying to run it. Previously user flags (compilation and/or linking flags) were +used for sanity checking cross compilers, but not native compilers. This is +because such flags might be essential for a cross binary to succeed, but usually +aren't for a native compiler. + +In recent releases, there has been an effort to minimize the special-casing of +cross or native builds so as to make building more predictable in less-tested +cases. Since this the user flags are necessary for cross, but not harmful for +native, it makes more sense to use them in all sanity checks than use them in no +sanity checks, so this is what we now do. diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index 01277f0..f1602c0 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -153,8 +153,20 @@ class AstInterpreter(interpreterbase.InterpreterBase): return True def evaluate_arithmeticstatement(self, cur): + self.evaluate_statement(cur.left) + self.evaluate_statement(cur.right) return 0 + def evaluate_uminusstatement(self, cur): + self.evaluate_statement(cur.value) + return 0 + + def evaluate_ternary(self, node): + assert(isinstance(node, mparser.TernaryNode)) + self.evaluate_statement(node.condition) + self.evaluate_statement(node.trueblock) + self.evaluate_statement(node.falseblock) + def evaluate_plusassign(self, node): assert(isinstance(node, mparser.PlusAssignmentNode)) if node.var_name not in self.assignments: @@ -177,6 +189,18 @@ class AstInterpreter(interpreterbase.InterpreterBase): return args.arguments, args.kwargs def evaluate_comparison(self, node): + self.evaluate_statement(node.left) + self.evaluate_statement(node.right) + return False + + def evaluate_andstatement(self, cur): + self.evaluate_statement(cur.left) + self.evaluate_statement(cur.right) + return False + + def evaluate_orstatement(self, cur): + self.evaluate_statement(cur.left) + self.evaluate_statement(cur.right) return False def evaluate_foreach(self, node): diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 5745d29..5a12e29 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -20,7 +20,7 @@ from .. import compilers, environment, mesonlib, optinterpreter from .. import coredata as cdata from ..interpreterbase import InvalidArguments from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary -from ..mparser import ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode +from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode import os build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries'] @@ -142,6 +142,8 @@ class IntrospectionInterpreter(AstInterpreter): condition_level = node.condition_level if hasattr(node, 'condition_level') else 0 if isinstance(required, ElementaryNode): required = required.value + if not isinstance(required, bool): + required = False self.dependencies += [{ 'name': name, 'required': required, @@ -189,6 +191,8 @@ class IntrospectionInterpreter(AstInterpreter): # Make sure nothing can crash when creating the build class kwargs_reduced = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs and k in ['install', 'build_by_default', 'build_always']} + kwargs_reduced = {k: v.value if isinstance(v, ElementaryNode) else v for k, v in kwargs_reduced.items()} + kwargs_reduced = {k: v for k, v in kwargs_reduced.items() if not isinstance(v, BaseNode)} is_cross = False objects = [] empty_sources = [] # Passing the unresolved sources list causes errors diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index d752ac4..04255dc 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -791,6 +791,7 @@ class Backend: for df in self.interpreter.get_build_def_files()] if self.environment.is_cross_build(): deps.extend(self.environment.coredata.cross_files) + deps.extend(self.environment.coredata.config_files) deps.append('meson-private/coredata.dat') if os.path.exists(os.path.join(self.environment.get_source_dir(), 'meson_options.txt')): deps.append(os.path.join(self.build_to_src, 'meson_options.txt')) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 2560c82..bcf8243 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -309,9 +309,9 @@ class CCompiler(Compiler): mlog.debug('Sanity testing ' + self.get_display_language() + ' compiler:', ' '.join(self.exelist)) mlog.debug('Is cross compiler: %s.' % str(self.is_cross)) - extra_flags = [] source_name = os.path.join(work_dir, sname) binname = sname.rsplit('.', 1)[0] + mode = 'link' if self.is_cross: binname += '_cross' if self.exe_wrapper is None: @@ -320,7 +320,9 @@ class CCompiler(Compiler): # on OSX the compiler binary is the same but you need # a ton of compiler flags to differentiate between # arm and x86_64. So just compile. - extra_flags += self.get_compile_only_args() + mode = 'compile' + extra_flags = self._get_basic_compiler_args(environment, mode) + # Is a valid executable output for all toolchains and platforms binname += '.exe' # Write binary check source @@ -392,6 +394,29 @@ class CCompiler(Compiler): return self.compiles(t.format(**fargs), env, extra_args=extra_args, dependencies=dependencies) + def _get_basic_compiler_args(self, env, mode): + args = [] + # Select a CRT if needed since we're linking + if mode == 'link': + args += self.get_linker_debug_crt_args() + if env.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + if mode in {'compile', 'preprocess'}: + # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS and CPPFLAGS from the env + sys_args = env.coredata.get_external_args(for_machine, self.language) + # Apparently it is a thing to inject linker flags both + # via CFLAGS _and_ LDFLAGS, even though the former are + # also used during linking. These flags can break + # argument checks. Thanks, Autotools. + cleaned_sys_args = self.remove_linkerlike_args(sys_args) + args += cleaned_sys_args + elif mode == 'link': + # Add LDFLAGS from the env + args += env.coredata.get_external_link_args(for_machine, self.language) + return args + def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'): if extra_args is None: extra_args = [] @@ -415,25 +440,9 @@ class CCompiler(Compiler): args += d.get_link_args() if d.need_threads(): args += self.thread_link_flags(env) - # Select a CRT if needed since we're linking - if mode == 'link': - args += self.get_linker_debug_crt_args() - if env.is_cross_build() and not self.is_cross: - for_machine = MachineChoice.BUILD - else: - for_machine = MachineChoice.HOST - if mode in {'compile', 'preprocess'}: - # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS and CPPFLAGS from the env - sys_args = env.coredata.get_external_args(for_machine, self.language) - # Apparently it is a thing to inject linker flags both - # via CFLAGS _and_ LDFLAGS, even though the former are - # also used during linking. These flags can break - # argument checks. Thanks, Autotools. - cleaned_sys_args = self.remove_linkerlike_args(sys_args) - args += cleaned_sys_args - elif mode == 'link': - # Add LDFLAGS from the env - args += env.coredata.get_external_link_args(for_machine, self.language) + + args += self._get_basic_compiler_args(env, mode) + args += self.get_compiler_check_args() # extra_args must override all other arguments, so we add them last args += extra_args diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index f1580b6..529919b 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -622,7 +622,15 @@ class DmdDCompiler(DCompiler): return [] def get_std_shared_lib_link_args(self): - return ['-shared', '-defaultlib=libphobos2.so'] + libname = 'libphobos2.so' + if is_windows(): + if self.arch == 'x86_64': + libname = 'phobos64.lib' + elif self.arch == 'x86_mscoff': + libname = 'phobos32mscoff.lib' + else: + libname = 'phobos.lib' + return ['-shared', '-defaultlib=' + libname] def get_target_arch_args(self): # DMD32 and DMD64 on 64-bit Windows defaults to 32-bit (OMF). diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index a16f2b5..5afbb3d 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -31,7 +31,9 @@ from .compilers import ( PGICompiler ) -from mesonbuild.mesonlib import EnvironmentException, is_osx, LibType +from mesonbuild.mesonlib import ( + EnvironmentException, MachineChoice, is_osx, LibType +) class FortranCompiler(Compiler): @@ -79,7 +81,13 @@ class FortranCompiler(Compiler): binary_name = os.path.join(work_dir, 'sanitycheckf') with open(source_name, 'w') as ofile: ofile.write('print *, "Fortran compilation is working."; end') - pc = subprocess.Popen(self.exelist + [source_name, '-o', binary_name]) + if environment.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + extra_flags = environment.coredata.get_external_args(for_machine, self.language) + extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) + pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) pc.wait() if pc.returncode != 0: raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string()) @@ -223,6 +231,9 @@ class FortranCompiler(Compiler): def gen_import_library_args(self, implibname): return CCompiler.gen_import_library_args(self, implibname) + def _get_basic_compiler_args(self, env, mode): + return CCompiler._get_basic_compiler_args(self, env, mode) + def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'): return CCompiler._get_compiler_check_args(self, env, extra_args, dependencies, mode='compile') diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index 8dfd0a2..c4a7019 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -14,7 +14,7 @@ import os.path, subprocess -from ..mesonlib import EnvironmentException +from ..mesonlib import EnvironmentException, MachineChoice from .c import CCompiler from .compilers import ClangCompiler, GnuCompiler @@ -31,9 +31,15 @@ class ObjCCompiler(CCompiler): # TODO try to use sanity_check_impl instead of duplicated code source_name = os.path.join(work_dir, 'sanitycheckobjc.m') binary_name = os.path.join(work_dir, 'sanitycheckobjc') - extra_flags = [] + if environment.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + extra_flags = environment.coredata.get_external_args(for_machine, self.language) if self.is_cross: extra_flags += self.get_compile_only_args() + else: + extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) with open(source_name, 'w') as ofile: ofile.write('#import<stdio.h>\n' 'int main(int argc, char **argv) { return 0; }\n') diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index e66d730..4c23d0a 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -14,7 +14,7 @@ import os.path, subprocess -from ..mesonlib import EnvironmentException +from ..mesonlib import EnvironmentException, MachineChoice from .cpp import CPPCompiler from .compilers import ClangCompiler, GnuCompiler @@ -31,11 +31,20 @@ class ObjCPPCompiler(CPPCompiler): # TODO try to use sanity_check_impl instead of duplicated code source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm') binary_name = os.path.join(work_dir, 'sanitycheckobjcpp') + if environment.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + extra_flags = environment.coredata.get_external_args(for_machine, self.language) + if self.is_cross: + extra_flags += self.get_compile_only_args() + else: + extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) with open(source_name, 'w') as ofile: ofile.write('#import<stdio.h>\n' 'class MyClass;' 'int main(int argc, char **argv) { return 0; }\n') - pc = subprocess.Popen(self.exelist + [source_name, '-o', binary_name]) + pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) pc.wait() if pc.returncode != 0: raise EnvironmentException('ObjC++ compiler %s can not compile programs.' % self.name_string()) diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index 94e6736..17705ac 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -14,7 +14,7 @@ import subprocess, os.path -from ..mesonlib import EnvironmentException +from ..mesonlib import EnvironmentException, MachineChoice from .compilers import Compiler, swift_buildtype_args, clike_debug_args @@ -102,13 +102,25 @@ class SwiftCompiler(Compiler): src = 'swifttest.swift' source_name = os.path.join(work_dir, src) output_name = os.path.join(work_dir, 'swifttest') + if environment.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + extra_flags = environment.coredata.get_external_args(for_machine, self.language) + if self.is_cross: + extra_flags += self.get_compile_only_args() + else: + extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) with open(source_name, 'w') as ofile: ofile.write('''print("Swift compilation is working.") ''') - pc = subprocess.Popen(self.exelist + ['-emit-executable', '-o', output_name, src], cwd=work_dir) + pc = subprocess.Popen(self.exelist + extra_flags + ['-emit-executable', '-o', output_name, src], cwd=work_dir) pc.wait() if pc.returncode != 0: raise EnvironmentException('Swift compiler %s can not compile programs.' % self.name_string()) + if self.is_cross: + # Can't check if the binaries run so we have to assume they do + return if subprocess.call(output_name) != 0: raise EnvironmentException('Executables created by Swift compiler %s are not runnable.' % self.name_string()) diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py index b463f0d..98b8b42 100644 --- a/mesonbuild/compilers/vala.py +++ b/mesonbuild/compilers/vala.py @@ -15,7 +15,7 @@ import os.path from .. import mlog -from ..mesonlib import EnvironmentException, version_compare +from ..mesonlib import EnvironmentException, MachineChoice, version_compare from .compilers import Compiler @@ -87,7 +87,16 @@ class ValaCompiler(Compiler): def sanity_check(self, work_dir, environment): code = 'class MesonSanityCheck : Object { }' - with self.compile(code, [], 'compile') as p: + if environment.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + extra_flags = environment.coredata.get_external_args(for_machine, self.language) + if self.is_cross: + extra_flags += self.get_compile_only_args() + else: + extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) + with self.compile(code, extra_flags, 'compile') as p: if p.returncode != 0: msg = 'Vala compiler {!r} can not compile programs' \ ''.format(self.name_string()) @@ -105,8 +114,14 @@ class ValaCompiler(Compiler): # no extra dirs are specified. if not extra_dirs: code = 'class MesonFindLibrary : Object { }' + if env.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + args = env.coredata.get_external_args(for_machine, self.language) vapi_args = ['--pkg', libname] - with self.compile(code, vapi_args, 'compile') as p: + args += vapi_args + with self.compile(code, args, 'compile') as p: if p.returncode == 0: return vapi_args # Not found? Try to find the vapi file itself. diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index 53ff1c9..1152b8d 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -18,7 +18,7 @@ from .base import ( # noqa: F401 ExternalDependency, NotFoundDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency, PkgConfigDependency, CMakeDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language) from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency -from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency) +from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, ShadercDependency) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency @@ -43,6 +43,7 @@ packages.update({ 'cups': CupsDependency, 'libwmf': LibWmfDependency, 'libgcrypt': LibGCryptDependency, + 'shaderc': ShadercDependency, # From platform: 'appleframeworks': AppleFrameworks, diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 52e8ee6..76eccfb 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -117,6 +117,7 @@ class HDF5Dependency(ExternalDependency): except Exception: pass + class NetCDFDependency(ExternalDependency): def __init__(self, environment, kwargs): @@ -666,3 +667,49 @@ class LibGCryptDependency(ExternalDependency): @staticmethod def get_methods(): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] + + +class ShadercDependency(ExternalDependency): + + def __init__(self, environment, kwargs): + super().__init__('shaderc', environment, None, kwargs) + + static_lib = 'shaderc_combined' + shared_lib = 'shaderc_shared' + + libs = [shared_lib, static_lib] + if self.static: + libs.reverse() + + cc = self.get_compiler() + + for lib in libs: + self.link_args = cc.find_library(lib, environment, []) + if self.link_args is not None: + self.is_found = True + + if self.static and lib != static_lib: + mlog.warning('Static library {!r} not found for dependency {!r}, may ' + 'not be statically linked'.format(static_lib, self.name)) + + break + + def log_tried(self): + return 'system' + + @classmethod + def _factory(cls, environment, kwargs): + methods = cls._process_method_kw(kwargs) + candidates = [] + + if DependencyMethods.SYSTEM in methods: + candidates.append(functools.partial(ShadercDependency, environment, kwargs)) + + if DependencyMethods.PKGCONFIG in methods: + candidates.append(functools.partial(PkgConfigDependency, 'shaderc', environment, kwargs)) + + return candidates + + @staticmethod + def get_methods(): + return [DependencyMethods.SYSTEM, DependencyMethods.PKGCONFIG] diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index deb6b7d..2241089 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -215,6 +215,9 @@ def detect_cpu_family(compilers): trial = 'x86' elif trial == 'bepc': trial = 'x86' + # OpenBSD's 64 bit arm architecute identifies as 'arm64' + elif trial == 'arm64': + trial = 'aarch64' elif trial.startswith('arm'): trial = 'arm' elif trial.startswith('ppc64'): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 3efc88c..4b713ea 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2471,7 +2471,8 @@ external dependencies (including libraries) must go to "dependencies".''') self.active_projectname = current_active self.subprojects.update(subi.subprojects) self.subprojects[dirname] = SubprojectHolder(subi, self.subproject_dir, dirname) - self.build_def_files += subi.build_def_files + # Duplicates are possible when subproject uses files from project root + self.build_def_files = list(set(self.build_def_files + subi.build_def_files)) self.build.merge(subi.build) self.build.subprojects[dirname] = subi.project_version return self.subprojects[dirname] diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index 976d2f0..95ea0ec 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -68,7 +68,14 @@ def linux_syms(libfilename, outfilename): libfilename])[0:2] if pnm.returncode != 0: raise RuntimeError('nm does not work.') - result += [' '.join(x.split()[0:2]) for x in output.split('\n') if len(x) > 0] + for line in output.split('\n'): + if len(line) == 0: + continue + line_split = line.split() + entry = line_split[0:2] + if len(line_split) >= 4: + entry += [line_split[3]] + result += [' '.join(entry)] write_if_changed('\n'.join(result) + '\n', outfilename) def osx_syms(libfilename, outfilename): diff --git a/mesonbuild/scripts/vcstagger.py b/mesonbuild/scripts/vcstagger.py index 62a45d9..16dd4d1 100644 --- a/mesonbuild/scripts/vcstagger.py +++ b/mesonbuild/scripts/vcstagger.py @@ -14,6 +14,7 @@ import sys, os, subprocess, re + def config_vcs_tag(infile, outfile, fallback, source_dir, replace_string, regex_selector, cmd): try: output = subprocess.check_output(cmd, cwd=source_dir) @@ -21,17 +22,18 @@ def config_vcs_tag(infile, outfile, fallback, source_dir, replace_string, regex_ except Exception: new_string = fallback - with open(infile) as f: + with open(infile, encoding='utf8') as f: new_data = f.read().replace(replace_string, new_string) if os.path.exists(outfile): - with open(outfile) as f: + with open(outfile, encoding='utf8') as f: needs_update = (f.read() != new_data) else: needs_update = True if needs_update: - with open(outfile, 'w') as f: + with open(outfile, 'w', encoding='utf8') as f: f.write(new_data) + def run(args): infile, outfile, fallback, source_dir, replace_string, regex_selector = args[0:6] command = args[6:] diff --git a/run_project_tests.py b/run_project_tests.py index 467d522..fdb5f48 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -460,6 +460,7 @@ def have_objc_compiler(): return False if not objc_comp: return False + env.coredata.process_new_compilers('objc', objc_comp, None, env) try: objc_comp.sanity_check(env.get_scratch_dir(), env) except mesonlib.MesonException: @@ -475,6 +476,7 @@ def have_objcpp_compiler(): return False if not objcpp_comp: return False + env.coredata.process_new_compilers('objcpp', objcpp_comp, None, env) try: objcpp_comp.sanity_check(env.get_scratch_dir(), env) except mesonlib.MesonException: @@ -561,7 +563,7 @@ def detect_tests_to_run(): ('C#', 'csharp', skip_csharp(backend)), ('vala', 'vala', backend is not Backend.ninja or not shutil.which('valac')), ('rust', 'rust', backend is not Backend.ninja or not shutil.which('rustc')), - ('d', 'd', backend is not Backend.ninja or not have_d_compiler() or mesonlib.is_windows()), + ('d', 'd', backend is not Backend.ninja or not have_d_compiler()), ('objective c', 'objc', backend not in (Backend.ninja, Backend.xcode) or mesonlib.is_windows() or not have_objc_compiler()), ('objective c++', 'objcpp', backend not in (Backend.ninja, Backend.xcode) or mesonlib.is_windows() or not have_objcpp_compiler()), ('fortran', 'fortran', backend is not Backend.ninja or not shutil.which('gfortran')), diff --git a/run_unittests.py b/run_unittests.py index f381efc..d803e12 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3408,7 +3408,7 @@ recommended as it is not supported on some platforms''') self.assertDictEqual(buildopts_to_find, {}) # Check buildsystem_files - bs_files = ['meson.build', 'sharedlib/meson.build', 'staticlib/meson.build'] + bs_files = ['meson.build', 'meson_options.txt', 'sharedlib/meson.build', 'staticlib/meson.build'] bs_files = [os.path.join(testdir, x) for x in bs_files] self.assertPathListEqual(list(sorted(res['buildsystem_files'])), list(sorted(bs_files))) @@ -3560,6 +3560,12 @@ recommended as it is not supported on some platforms''') 'conditional': False }, { + 'name': 'bugDep1', + 'required': False, + 'has_fallback': False, + 'conditional': False + }, + { 'name': 'somethingthatdoesnotexist', 'required': True, 'has_fallback': False, @@ -4373,12 +4379,11 @@ class LinuxlikeTests(BasePlatformTests): cmd_std = '-std=FAIL' env_flags = p.upper() + 'FLAGS' os.environ[env_flags] = cmd_std - self.init(testdir) - cmd = self.get_compdb()[0]['command'] - qcmd_std = " {} ".format(cmd_std) - self.assertIn(qcmd_std, cmd) - with self.assertRaises(subprocess.CalledProcessError, - msg='{} should have failed'.format(qcmd_std)): + with self.assertRaises((subprocess.CalledProcessError, mesonbuild.mesonlib.EnvironmentException), + msg='C compiler should have failed with -std=FAIL'): + self.init(testdir) + # ICC won't fail in the above because additional flags are needed to + # make unknown -std=... options errors. self.build() def test_compiler_c_stds(self): @@ -4873,7 +4878,7 @@ endian = 'little' myenv['PKG_CONFIG_PATH'] = self.privatedir stdo = subprocess.check_output(['pkg-config', '--libs-only-l', 'libsomething'], env=myenv) deps = [b'-lgobject-2.0', b'-lgio-2.0', b'-lglib-2.0', b'-lsomething'] - if is_windows() or is_cygwin() or is_osx(): + if is_windows() or is_cygwin() or is_osx() or is_openbsd(): # On Windows, libintl is a separate library deps.append(b'-lintl') self.assertEqual(set(deps), set(stdo.split())) diff --git a/test cases/common/177 initial c_args/meson.build b/test cases/common/177 initial c_args/meson.build index 169d2bd..638f8c2 100644 --- a/test cases/common/177 initial c_args/meson.build +++ b/test cases/common/177 initial c_args/meson.build @@ -3,5 +3,5 @@ project('options', 'c') # Test passing c_args and c_link_args options from the command line. assert(get_option('c_args') == ['-funroll-loops'], 'Incorrect value for c_args option.') -assert(get_option('c_link_args') == ['-random_linker_option'], +assert(get_option('c_link_args') == ['-Dtest_harmless_but_useless_link_arg'], 'Incorrect value for c_link_args option.') diff --git a/test cases/common/177 initial c_args/test_args.txt b/test cases/common/177 initial c_args/test_args.txt index 9a6da06..166e481 100644 --- a/test cases/common/177 initial c_args/test_args.txt +++ b/test cases/common/177 initial c_args/test_args.txt @@ -1,4 +1,4 @@ # This file is not read by meson itself, but by the test framework. # It is not possible to pass arguments to meson from a file. ['-Dc_args=-march=native', '-Dc_args=-funroll-loops', - '-Dc_link_args=-random_linker_option'] + '-Dc_link_args=-Dtest_harmless_but_useless_link_arg'] diff --git a/test cases/failing/85 gtest dependency with version/meson.build b/test cases/failing/85 gtest dependency with version/meson.build index 5115f27..3d90994 100644 --- a/test cases/failing/85 gtest dependency with version/meson.build +++ b/test cases/failing/85 gtest dependency with version/meson.build @@ -1,3 +1,3 @@ project('gtest dependency with version', ['c', 'cpp']) # discovering gtest version is not yet implemented -dep = dependency('gtest', version: '>0') +dep = dependency('gtest', method: 'system', version: '>0') diff --git a/test cases/unit/55 introspection/meson.build b/test cases/unit/55 introspection/meson.build index 98f6f22..588f71c 100644 --- a/test cases/unit/55 introspection/meson.build +++ b/test cases/unit/55 introspection/meson.build @@ -2,6 +2,12 @@ project('introspection', ['c', 'cpp'], version: '1.2.3', default_options: ['cpp_ dep1 = dependency('threads') dep2 = dependency('zlib', required: false) +dep3 = dependency('bugDep1', required: get_option('test_opt1')) + +b1 = get_option('test_opt1') +b2 = get_option('test_opt2') +test_bool = b1 or b2 +test_bool = b1 and b2 if false dependency('somethingthatdoesnotexist', required: true) @@ -11,7 +17,7 @@ endif subdir('sharedlib') subdir('staticlib') -t1 = executable('test1', 't1.cpp', link_with: [sharedlib], install: true) +t1 = executable('test1', 't1.cpp', link_with: [sharedlib], install: true, build_by_default: get_option('test_opt2')) t2 = executable('test2', 't2.cpp', link_with: [staticlib]) t3 = executable('test3', 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1]) diff --git a/test cases/unit/55 introspection/meson_options.txt b/test cases/unit/55 introspection/meson_options.txt new file mode 100644 index 0000000..fc5cb4d --- /dev/null +++ b/test cases/unit/55 introspection/meson_options.txt @@ -0,0 +1,2 @@ +option('test_opt1', type: 'boolean', value: false, description: 'simple boolean flag') +option('test_opt2', type: 'boolean', value: true, description: 'simple boolean flag') |