diff options
29 files changed, 173 insertions, 121 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5a7c6ac..483f1eb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -86,6 +86,7 @@ jobs: zlib-devel displayName: Install Dependencies - script: | + set BOOST_ROOT= set PATH=%CYGWIN_ROOT%\bin;%SYSTEMROOT%\system32 cp /usr/bin/python3.5 /usr/bin/python3 env.exe -- python3 run_tests.py --backend=ninja @@ -150,6 +151,7 @@ jobs: %TOOLCHAIN% displayName: Install Dependencies - script: | + set BOOST_ROOT= set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem set PATHEXT=%PATHEXT%;.py if %compiler%==clang ( set CC=clang && set CXX=clang++ ) diff --git a/ci/azure-steps.yml b/ci/azure-steps.yml index 6fe1831..7e0f6fe 100644 --- a/ci/azure-steps.yml +++ b/ci/azure-steps.yml @@ -71,6 +71,8 @@ steps: Start-Process "boost_$boost_filename-msvc-$boost_abi_tag-$boost_bitness.exe" -ArgumentList "/dir=$(System.WorkFolder)\boost_$boost_filename /silent" -Wait $env:BOOST_ROOT = "$(System.WorkFolder)\boost_$boost_filename" $env:Path = "$env:Path;$env:BOOST_ROOT\lib$boost_bitness-msvc-$boost_abi_tag" + } else { + $env:BOOST_ROOT = "" } # install D compiler and dub packages diff --git a/docs/markdown/snippets/multiple-cross-files.md b/docs/markdown/snippets/multiple-cross-files.md new file mode 100644 index 0000000..de229be --- /dev/null +++ b/docs/markdown/snippets/multiple-cross-files.md @@ -0,0 +1,3 @@ +## Multipe cross files can be specified + +`--cross-file` can be passed multiple times, with the configuration files overlaying the same way as `--native-file`. diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 4d35d22..5b270d3 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -788,8 +788,7 @@ class Backend: deps = [os.path.join(self.build_to_src, df) for df in self.interpreter.get_build_def_files()] if self.environment.is_cross_build(): - deps.append(os.path.join(self.build_to_src, - self.environment.coredata.cross_file)) + deps.extend(self.environment.coredata.cross_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/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 21c6c08..6446406 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -31,7 +31,7 @@ from .. import dependencies from .. import compilers from ..compilers import CompilerArgs, CCompiler, VisualStudioCCompiler, FortranCompiler from ..linkers import ArLinker -from ..mesonlib import File, MachineChoice, MesonException, OrderedSet +from ..mesonlib import File, MachineChoice, MesonException, OrderedSet, LibType from ..mesonlib import get_compiler_for_source, has_path_sep from .backends import CleanTrees from ..build import InvalidArguments @@ -2401,8 +2401,8 @@ rule FORTRAN_DEP_HACK%s # TODO The get_library_naming requirement currently excludes link targets that use d or fortran as their main linker if hasattr(linker, 'get_library_naming'): search_dirs = tuple(search_dirs) + linker.get_library_dirs(self.environment) - static_patterns = linker.get_library_naming(self.environment, 'static', strict=True) - shared_patterns = linker.get_library_naming(self.environment, 'shared', strict=True) + static_patterns = linker.get_library_naming(self.environment, LibType.STATIC, strict=True) + shared_patterns = linker.get_library_naming(self.environment, LibType.SHARED, strict=True) for libname in libs: # be conservative and record most likely shared and static resolution, because we don't know exactly # which one the linker will prefer diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 3548b6d..cac27ad 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -27,7 +27,7 @@ from . import compilers from ..mesonlib import ( EnvironmentException, MachineChoice, MesonException, Popen_safe, listify, version_compare, for_windows, for_darwin, for_cygwin, for_haiku, - for_openbsd, darwin_get_object_archs + for_openbsd, darwin_get_object_archs, LibType ) from .c_function_attributes import C_FUNC_ATTRIBUTES @@ -905,7 +905,7 @@ class CCompiler(Compiler): patterns.append(p + '{}.so.[0-9]*.[0-9]*') return patterns - def get_library_naming(self, env, libtype, strict=False): + def get_library_naming(self, env, libtype: LibType, strict=False): ''' Get library prefixes and suffixes for the target platform ordered by priority @@ -938,18 +938,17 @@ class CCompiler(Compiler): # Linux/BSDs shlibext = ['so'] # Search priority - if libtype == 'shared-static': + if libtype is LibType.PREFER_SHARED: patterns = self._get_patterns(env, prefixes, shlibext, True) patterns.extend([x for x in self._get_patterns(env, prefixes, stlibext, False) if x not in patterns]) - elif libtype == 'static-shared': + elif libtype is LibType.PREFER_STATIC: patterns = self._get_patterns(env, prefixes, stlibext, False) patterns.extend([x for x in self._get_patterns(env, prefixes, shlibext, True) if x not in patterns]) - elif libtype == 'shared': + elif libtype is LibType.SHARED: patterns = self._get_patterns(env, prefixes, shlibext, True) - elif libtype == 'static': - patterns = self._get_patterns(env, prefixes, stlibext, False) else: - raise AssertionError('BUG: unknown libtype {!r}'.format(libtype)) + assert libtype is LibType.STATIC + patterns = self._get_patterns(env, prefixes, stlibext, False) return tuple(patterns) @staticmethod @@ -1011,13 +1010,13 @@ class CCompiler(Compiler): ''' return self.sizeof('void *', '', env) == 8 - def find_library_real(self, libname, env, extra_dirs, code, libtype): + def find_library_real(self, libname, env, extra_dirs, code, libtype: LibType): # First try if we can just add the library as -l. # Gcc + co seem to prefer builtin lib dirs to -L dirs. # Only try to find std libs if no extra dirs specified. # The built-in search procedure will always favour .so and then always - # search for .a. This is only allowed if libtype is 'shared-static' - if ((not extra_dirs and libtype == 'shared-static') or + # search for .a. This is only allowed if libtype is LibType.PREFER_SHARED + if ((not extra_dirs and libtype is LibType.PREFER_SHARED) or libname in self.internal_libs): args = ['-l' + libname] largs = self.linker_to_compiler_args(self.get_allow_undefined_link_args()) @@ -1051,7 +1050,7 @@ class CCompiler(Compiler): return [trial.as_posix()] return None - def find_library_impl(self, libname, env, extra_dirs, code, libtype): + def find_library_impl(self, libname, env, extra_dirs, code, libtype: LibType): # These libraries are either built-in or invalid if libname in self.ignore_libs: return [] @@ -1067,7 +1066,7 @@ class CCompiler(Compiler): return None return value[:] - def find_library(self, libname, env, extra_dirs, libtype='shared-static'): + def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED): code = 'int main(int argc, char **argv) { return 0; }' return self.find_library_impl(libname, env, extra_dirs, code, libtype) @@ -1399,6 +1398,13 @@ class VisualStudioCCompiler(CCompiler): self.base_options = ['b_pch', 'b_ndebug', 'b_vscrt'] # FIXME add lto, pgo and the like self.target = target self.is_64 = ('x64' in target) or ('x86_64' in target) + # do some canonicalization of target machine + if 'x86_64' in target: + self.machine = 'x64' + elif '86' in target: + self.machine = 'x86' + else: + self.machine = target # Override CCompiler.get_always_args def get_always_args(self): @@ -1475,7 +1481,7 @@ class VisualStudioCCompiler(CCompiler): return ['/nologo'] def get_linker_output_args(self, outputname): - return ['/OUT:' + outputname] + return ['/MACHINE:' + self.machine, '/OUT:' + outputname] def get_linker_search_args(self, dirname): return ['/LIBPATH:' + dirname] diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 738a5c6..15234ee 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -31,7 +31,7 @@ from .compilers import ( PGICompiler ) -from mesonbuild.mesonlib import EnvironmentException, is_osx +from mesonbuild.mesonlib import EnvironmentException, is_osx, LibType class FortranCompiler(Compiler): @@ -241,7 +241,7 @@ class FortranCompiler(Compiler): def find_library_impl(self, *args): return CCompiler.find_library_impl(self, *args) - def find_library(self, libname, env, extra_dirs, libtype='shared-static'): + def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED): code = '''program main call exit(0) end program main''' diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index fba90fa..cb50961 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -211,8 +211,8 @@ class UserFeatureOption(UserComboOption): return self.value == 'auto' -def load_configs(filenames): - """Load native files.""" +def load_configs(filenames, subdir): + """Load configuration files from a named subdirectory.""" def gen(): for f in filenames: f = os.path.expanduser(os.path.expandvars(f)) @@ -225,7 +225,7 @@ def load_configs(filenames): os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')), ] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':') for path in paths: - path_to_try = os.path.join(path, 'meson', 'native', f) + path_to_try = os.path.join(path, 'meson', subdir, f) if os.path.isfile(path_to_try): yield path_to_try break @@ -265,7 +265,7 @@ class CoreData: self.compiler_options = PerMachine({}, {}, {}) self.base_options = {} self.external_preprocess_args = PerMachine({}, {}, {}) # CPPFLAGS only - self.cross_file = self.__load_cross_file(options.cross_file) + self.cross_files = self.__load_config_files(options.cross_file) self.compilers = OrderedDict() self.cross_compilers = OrderedDict() self.deps = OrderedDict() @@ -276,57 +276,19 @@ class CoreData: @staticmethod def __load_config_files(filenames): + # Need to try and make the passed filenames absolute because when the + # files are parsed later we'll have chdir()d. if not filenames: return [] filenames = [os.path.abspath(os.path.expanduser(os.path.expanduser(f))) for f in filenames] return filenames - @staticmethod - def __load_cross_file(filename): - """Try to load the cross file. - - If the filename is None return None. If the filename is an absolute - (after resolving variables and ~), return that absolute path. Next, - check if the file is relative to the current source dir. If the path - still isn't resolved do the following: - Windows: - - Error - *: - - $XDG_DATA_HOME/meson/cross (or ~/.local/share/meson/cross if - undefined) - - $XDG_DATA_DIRS/meson/cross (or - /usr/local/share/meson/cross:/usr/share/meson/cross if undefined) - - Error - - Non-Windows follows the Linux path and will honor XDG_* if set. This - simplifies the implementation somewhat. - """ - if filename is None: - return None - filename = os.path.expanduser(os.path.expandvars(filename)) - if os.path.isabs(filename): - return filename - path_to_try = os.path.abspath(filename) - if os.path.isfile(path_to_try): - return path_to_try - if sys.platform != 'win32': - paths = [ - os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')), - ] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':') - for path in paths: - path_to_try = os.path.join(path, 'meson', 'cross', filename) - if os.path.isfile(path_to_try): - return path_to_try - raise MesonException('Cannot find specified cross file: ' + filename) - - raise MesonException('Cannot find specified cross file: ' + filename) - def libdir_cross_fixup(self): # By default set libdir to "lib" when cross compiling since # getting the "system default" is always wrong on multiarch # platforms as it gets a value like lib/x86_64-linux-gnu. - if self.cross_file is not None: + if self.cross_files: self.builtins['libdir'].value = 'lib' def sanitize_prefix(self, prefix): @@ -642,8 +604,8 @@ def read_cmd_line_file(build_dir, options): options.cmd_line_options = d properties = config['properties'] - if options.cross_file is None: - options.cross_file = properties.get('cross_file', None) + if not options.cross_file: + options.cross_file = ast.literal_eval(properties.get('cross_file', '[]')) if not options.native_file: # This will be a string in the form: "['first', 'second', ...]", use # literal_eval to get it into the list of strings. @@ -654,7 +616,7 @@ def write_cmd_line_file(build_dir, options): config = CmdLineFileParser() properties = {} - if options.cross_file is not None: + if options.cross_file: properties['cross_file'] = options.cross_file if options.native_file: properties['native_file'] = options.native_file diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 2ba150b..de25895 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -36,7 +36,7 @@ from ..compilers import clib_langs from ..environment import BinaryTable, Environment, MachineInfo from ..mesonlib import MachineChoice, MesonException, OrderedSet, PerMachine from ..mesonlib import Popen_safe, version_compare_many, version_compare, listify -from ..mesonlib import Version +from ..mesonlib import Version, LibType # These must be defined in this file to avoid cyclical references. packages = {} @@ -703,7 +703,7 @@ class PkgConfigDependency(ExternalDependency): libs_found = OrderedSet() # Track not-found libraries to know whether to add library paths libs_notfound = [] - libtype = 'static' if self.static else 'shared-static' + libtype = LibType.STATIC if self.static else LibType.PREFER_SHARED # Generate link arguments for this library link_args = [] for lib in full_args: @@ -1993,6 +1993,12 @@ class ExternalProgram: # We know what python3 is, we're running on it if len(commands) > 0 and commands[0] == 'python3': commands = mesonlib.python_command + commands[1:] + else: + # Replace python3 with the actual python3 that we are using + if commands[0] == '/usr/bin/env' and commands[1] == 'python3': + commands = mesonlib.python_command + commands[2:] + elif commands[0].split('/')[-1] == 'python3': + commands = mesonlib.python_command + commands[1:] return commands + [script] except Exception as e: mlog.debug(e) diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index df3a053..c95acff 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -450,10 +450,14 @@ class Python3Dependency(ExternalDependency): if pyplat.startswith('win'): vernum = sysconfig.get_config_var('py_version_nodot') if self.static: - libname = 'libpython{}.a'.format(vernum) + libpath = Path('libs') / 'libpython{}.a'.format(vernum) else: - libname = 'python{}.lib'.format(vernum) - lib = Path(sysconfig.get_config_var('base')) / 'libs' / libname + comp = self.get_compiler() + if comp.id == "gcc": + libpath = 'python{}.dll'.format(vernum) + else: + libpath = Path('libs') / 'python{}.lib'.format(vernum) + lib = Path(sysconfig.get_config_var('base')) / libpath elif pyplat == 'mingw': if self.static: libname = sysconfig.get_config_var('LIBRARY') diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 609899c..e211945 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -69,16 +69,6 @@ CPU_FAMILES_64_BIT = [ class MesonConfigFile: @classmethod - def parse_datafile(cls, filename): - config = configparser.ConfigParser() - try: - with open(filename, 'r') as f: - config.read_file(f, filename) - except FileNotFoundError: - raise EnvironmentException('File not found: %s.' % filename) - return cls.from_config_parser(config) - - @classmethod def from_config_parser(cls, parser: configparser.ConfigParser): out = {} # This is a bit hackish at the moment. diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index ac6e70a..d0dccf4 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -408,12 +408,13 @@ class Environment: if self.coredata.config_files is not None: config = MesonConfigFile.from_config_parser( - coredata.load_configs(self.coredata.config_files)) + coredata.load_configs(self.coredata.config_files, 'native')) self.binaries.build = BinaryTable(config.get('binaries', {})) self.paths.build = Directories(**config.get('paths', {})) - if self.coredata.cross_file is not None: - config = MesonConfigFile.parse_datafile(self.coredata.cross_file) + if self.coredata.cross_files: + config = MesonConfigFile.from_config_parser( + coredata.load_configs(self.coredata.cross_files, 'cross')) self.properties.host = Properties(config.get('properties', {}), False) self.binaries.host = BinaryTable(config.get('binaries', {}), False) if 'host_machine' in config: @@ -1179,7 +1180,7 @@ class Environment: popen_exceptions[' '.join(linker + [arg])] = e continue if '/OUT:' in out.upper() or '/OUT:' in err.upper(): - return VisualStudioLinker(linker) + return VisualStudioLinker(linker, getattr(compiler, 'machine', None)) if p.returncode == 0 and ('armar' in linker or 'armar.exe' in linker): return ArmarLinker(linker) if 'DMD32 D Compiler' in out or 'DMD64 D Compiler' in out: diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index ca4414a..08f10a2 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1493,11 +1493,11 @@ class CompilerHolder(InterpreterObject): for i in search_dirs: if not os.path.isabs(i): raise InvalidCode('Search directory %s is not an absolute path.' % i) - libtype = 'shared-static' + libtype = mesonlib.LibType.PREFER_SHARED if 'static' in kwargs: if not isinstance(kwargs['static'], bool): raise InterpreterException('static must be a boolean') - libtype = 'static' if kwargs['static'] else 'shared' + libtype = mesonlib.LibType.STATIC if kwargs['static'] else mesonlib.LibType.SHARED linkargs = self.compiler.find_library(libname, self.environment, search_dirs, libtype) if required and not linkargs: raise InterpreterException( diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 9206d02..650d1e0 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -606,6 +606,23 @@ The result of this is undefined and will become a hard error in a future Meson r raise InterpreterException('Argument to negation is not an integer.') return -v + @FeatureNew('/ with string arguments', '0.49.0') + def evaluate_path_join(self, l, r): + if not isinstance(l, str): + raise InvalidCode('The division operator can only append to a string.') + if not isinstance(r, str): + raise InvalidCode('The division operator can only append a string.') + return self.join_path_strings((l, r)) + + def evaluate_division(self, l, r): + if isinstance(l, str) or isinstance(r, str): + return self.evaluate_path_join(l, r) + if isinstance(l, int) and isinstance(r, int): + if r == 0: + raise InvalidCode('Division by zero.') + return l // r + raise InvalidCode('Division works only with strings or integers.') + def evaluate_arithmeticstatement(self, cur): l = self.evaluate_statement(cur.left) if is_disabler(l): @@ -630,13 +647,7 @@ The result of this is undefined and will become a hard error in a future Meson r raise InvalidCode('Multiplication works only with integers.') return l * r elif cur.operation == 'div': - if isinstance(l, str) and isinstance(r, str): - return self.join_path_strings((l, r)) - if isinstance(l, int) and isinstance(r, int): - if r == 0: - raise InvalidCode('Division by zero.') - return l // r - raise InvalidCode('Division works only with strings or integers.') + return self.evaluate_division(l, r) elif cur.operation == 'mod': if not isinstance(l, int) or not isinstance(r, int): raise InvalidCode('Modulo works only with integers.') diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index 5432514..c6302bf 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -26,8 +26,9 @@ class StaticLinker: class VisualStudioLinker(StaticLinker): always_args = ['/NOLOGO'] - def __init__(self, exelist): + def __init__(self, exelist, machine): self.exelist = exelist + self.machine = machine def get_exelist(self): return self.exelist[:] @@ -39,7 +40,11 @@ class VisualStudioLinker(StaticLinker): return [] def get_output_args(self, target): - return ['/OUT:' + target] + args = [] + if self.machine: + args += ['/MACHINE:' + self.machine] + args += ['/OUT:' + target] + return args def get_coverage_link_args(self): return [] diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 0afc21b..25e15e4 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -1274,3 +1274,13 @@ def relpath(path, start): return os.path.relpath(path, start) except ValueError: return path + + +class LibType(Enum): + + """Enumeration for library types.""" + + SHARED = 0 + STATIC = 1 + PREFER_SHARED = 2 + PREFER_STATIC = 3 diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 4473bcb..8833a21 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -189,9 +189,13 @@ class GnomeModule(ExtensionModule): gresource_ld_binary = True gresource = kwargs.pop('gresource_bundle', False) - if gresource or gresource_ld_binary: + + if gresource: g_output = args[0] + '.gresource' g_name = args[0] + '_gresource' + elif gresource_ld_binary: + g_output = args[0] + '_ld_binary.gresource' + g_name = args[0] + '_ld_binary_gresource' output = args[0] + '.c' name = args[0] + '_c' @@ -240,10 +244,7 @@ class GnomeModule(ExtensionModule): if gresource or gresource_ld_binary: target_g = GResourceTarget(g_name, state.subdir, state.subproject, g_kwargs) if gresource: # Only one target for .gresource files - if target_g.get_id() not in self.interpreter.build.targets: - return ModuleReturnValue(target_g, [target_g]) - else: - return ModuleReturnValue(target_g, []) + return ModuleReturnValue(target_g, [target_g]) target_c = GResourceTarget(name, state.subdir, state.subproject, kwargs) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 049c457..34fe5a5 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -184,10 +184,14 @@ class PythonDependency(ExternalDependency): if self.platform.startswith('win'): vernum = self.variables.get('py_version_nodot') if self.static: - libname = 'libpython{}.a'.format(vernum) + libpath = Path('libs') / 'libpython{}.a'.format(vernum) else: - libname = 'python{}.lib'.format(vernum) - lib = Path(self.variables.get('base')) / 'libs' / libname + comp = self.get_compiler() + if comp.id == "gcc": + libpath = 'python{}.dll'.format(vernum) + else: + libpath = Path('libs') / 'python{}.lib'.format(vernum) + lib = Path(self.variables.get('base')) / libpath elif self.platform == 'mingw': if self.static: libname = self.variables.get('LIBRARY') diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 28fb98c..0b252ac 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -19,7 +19,7 @@ from ..mesonlib import MesonException, Popen_safe, extract_as_list, File from ..dependencies import Dependency, Qt4Dependency, Qt5Dependency import xml.etree.ElementTree as ET from . import ModuleReturnValue, get_include_args, ExtensionModule -from ..interpreterbase import permittedKwargs, FeatureNewKwargs +from ..interpreterbase import permittedKwargs, FeatureNew, FeatureNewKwargs _QT_DEPS_LUT = { 4: Qt4Dependency, @@ -199,7 +199,7 @@ class QtBaseModule(ExtensionModule): sources.append(moc_output) return ModuleReturnValue(sources, sources) - @FeatureNewKwargs('build target', '0.40.0', ['build_by_default']) + @FeatureNew('qt.compile_translations', '0.44.0') @permittedKwargs({'ts_files', 'install', 'install_dir', 'build_by_default', 'method'}) def compile_translations(self, state, args, kwargs): ts_files, install_dir = extract_as_list(kwargs, 'ts_files', 'install_dir', pop=True) diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index 023afdb..6e8ca83 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -29,7 +29,9 @@ from .mesonlib import MesonException def add_arguments(parser): coredata.register_builtin_arguments(parser) - parser.add_argument('--cross-file', default=None, + parser.add_argument('--cross-file', + default=[], + action='append', help='File describing cross compilation environment.') parser.add_argument('--native-file', default=[], diff --git a/mesonbuild/munstable_coredata.py b/mesonbuild/munstable_coredata.py index 78f3f34..913f942 100644 --- a/mesonbuild/munstable_coredata.py +++ b/mesonbuild/munstable_coredata.py @@ -81,8 +81,9 @@ def run(options): print('Last seen PKGCONFIG enviroment variable value: ' + v) elif k == 'version': print('Meson version: ' + v) - elif k == 'cross_file': - print('Cross File: ' + (v or 'None')) + elif k == 'cross_files': + if v: + print('Cross File: ' + ' '.join(v)) elif k == 'config_files': if v: print('Native File: ' + ' '.join(v)) diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 8967a53..85f6897 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -22,6 +22,7 @@ from . import compilers forbidden_option_names = coredata.get_builtin_options() forbidden_prefixes = [lang + '_' for lang in compilers.all_languages] + ['b_', 'backend_'] +reserved_prefixes = ['cross_'] def is_invalid_name(name): if name in forbidden_option_names: @@ -29,6 +30,9 @@ def is_invalid_name(name): pref = name.split('_')[0] + '_' if pref in forbidden_prefixes: return True + if pref in reserved_prefixes: + from . import mlog + mlog.deprecation('Option uses prefix "%s", which is reserved for Meson. This will become an error in the future.' % pref) return False class OptionException(mesonlib.MesonException): diff --git a/run_project_tests.py b/run_project_tests.py index 00fca6c..467d522 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -547,6 +547,7 @@ def detect_tests_to_run(): # Name, subdirectory, skip condition. all_tests = [ ('common', 'common', False), + ('warning-meson', 'warning', False), ('failing-meson', 'failing', False), ('failing-build', 'failing build', False), ('failing-test', 'failing test', False), @@ -624,9 +625,14 @@ def _run_tests(all_tests, log_name_base, failfast, extra_args): (testnum, testbase) = t.name.split(' ', 1) testname = '%.3d %s' % (int(testnum), testbase) should_fail = False + suite_args = [] if name.startswith('failing'): should_fail = name.split('failing-')[1] - result = executor.submit(run_test, skipped, t.as_posix(), extra_args, system_compiler, backend, backend_flags, commands, should_fail) + if name.startswith('warning'): + suite_args = ['--fatal-meson-warnings'] + should_fail = name.split('warning-')[1] + result = executor.submit(run_test, skipped, t.as_posix(), extra_args + suite_args, + system_compiler, backend, backend_flags, commands, should_fail) futures.append((testname, t, result)) for (testname, t, result) in futures: sys.stdout.flush() diff --git a/run_unittests.py b/run_unittests.py index 0b2164f..f0410ab 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -47,7 +47,7 @@ from mesonbuild.ast import AstInterpreter from mesonbuild.mesonlib import ( is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd, is_haiku, windows_proof_rmtree, python_command, version_compare, - BuildDirLock, Version, PerMachine + BuildDirLock, Version, PerMachine, LibType ) from mesonbuild.environment import detect_ninja from mesonbuild.mesonlib import MesonException, EnvironmentException @@ -612,7 +612,7 @@ class InternalTests(unittest.TestCase): configfile.flush() configfile.close() opts = get_fake_options() - opts.cross_file = configfilename + opts.cross_file = (configfilename,) env = get_fake_env(opts=opts) detected_value = env.need_exe_wrapper() os.unlink(configfilename) @@ -627,7 +627,7 @@ class InternalTests(unittest.TestCase): config.write(configfile) configfile.close() opts = get_fake_options() - opts.cross_file = configfilename + opts.cross_file = (configfilename,) env = get_fake_env(opts=opts) forced_value = env.need_exe_wrapper() os.unlink(configfilename) @@ -702,13 +702,13 @@ class InternalTests(unittest.TestCase): stc = patterns[platform]['static'] shrstc = shr + tuple([x for x in stc if x not in shr]) stcshr = stc + tuple([x for x in shr if x not in stc]) - p = cc.get_library_naming(env, 'shared') + p = cc.get_library_naming(env, LibType.SHARED) self.assertEqual(p, shr) - p = cc.get_library_naming(env, 'static') + p = cc.get_library_naming(env, LibType.STATIC) self.assertEqual(p, stc) - p = cc.get_library_naming(env, 'static-shared') + p = cc.get_library_naming(env, LibType.PREFER_STATIC) self.assertEqual(p, stcshr) - p = cc.get_library_naming(env, 'shared-static') + p = cc.get_library_naming(env, LibType.PREFER_SHARED) self.assertEqual(p, shrstc) # Test find library by mocking up openbsd if platform != 'openbsd': @@ -724,7 +724,7 @@ class InternalTests(unittest.TestCase): f.write('') with open(os.path.join(tmpdir, 'libfoo.so.70.0.so.1'), 'w') as f: f.write('') - found = cc.find_library_real('foo', env, [tmpdir], '', 'shared-static') + found = cc.find_library_real('foo', env, [tmpdir], '', LibType.PREFER_SHARED) self.assertEqual(os.path.basename(found[0]), 'libfoo.so.54.0') def test_find_library_patterns(self): @@ -5871,6 +5871,25 @@ class CrossFileTests(BasePlatformTests): '-Ddef_sharedstatedir=sharedstatebar', '-Ddef_sysconfdir=sysconfbar']) + def test_cross_file_dirs_chain(self): + # crossfile2 overrides crossfile overrides nativefile + testcase = os.path.join(self.unit_test_dir, '57 native file override') + self.init(testcase, default_args=False, + extra_args=['--native-file', os.path.join(testcase, 'nativefile'), + '--cross-file', os.path.join(testcase, 'crossfile'), + '--cross-file', os.path.join(testcase, 'crossfile2'), + '-Ddef_bindir=binbar2', + '-Ddef_datadir=databar', + '-Ddef_includedir=includebar', + '-Ddef_infodir=infobar', + '-Ddef_libdir=libbar', + '-Ddef_libexecdir=libexecbar', + '-Ddef_localedir=localebar', + '-Ddef_localstatedir=localstatebar', + '-Ddef_mandir=manbar', + '-Ddef_sbindir=sbinbar', + '-Ddef_sharedstatedir=sharedstatebar', + '-Ddef_sysconfdir=sysconfbar']) class TAPParserTests(unittest.TestCase): def assert_test(self, events, **kwargs): diff --git a/test cases/unit/57 native file override/crossfile2 b/test cases/unit/57 native file override/crossfile2 new file mode 100644 index 0000000..70946c9 --- /dev/null +++ b/test cases/unit/57 native file override/crossfile2 @@ -0,0 +1,4 @@ +[paths] +bindir = 'binbar2' + +; vim: ft=dosini diff --git a/test cases/warning/1 version for string div/a/b.c b/test cases/warning/1 version for string div/a/b.c new file mode 100644 index 0000000..5047a34 --- /dev/null +++ b/test cases/warning/1 version for string div/a/b.c @@ -0,0 +1,3 @@ +int main() +{ +} diff --git a/test cases/warning/1 version for string div/meson.build b/test cases/warning/1 version for string div/meson.build new file mode 100644 index 0000000..54e9708 --- /dev/null +++ b/test cases/warning/1 version for string div/meson.build @@ -0,0 +1,3 @@ +project('warn on string division', 'c', meson_version: '>=0.48.0') + +executable('prog', 'a' / 'b.c') diff --git a/test cases/windows/5 resources/res/dummy.c b/test cases/windows/5 resources/res/dummy.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/windows/5 resources/res/dummy.c diff --git a/test cases/windows/5 resources/res/meson.build b/test cases/windows/5 resources/res/meson.build index 6d501a2..160d651 100644 --- a/test cases/windows/5 resources/res/meson.build +++ b/test cases/windows/5 resources/res/meson.build @@ -3,3 +3,7 @@ win = import('windows') res = win.compile_resources('myres.rc', depend_files: 'sample.ico', include_directories : inc) + +# test that with MSVC tools, LIB/LINK invokes CVTRES with correct /MACHINE +static_library('reslib', res, 'dummy.c') +shared_library('shreslib', res, 'dummy.c') |