diff options
25 files changed, 210 insertions, 108 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md index 39db4fa..8137cff 100644 --- a/docs/markdown/Builtin-options.md +++ b/docs/markdown/Builtin-options.md @@ -12,11 +12,7 @@ universal options, base options, compiler options. A list of these options can be found by running `meson --help`. All these can be set by passing to `meson` (aka `meson setup`) in any of -these ways: - -| --option=value | -| --option value | -| -Doption=value | +these ways: `--option=value`, `--option value`, `-Doption=value`. They can also be edited after setup using `meson configure`. diff --git a/docs/markdown/Contributing.md b/docs/markdown/Contributing.md index e385be2..c0eea29 100644 --- a/docs/markdown/Contributing.md +++ b/docs/markdown/Contributing.md @@ -167,6 +167,8 @@ Continuous integration systems currently used: allows `[skip ci]` anywhere in the commit messages. - [AppVeyor](https://www.appveyor.com/docs/how-to/filtering-commits/#skip-directive-in-commit-message) requires `[skip ci]` or `[skip appveyor]` in the commit title. +- [Sider](https://sider.review) + runs Flake8 (see below) ## Documentation @@ -208,6 +210,13 @@ $ cd meson $ flake8 ``` +To run it automatically before committing: + +```console +$ flake8 --install-hook=git +$ git config --bool flake8.strict true +``` + ## C/C++ coding style Meson has a bunch of test code in several languages. The rules for diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 688af37..df8531c 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1398,6 +1398,28 @@ the following methods. `MESON_INSTALL_DESTDIR_PREFIX`, and `MESONINTROSPECT` set. All additional arguments are passed as parameters. + Meson uses the `DESTDIR` environment variable as set by the + inherited environment to determine the (temporary) installation + location for files. Your install script must be aware of this while + manipulating and installing files. The correct way to handle this is + with the `MESON_INSTALL_DESTDIR_PREFIX` variable which is always set + and contains `DESTDIR` (if set) and `prefix` joined together. This + is useful because both are usually absolute paths and there are + platform-specific edge-cases in joining two absolute paths. + + In case it is needed, `MESON_INSTALL_PREFIX` is also always set and + has the value of the `prefix` option passed to Meson. + + `MESONINTROSPECT` contains the path to the introspect command that + corresponds to the `meson` executable that was used to configure the + build. (This might be a different path then the first executable + found in `PATH`.) It can be used to query build configuration. Note + that the value will contain many parts, f.ex., it may be `python3 + /path/to/meson.py introspect`. The user is responsible for splitting + the string to an array if needed by splitting lexically like a UNIX + shell would. If your script uses Python, `shlex.split()` is the + easiest correct way to do this. + - `add_postconf_script(script_name, arg1, arg2, ...)` will run the executable given as an argument after all project files have been generated. This script will have the environment variables @@ -1461,26 +1483,6 @@ the following methods. build](Unity-builds.md) (multiple sources are combined before compilation to reduce build time) and `false` otherwise. - To determine the installation location, the script should use the - `DESTDIR`, `MESON_INSTALL_PREFIX`, `MESON_INSTALL_DESTDIR_PREFIX` - variables. `DESTDIR` will be set only if it is inherited from the - outside environment. `MESON_INSTALL_PREFIX` is always set and has - the value of the `prefix` option passed to - Meson. `MESON_INSTALL_DESTDIR_PREFIX` is always set and contains - `DESTDIR` and `prefix` joined together. This is useful because both - are absolute paths, and many path-joining functions such as - [`os.path.join` in - Python](https://docs.python.org/3/library/os.path.html#os.path.join) - special-case absolute paths. - - `MESONINTROSPECT` contains the path to the introspect command that - corresponds to the `meson` executable that was used to configure the - build. (This might be a different path then the first executable - found in `PATH`.) It can be used to query build configuration. Note - that the value may contain many parts, i.e. it may be `python3 - /path/to/meson.py introspect`. The user is responsible for splitting - the string to an array if needed. - - `override_find_program(progname, program)` [*(Added 0.46.0)*](Release-notes-for-0-46-0.html#can-override-find_program) specifies that whenever `find_program` is used to find a program @@ -1954,13 +1956,13 @@ an external dependency with the following methods: - `type_name()` which returns a string describing the type of the dependency, the most common values are `internal` for deps created - with `declare_dependencies` and `pkgconfig` for system dependencies + with `declare_dependency()` and `pkgconfig` for system dependencies obtained with Pkg-config. - `version()` is the version number as a string, for example `1.2.8` - `partial_dependency(compile_args : false, link_args : false, links - : false, includes : false, source : false)` (*added 0.46.0) returns + : false, includes : false, source : false)` (*added 0.46.0*) returns a new dependency object with the same name, version, found status, type name, and methods as the object that called it. This new object will only inherit other attributes from its parent as @@ -2039,8 +2041,16 @@ if called twice with the same `varname`. This object is returned by [`find_library()`](#find_library) and contains an external (i.e. not built as part of this project) -library. This object has only one method, `found`, which returns -whether the library was found. +library. This object has the following methods: + + - `found` which returns whether the library was found. + + - `partial_dependency(compile_args : false, link_args : false, links + : false, includes : false, source : false)` (*added 0.46.0*) returns + a new dependency object with the same name, version, found status, + type name, and methods as the object that called it. This new + object will only inherit other attributes from its parent as + controlled by keyword arguments. ### `generator` object diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index b1a7bf6..6486aa2 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -49,9 +49,8 @@ set in the cross file. | aarch64 | 64 bit ARM processor | | mips | 32 bit MIPS processor | | mips64 | 64 bit MIPS processor | -| ppc | 32 bit PPC processors (Big Endian) | -| ppc64 | 64 bit PPC processors (Big Endian) | -| ppc64le | 64 bit PPC processors (Little Endian) | +| ppc | 32 bit PPC processors | +| ppc64 | 64 bit PPC processors | | e2k | MCST Elbrus processor | | parisc | HP PA-RISC processor | | sparc64 | SPARC v9 processor | diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index 9070a9f..bb6c9a9 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -46,6 +46,8 @@ __all__ = [ 'ArmCCompiler', 'ArmCPPCompiler', + 'ArmclangCCompiler', + 'ArmclangCPPCompiler', 'CCompiler', 'ClangCCompiler', 'ClangCompiler', diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index f3ce4d8..8af7abc 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -851,31 +851,36 @@ class CCompiler(Compiler): args = ['-l' + libname] if self.links(code, env, extra_args=args): return args - # Ensure that we won't modify the list that was passed to us - extra_dirs = extra_dirs[:] # Search in the system libraries too - extra_dirs += self.get_library_dirs() + system_dirs = self.get_library_dirs() # Not found or we want to use a specific libtype? Try to find the # library file itself. prefixes, suffixes = self.get_library_naming(env, libtype) - # Triply-nested loop! + # Triply-nested loops! for d in extra_dirs: for suffix in suffixes: for prefix in prefixes: trial = os.path.join(d, prefix + libname + '.' + suffix) - # as well as checking the path, we need to check compilation - # with link-whole, as static libs (.a) need to be checked - # to ensure they are the right architecture, e.g. 32bit or - # 64-bit. Just a normal test link won't work as the .a file - # doesn't seem to be checked by linker if there are no - # unresolved symbols from the main C file. + if os.path.isfile(trial): + return [trial] + for d in system_dirs: + for suffix in suffixes: + for prefix in prefixes: + trial = os.path.join(d, prefix + libname + '.' + suffix) + # When searching the system paths used by the compiler, we + # need to check linking with link-whole, as static libs + # (.a) need to be checked to ensure they are the right + # architecture, e.g. 32bit or 64-bit. + # Just a normal test link won't work as the .a file doesn't + # seem to be checked by linker if there are no unresolved + # symbols from the main C file. extra_link_args = self.get_link_whole_for([trial]) extra_link_args = self.linker_to_compiler_args(extra_link_args) if (os.path.isfile(trial) and self.links(code, env, extra_args=extra_link_args)): return [trial] - # XXX: For OpenBSD and macOS we (may) need to search for libfoo.x.y.z.dylib + # XXX: For OpenBSD and macOS we (may) need to search for libfoo.x{,.y.z}.ext return None def find_library_impl(self, libname, env, extra_dirs, code, libtype): diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index a53fdde..3725c61 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -333,7 +333,6 @@ class CoreData: 'Default project to execute in Visual Studio', '') - def get_builtin_option(self, optname): if optname in self.builtins: return self.builtins[optname].value diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 48d9fd4..0aa0b32 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -84,7 +84,6 @@ known_cpu_families = ( 'parisc', 'ppc', 'ppc64', - 'ppc64le', 'sparc64', 'x86', 'x86_64' @@ -212,6 +211,8 @@ def detect_cpu_family(compilers): return 'x86' if trial.startswith('arm'): return 'arm' + if trial.startswith('ppc64'): + return 'ppc64' if trial in ('amd64', 'x64'): trial = 'x86_64' if trial == 'x86_64': @@ -229,7 +230,9 @@ def detect_cpu_family(compilers): # Add fixes here as bugs are reported. if trial not in known_cpu_families: - mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial) + mlog.warning('Unknown CPU family {!r}, please report this at ' + 'https://github.com/mesonbuild/meson/issues/new with the' + 'output of `uname -a` and `cat /proc/cpuinfo`'.format(trial)) return trial diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 06d80ab..9d4a64a 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1012,7 +1012,7 @@ class CompilerHolder(InterpreterObject): extra_args = mesonlib.stringlistify(kwargs.get('args', [])) deps = self.determine_dependencies(kwargs) result = self.compiler.alignment(typename, prefix, self.environment, extra_args, deps) - mlog.log('Checking for alignment of "', mlog.bold(typename), '": ', result, sep='') + mlog.log('Checking for alignment of', mlog.bold(typename, True), ':', result) return result @permittedKwargs({ @@ -1044,7 +1044,7 @@ class CompilerHolder(InterpreterObject): h = mlog.green('YES') else: h = mlog.red('NO (%d)' % result.returncode) - mlog.log('Checking if "', mlog.bold(testname), '" runs: ', h, sep='') + mlog.log('Checking if', mlog.bold(testname, True), 'runs:', h) return TryRunResultHolder(result) @noPosargs @@ -1097,8 +1097,8 @@ class CompilerHolder(InterpreterObject): hadtxt = mlog.green('YES') else: hadtxt = mlog.red('NO') - mlog.log('Checking whether type "', mlog.bold(typename), - '" has member "', mlog.bold(membername), '": ', hadtxt, sep='') + mlog.log('Checking whether type', mlog.bold(typename, True), + 'has member', mlog.bold(membername, True), ':', hadtxt) return had @permittedKwargs({ @@ -1126,8 +1126,8 @@ class CompilerHolder(InterpreterObject): else: hadtxt = mlog.red('NO') members = mlog.bold(', '.join(['"{}"'.format(m) for m in membernames])) - mlog.log('Checking whether type "', mlog.bold(typename), - '" has members ', members, ': ', hadtxt, sep='') + mlog.log('Checking whether type', mlog.bold(typename, True), + 'has members', members, ':', hadtxt) return had @permittedKwargs({ @@ -1152,7 +1152,7 @@ class CompilerHolder(InterpreterObject): hadtxt = mlog.green('YES') else: hadtxt = mlog.red('NO') - mlog.log('Checking for function "', mlog.bold(funcname), '": ', hadtxt, sep='') + mlog.log('Checking for function', mlog.bold(funcname, True), ':', hadtxt) return had @permittedKwargs({ @@ -1177,7 +1177,7 @@ class CompilerHolder(InterpreterObject): hadtxt = mlog.green('YES') else: hadtxt = mlog.red('NO') - mlog.log('Checking for type "', mlog.bold(typename), '": ', hadtxt, sep='') + mlog.log('Checking for type', mlog.bold(typename, True), ':', hadtxt) return had @FeatureNew('compiler.compute_int', '0.40.0') @@ -1284,7 +1284,7 @@ class CompilerHolder(InterpreterObject): h = mlog.green('YES') else: h = mlog.red('NO') - mlog.log('Checking if "', mlog.bold(testname), '" compiles: ', h, sep='') + mlog.log('Checking if', mlog.bold(testname, True), 'compiles:', h) return result @permittedKwargs({ @@ -1314,7 +1314,7 @@ class CompilerHolder(InterpreterObject): h = mlog.green('YES') else: h = mlog.red('NO') - mlog.log('Checking if "', mlog.bold(testname), '" links: ', h, sep='') + mlog.log('Checking if', mlog.bold(testname, True), 'links:', h) return result @FeatureNew('compiler.check_header', '0.47.0') @@ -2236,7 +2236,7 @@ external dependencies (including libraries) must go to "dependencies".''') self.global_args_frozen = True mlog.log() with mlog.nested(): - mlog.log('\nExecuting subproject ', mlog.bold(dirname), '.\n', sep='') + mlog.log('\nExecuting subproject', mlog.bold(dirname), '\n') subi = Interpreter(self.build, self.backend, dirname, subdir, self.subproject_dir, self.modules, default_options) subi.subprojects = self.subprojects @@ -2439,8 +2439,8 @@ external dependencies (including libraries) must go to "dependencies".''') if not mesonlib.version_compare(cv, pv): raise InterpreterException('Meson version is %s but project requires %s.' % (cv, pv)) self.build.projects[self.subproject] = proj_name - mlog.log('Project name: ', mlog.bold(proj_name), sep='') - mlog.log('Project version: ', mlog.bold(self.project_version), sep='') + mlog.log('Project name:', mlog.bold(proj_name)) + mlog.log('Project version:', mlog.bold(self.project_version)) self.add_languages(proj_langs, True) langs = self.coredata.compilers.keys() if 'vala' in langs: @@ -2593,14 +2593,16 @@ external dependencies (including libraries) must go to "dependencies".''') else: raise if comp.full_version is not None: - version_string = ' (%s %s "%s")' % (comp.id, comp.version, comp.full_version) + version_string = '(%s %s "%s")' % (comp.id, comp.version, comp.full_version) else: - version_string = ' (%s %s)' % (comp.id, comp.version) - mlog.log('Native %s compiler: ' % comp.get_display_language(), mlog.bold(' '.join(comp.get_exelist())), version_string, sep='') - + version_string = '(%s %s)' % (comp.id, comp.version) + mlog.log('Native', comp.get_display_language(), 'compiler:', + mlog.bold(' '.join(comp.get_exelist())), version_string) self.build.add_compiler(comp) if need_cross_compiler: - mlog.log('Cross %s compiler: ' % cross_comp.get_display_language(), mlog.bold(' '.join(cross_comp.get_exelist())), ' (%s %s)' % (cross_comp.id, cross_comp.version), sep='') + version_string = '(%s %s)' % (cross_comp.id, cross_comp.version) + mlog.log('Cross', cross_comp.get_display_language(), 'compiler:', + mlog.bold(' '.join(cross_comp.get_exelist())), version_string) self.build.add_cross_compiler(cross_comp) if self.environment.is_cross_build() and not need_cross_compiler: self.build.add_cross_compiler(comp) @@ -3207,10 +3209,10 @@ root and issuing %s. env, should_fail, timeout, workdir) if is_base_test: self.build.tests.append(t) - mlog.debug('Adding test "', mlog.bold(args[0]), '".', sep='') + mlog.debug('Adding test', mlog.bold(args[0], True)) else: self.build.benchmarks.append(t) - mlog.debug('Adding benchmark "', mlog.bold(args[0]), '".', sep='') + mlog.debug('Adding benchmark', mlog.bold(args[0], True)) @FeatureNewKwargs('install_headers', '0.47.0', ['install_mode']) @permittedKwargs(permitted_kwargs['install_headers']) @@ -3444,20 +3446,6 @@ root and issuing %s. raise InterpreterException('Output file name must not contain a subdirectory.') (ofile_path, ofile_fname) = os.path.split(os.path.join(self.subdir, output)) ofile_abs = os.path.join(self.environment.build_dir, ofile_path, ofile_fname) - # Optimize copies by not doing substitution if there's nothing to - # substitute, and warn about this legacy hack - if 'configuration' in kwargs: - conf = kwargs['configuration'] - if not isinstance(conf, ConfigurationDataHolder): - raise InterpreterException('Argument "configuration" must be of type configuration_data') - if ifile_abs and not conf.keys(): - del kwargs['configuration'] - kwargs['copy'] = True - mlog.warning('Got an empty configuration_data() object: ' - 'optimizing copy automatically; if you want to ' - 'copy a file to the build dir, use the \'copy:\' ' - 'keyword argument added in 0.47.0', location=node) - conf.mark_used() # Perform the appropriate action if 'configuration' in kwargs: conf = kwargs['configuration'] @@ -3467,15 +3455,21 @@ root and issuing %s. if inputfile is not None: os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True) file_encoding = kwargs.setdefault('encoding', 'utf-8') - missing_variables = mesonlib.do_conf_file(ifile_abs, ofile_abs, - conf.held_object, fmt, - file_encoding) + missing_variables, confdata_useless = \ + mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object, + fmt, file_encoding) if missing_variables: var_list = ", ".join(map(repr, sorted(missing_variables))) mlog.warning( - "The variable(s) %s in the input file %s are not " + "The variable(s) %s in the input file '%s' are not " "present in the given configuration data." % ( var_list, inputfile), location=node) + if confdata_useless: + ifbase = os.path.basename(ifile_abs) + mlog.warning('Got an empty configuration_data() object and found no ' + 'substitutions in the input file {!r}. If you want to ' + 'copy a file to the build dir, use the \'copy:\' keyword ' + 'argument added in 0.47.0'.format(ifbase), location=node) else: mesonlib.dump_conf_header(ofile_abs, conf.held_object, output_format) conf.mark_used() diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 5f9b98a..6b1fb76 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -653,12 +653,18 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'): result = [] missing_variables = set() + # Detect when the configuration data is empty and no tokens were found + # during substitution so we can warn the user to use the `copy:` kwarg. + confdata_useless = not confdata.keys() for line in data: if line.startswith(search_token): + confdata_useless = False line = do_mesondefine(line, confdata) else: line, missing = do_replacement(regex, line, format, confdata) missing_variables.update(missing) + if missing: + confdata_useless = False result.append(line) dst_tmp = dst + '~' try: @@ -668,7 +674,7 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'): raise MesonException('Could not write output file %s: %s' % (dst, str(e))) shutil.copymode(src, dst_tmp) replace_if_different(dst, dst_tmp) - return missing_variables + return missing_variables, confdata_useless CONF_C_PRELUDE = '''/* * Autogenerated by the Meson build system. diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 8a19631..1aca9c6 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time import sys, stat, traceback, argparse import datetime import os.path @@ -110,6 +111,8 @@ class MesonApp: def generate(self): env = environment.Environment(self.source_dir, self.build_dir, self.options) mlog.initialize(env.get_log_dir()) + if self.options.profile: + mlog.set_timestamp_start(time.monotonic()) with mesonlib.BuildDirLock(self.build_dir): self._generate(env) diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index ad63a34..4615b6d 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -306,7 +306,7 @@ class Installer: print('Installation failed due to insufficient permissions.') print('Attempting to use polkit to gain elevated privileges...') os.execlp('pkexec', 'pkexec', sys.executable, main_file, *sys.argv[1:], - os.getcwd()) + '-C', os.getcwd()) else: raise diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index d17b889..b763e20 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -12,7 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys, os, platform, io +import os +import io +import sys +import time +import platform from contextlib import contextmanager """This is (mostly) a standalone module used to write logging @@ -41,12 +45,17 @@ log_dir = None log_file = None log_fname = 'meson-log.txt' log_depth = 0 +log_timestamp_start = None def initialize(logdir): global log_dir, log_file log_dir = logdir log_file = open(os.path.join(logdir, log_fname), 'w', encoding='utf8') +def set_timestamp_start(start): + global log_timestamp_start + log_timestamp_start = start + def shutdown(): global log_file if log_file is not None: @@ -57,17 +66,21 @@ def shutdown(): class AnsiDecorator: plain_code = "\033[0m" - def __init__(self, text, code): + def __init__(self, text, code, quoted=False): self.text = text self.code = code + self.quoted = quoted def get_text(self, with_codes): + text = self.text if with_codes: - return self.code + self.text + AnsiDecorator.plain_code - return self.text + text = self.code + self.text + AnsiDecorator.plain_code + if self.quoted: + text = '"{}"'.format(text) + return text -def bold(text): - return AnsiDecorator(text, "\033[1m") +def bold(text, quoted=False): + return AnsiDecorator(text, "\033[1m", quoted=quoted) def red(text): return AnsiDecorator(text, "\033[1;31m") @@ -83,6 +96,8 @@ def cyan(text): def process_markup(args, keep): arr = [] + if log_timestamp_start is not None: + arr = ['[{:.3f}]'.format(time.monotonic() - log_timestamp_start)] for arg in args: if isinstance(arg, str): arr.append(arg) diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index e461144..6b6aa8b 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -1,7 +1,6 @@ import os from .. import build -from .. import mlog class ExtensionModule: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index fabb0f9..1732282 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -831,7 +831,7 @@ This will become a hard error in the future.''') args += self._unpack_args('--expand-content-files=', 'expand_content_files', kwargs, state) args += self._unpack_args('--ignore-headers=', 'ignore_headers', kwargs) - args += self._unpack_args('--installdir=', 'install_dir', kwargs, state) + args += self._unpack_args('--installdir=', 'install_dir', kwargs) args += self._get_build_args(kwargs, state, depends) res = [build.RunTarget(targetname, command[0], command[1:] + args, depends, state.subdir, state.subproject)] if kwargs.get('install', True): @@ -919,7 +919,6 @@ This will become a hard error in the future.''') raise MesonException('gdbus_codegen takes at most two arguments, name and xml file.') namebase = args[0] xml_files = args[1:] - target_name = namebase + '-gdbus' cmd = [self.interpreter.find_program_impl('gdbus-codegen')] extra_args = mesonlib.stringlistify(kwargs.pop('extra_args', [])) cmd += extra_args diff --git a/run_unittests.py b/run_unittests.py index b6ad20d..8dcf308 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1864,7 +1864,7 @@ int main(int argc, char **argv) { r'meson.build:6: WARNING: a warning of some sort', r'sub' + os.path.sep + r'meson.build:4: WARNING: subdir warning', r'meson.build:7: WARNING: Module unstable-simd has no backwards or forwards compatibility and might not exist in future releases.', - r"meson.build:11: WARNING: The variable(s) 'MISSING' in the input file conf.in are not present in the given configuration data.", + r"meson.build:11: WARNING: The variable(s) 'MISSING' in the input file 'conf.in' are not present in the given configuration data.", r'meson.build:1: WARNING: Passed invalid keyword argument "invalid".', ]: self.assertRegex(out, re.escape(expected)) @@ -2286,6 +2286,21 @@ recommended as it is not supported on some platforms''') self.assertRegex(out, "WARNING: Project specifies a minimum meson_version '>=0.45'") self.assertRegex(out, " * 0.47.0: {'dict'}") + def test_configure_file_warnings(self): + testdir = os.path.join(self.common_test_dir, "16 configure file") + out = self.init(testdir) + self.assertRegex(out, "WARNING:.*'empty'.*config.h.in.*not present.*") + self.assertRegex(out, "WARNING:.*'FOO_BAR'.*nosubst-nocopy2.txt.in.*not present.*") + self.assertRegex(out, "WARNING:.*'empty'.*config.h.in.*not present.*") + self.assertRegex(out, "WARNING:.*empty configuration_data.*test.py.in") + # No warnings about empty configuration data objects passed to files with substitutions + self.assertNotRegex(out, "WARNING:.*empty configuration_data.*nosubst-nocopy1.txt.in") + self.assertNotRegex(out, "WARNING:.*empty configuration_data.*nosubst-nocopy2.txt.in") + with open(os.path.join(self.builddir, 'nosubst-nocopy1.txt'), 'rb') as f: + self.assertEqual(f.read().strip(), b'/* #undef FOO_BAR */') + with open(os.path.join(self.builddir, 'nosubst-nocopy2.txt'), 'rb') as f: + self.assertEqual(f.read().strip(), b'') + class FailureTests(BasePlatformTests): ''' diff --git a/test cases/common/146 C and CPP link/foo.cpp b/test cases/common/146 C and CPP link/foo.cpp index d8b4dbb..9db7fb2 100644 --- a/test cases/common/146 C and CPP link/foo.cpp +++ b/test cases/common/146 C and CPP link/foo.cpp @@ -16,6 +16,9 @@ const int cnums[] = {0, 61}; +/* Provided by foobar.c */ +extern "C" int get_number_index (void); + template<typename T, int N> std::vector<T> makeVector(const T (&data)[N]) { @@ -27,5 +30,5 @@ namespace { } extern "C" int six_one(void) { - return numbers[1]; + return numbers[get_number_index ()]; } diff --git a/test cases/common/146 C and CPP link/foobar.c b/test cases/common/146 C and CPP link/foobar.c index bd6cb00..27928bf 100644 --- a/test cases/common/146 C and CPP link/foobar.c +++ b/test cases/common/146 C and CPP link/foobar.c @@ -17,6 +17,10 @@ #include "foo.hpp" #include "foobar.h" +int get_number_index (void) { + return 1; +} + void mynumbers(int nums[]) { nums[0] = forty_two(); nums[1] = six_one(); diff --git a/test cases/common/157 configure file in test/meson.build b/test cases/common/157 configure file in test/meson.build deleted file mode 100644 index 9028101..0000000 --- a/test cases/common/157 configure file in test/meson.build +++ /dev/null @@ -1,9 +0,0 @@ -project('conf file in test') - -test_file = configure_file( - input: 'test.py.in', - output: 'test.py', - configuration: configuration_data() -) - -test('configure-file', test_file) diff --git a/test cases/common/16 configure file/meson.build b/test cases/common/16 configure file/meson.build index 333b121..409765b 100644 --- a/test cases/common/16 configure file/meson.build +++ b/test cases/common/16 configure file/meson.build @@ -156,11 +156,11 @@ configure_file( ) test('test7', executable('prog7', 'prog7.c')) -# Test empty configuration data object on invalid utf8 file +# Test copying of an empty configuration data object inf = 'invalid-utf8.bin.in' outf = configure_file(input : inf, output : 'invalid-utf8.bin', - configuration : configuration_data()) + copy: true) ret = run_command(check_file, inf, outf) if ret.returncode() != 0 error('Error running command: @0@\n@1@'.format(ret.stdout(), ret.stderr())) @@ -184,3 +184,30 @@ configure_file( encoding : 'koi8-r', configuration : conf8 ) + +# Test that passing an empty configuration_data() object to a file with +# #mesondefine substitutions does not print the warning. +configure_file( + input: 'nosubst-nocopy1.txt.in', + output: 'nosubst-nocopy1.txt', + configuration : configuration_data() +) + +# Test that passing an empty configuration_data() object to a file with +# @FOO@ substitutions does not print the warning. +configure_file( + input: 'nosubst-nocopy2.txt.in', + output: 'nosubst-nocopy2.txt', + configuration : configuration_data() +) + +# Test that passing a configured file object to test() works, and that passing +# an empty configuration_data() object to a file that leads to no substitutions +# prints a warning (see unit tests) +test_file = configure_file( + input: 'test.py.in', + output: 'test.py', + configuration: configuration_data() +) + +test('configure-file', test_file) diff --git a/test cases/common/16 configure file/nosubst-nocopy1.txt.in b/test cases/common/16 configure file/nosubst-nocopy1.txt.in new file mode 100644 index 0000000..6e893a1 --- /dev/null +++ b/test cases/common/16 configure file/nosubst-nocopy1.txt.in @@ -0,0 +1 @@ +#mesondefine FOO_BAR diff --git a/test cases/common/16 configure file/nosubst-nocopy2.txt.in b/test cases/common/16 configure file/nosubst-nocopy2.txt.in new file mode 100644 index 0000000..a6a7cca --- /dev/null +++ b/test cases/common/16 configure file/nosubst-nocopy2.txt.in @@ -0,0 +1 @@ +@FOO_BAR@ diff --git a/test cases/common/157 configure file in test/test.py.in b/test cases/common/16 configure file/test.py.in index 15a61f5..15a61f5 100755..100644 --- a/test cases/common/157 configure file in test/test.py.in +++ b/test cases/common/16 configure file/test.py.in diff --git a/test cases/frameworks/10 gtk-doc/doc/meson.build b/test cases/frameworks/10 gtk-doc/doc/meson.build index 9f38eaa..059d405 100644 --- a/test cases/frameworks/10 gtk-doc/doc/meson.build +++ b/test cases/frameworks/10 gtk-doc/doc/meson.build @@ -9,3 +9,10 @@ gnome.gtkdoc('foobar', main_sgml : 'foobar-docs.sgml', content_files : [docbook, version_xml], install : true) + +gnome.gtkdoc('foobar2', + src_dir : inc, + main_sgml : 'foobar-docs.sgml', + content_files : [docbook, version_xml], + install : true, + install_dir : 'foobar2') diff --git a/test cases/frameworks/10 gtk-doc/installed_files.txt b/test cases/frameworks/10 gtk-doc/installed_files.txt index 6f8ca01..2bfb3f5 100644 --- a/test cases/frameworks/10 gtk-doc/installed_files.txt +++ b/test cases/frameworks/10 gtk-doc/installed_files.txt @@ -13,3 +13,17 @@ usr/share/gtk-doc/html/foobar/right-insensitive.png usr/share/gtk-doc/html/foobar/style.css usr/share/gtk-doc/html/foobar/up.png usr/share/gtk-doc/html/foobar/up-insensitive.png +usr/share/gtk-doc/html/foobar2/BAR.html +usr/share/gtk-doc/html/foobar2/foobar2.devhelp2 +usr/share/gtk-doc/html/foobar2/foobar.html +usr/share/gtk-doc/html/foobar2/foobar2-foo.html +usr/share/gtk-doc/html/foobar2/foobar2-foo-version.html +usr/share/gtk-doc/html/foobar2/home.png +usr/share/gtk-doc/html/foobar2/index.html +usr/share/gtk-doc/html/foobar2/left.png +usr/share/gtk-doc/html/foobar2/left-insensitive.png +usr/share/gtk-doc/html/foobar2/right.png +usr/share/gtk-doc/html/foobar2/right-insensitive.png +usr/share/gtk-doc/html/foobar2/style.css +usr/share/gtk-doc/html/foobar2/up.png +usr/share/gtk-doc/html/foobar2/up-insensitive.png |