diff options
25 files changed, 133 insertions, 40 deletions
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md index 61b88ad..805ceaa 100644 --- a/docs/markdown/Gnome-module.md +++ b/docs/markdown/Gnome-module.md @@ -127,9 +127,11 @@ This also creates two targets for translations `help-$project-update-po` and `he * `sources`: list of pages * `media`: list of media such as images -* `symlink_media`: if media should be symlinked (requires newish yelp) defaults to `false` +* `symlink_media`: if media should be symlinked not copied (defaults to `true` since 0.41.0) * `languages`: list of languages for translations +Note that very old versions of yelp may not support symlinked media; At least 3.10 should work. + *Added 0.36.0* ### gnome.gtkdoc() diff --git a/docs/markdown/Release-notes-for-0.41.0.md b/docs/markdown/Release-notes-for-0.41.0.md index eb565ab..1ddde95 100644 --- a/docs/markdown/Release-notes-for-0.41.0.md +++ b/docs/markdown/Release-notes-for-0.41.0.md @@ -11,7 +11,7 @@ Native support for linking against LLVM using the `dependency` function. ## vcs_tag keyword fallback is is now optional -The `fallback` keyword in `vcs_tag` is now optional. If not given, its value +The `fallback` keyword in `vcs_tag()` is now optional. If not given, its value defaults to the return value of `meson.project_version()`. ## Better quoting of special characters in ninja command invocations @@ -56,7 +56,7 @@ Targets for building rust now take a `rust_args` keyword. Code coverage can be generated for tests by passing the `--cov` argument to the `run_tests.py` test runner. Note, since multiple processes are used, -coverage must be combined before producing a report (`coverage3 combine`.) +coverage must be combined before producing a report (`coverage3 combine`). ## Reproducible builds diff --git a/man/meson.1 b/man/meson.1 index 9cedccc..1cd60b6 100644 --- a/man/meson.1 +++ b/man/meson.1 @@ -1,4 +1,4 @@ -.TH MESON "1" "June 2017" "meson 0.41.0" "User Commands" +.TH MESON "1" "June 2017" "meson 0.41.1" "User Commands" .SH NAME meson - a high productivity build system .SH DESCRIPTION diff --git a/man/mesonconf.1 b/man/mesonconf.1 index 0715637..6bb9d39 100644 --- a/man/mesonconf.1 +++ b/man/mesonconf.1 @@ -1,4 +1,4 @@ -.TH MESONCONF "1" "June 2017" "mesonconf 0.41.0" "User Commands" +.TH MESONCONF "1" "June 2017" "mesonconf 0.41.1" "User Commands" .SH NAME mesonconf - a tool to configure Meson builds .SH DESCRIPTION diff --git a/man/mesonintrospect.1 b/man/mesonintrospect.1 index 7b3455d..1918b4f 100644 --- a/man/mesonintrospect.1 +++ b/man/mesonintrospect.1 @@ -1,4 +1,4 @@ -.TH MESONCONF "1" "June 2017" "mesonintrospect 0.41.0" "User Commands" +.TH MESONCONF "1" "June 2017" "mesonintrospect 0.41.1" "User Commands" .SH NAME mesonintrospect - a tool to extract information about a Meson build .SH DESCRIPTION diff --git a/man/mesontest.1 b/man/mesontest.1 index 88d0520..cf21fe7 100644 --- a/man/mesontest.1 +++ b/man/mesontest.1 @@ -1,4 +1,4 @@ -.TH MESON "1" "June 2017" "meson 0.41.0" "User Commands" +.TH MESON "1" "June 2017" "meson 0.41.1" "User Commands" .SH NAME mesontest - test tool for the Meson build system .SH DESCRIPTION diff --git a/man/wraptool.1 b/man/wraptool.1 index 5013cf8..73c2568 100644 --- a/man/wraptool.1 +++ b/man/wraptool.1 @@ -1,4 +1,4 @@ -.TH WRAPTOOL "1" "June 2017" "meson 0.41.0" "User Commands" +.TH WRAPTOOL "1" "June 2017" "meson 0.41.1" "User Commands" .SH NAME wraptool - source dependency downloader .SH DESCRIPTION diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 9a48c4e..b1f6d85 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -510,12 +510,12 @@ int dummy; cmd_type = 'meson_exe.py custom' else: cmd_type = 'custom' - if target.depfile is not None: rel_dfile = os.path.join(self.get_target_dir(target), target.depfile) abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) os.makedirs(abs_pdir, exist_ok=True) elem.add_item('DEPFILE', rel_dfile) + cmd = self.replace_paths(target, cmd) elem.add_item('COMMAND', cmd) elem.add_item('description', desc.format(target.name, cmd_type)) elem.write(outfile) @@ -564,7 +564,9 @@ int dummy; else: cmd.append(target.command) cmd += arg_strings + elem.add_dep(deps) + cmd = self.replace_paths(target, cmd) elem.add_item('COMMAND', cmd) elem.add_item('description', 'Running external command %s.' % target.name) elem.add_item('pool', 'console') @@ -1649,6 +1651,16 @@ rule FORTRAN_DEP_HACK continue self.generate_genlist_for_target(genlist, target, outfile) + def replace_paths(self, target, args): + source_target_dir = self.get_target_source_dir(target) + relout = self.get_target_private_dir(target) + args = [x.replace("@SOURCE_DIR@", self.build_to_src).replace("@BUILD_DIR@", relout) + for x in args] + args = [x.replace("@CURRENT_SOURCE_DIR@", source_target_dir) for x in args] + args = [x.replace("@SOURCE_ROOT@", self.build_to_src).replace("@BUILD_ROOT@", '.') + for x in args] + return args + def generate_genlist_for_target(self, genlist, target, outfile): generator = genlist.get_generator() exe = generator.get_exe() @@ -1682,11 +1694,7 @@ rule FORTRAN_DEP_HACK if sole_output == '': outfilelist = outfilelist[len(generator.outputs):] relout = self.get_target_private_dir(target) - args = [x.replace("@SOURCE_DIR@", self.build_to_src).replace("@BUILD_DIR@", relout) - for x in args] - args = [x.replace("@CURRENT_SOURCE_DIR@", source_target_dir) for x in args] - args = [x.replace("@SOURCE_ROOT@", self.build_to_src).replace("@BUILD_ROOT@", '.') - for x in args] + args = self.replace_paths(target, args) cmdlist = exe_arr + self.replace_extra_args(args, genlist) elem = NinjaBuildElement(self.all_outputs, outfiles, rulename, infilename) if generator.depfile is not None: diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 2b54cc8..3b9972f 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -430,6 +430,17 @@ class CompilerArgs(list): to recursively search for symbols in the libraries. This is not needed with other linkers. ''' + + # A standalone argument must never be deduplicated because it is + # defined by what comes _after_ it. Thus dedupping this: + # -D FOO -D BAR + # would yield either + # -D FOO BAR + # or + # FOO -D BAR + # both of which are invalid. + if arg in cls.dedup2_prefixes: + return 0 if arg in cls.dedup2_args or \ arg.startswith(cls.dedup2_prefixes) or \ arg.endswith(cls.dedup2_suffixes): @@ -1042,7 +1053,7 @@ class CCompiler(Compiler): def _links_wrapper(self, code, env, extra_args, dependencies): "Shares common code between self.links and self.run" args = self._get_compiler_check_args(env, extra_args, dependencies, mode='link') - return self.compile(code, args.to_native()) + return self.compile(code, args) def links(self, code, env, extra_args=None, dependencies=None): with self._links_wrapper(code, env, extra_args, dependencies) as p: diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 14ec41e..fdb5ab8 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -528,7 +528,10 @@ class ExternalLibrary(ExternalDependency): C-like code. Note that C++ libraries *can* be linked with C code with a C++ linker (and vice-versa). ''' - if self.language == 'vala' and language != 'vala': + # Using a vala library in a non-vala target, or a non-vala library in a vala target + # XXX: This should be extended to other non-C linkers such as Rust + if (self.language == 'vala' and language != 'vala') or \ + (language == 'vala' and self.language != 'vala'): return [] return self.link_args diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index d7a7181..f991d3c 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -236,7 +236,7 @@ class ValgrindDependency(PkgConfigDependency): link to its (static) libraries. ''' def __init__(self, env, kwargs): - super().__init__('valgrind', env, None, kwargs) + super().__init__('valgrind', env, kwargs) def get_link_args(self): return [] diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 8537a7e..7cc8bb4 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -312,7 +312,7 @@ class QtBaseDependency(ExternalDependency): fname = 'Qt' + m fwdep = ExtraFrameworkDependency(fname, False, libdir, self.env, self.language, kwargs) - self.cargs.append('-F' + libdir) + self.compile_args.append('-F' + libdir) if fwdep.found(): self.is_found = True self.compile_args += fwdep.get_compile_args() @@ -426,6 +426,8 @@ class WxDependency(ExternalDependency): self.version = 'none' if WxDependency.wx_found is None: self.check_wxconfig() + else: + self.wxc = WxDependency.wx_found if not WxDependency.wx_found: mlog.log("Neither wx-config-3.0 nor wx-config found; can't detect dependency") return @@ -480,7 +482,7 @@ class WxDependency(ExternalDependency): mlog.log('Found wx-config:', mlog.bold(shutil.which(wxc)), '(%s)' % out.strip()) self.wxc = wxc - WxDependency.wx_found = True + WxDependency.wx_found = wxc return except (FileNotFoundError, PermissionError): pass diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 525a41d..5e672bb 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -158,7 +158,7 @@ def list_buildsystem_files(coredata, builddata): def list_deps(coredata): result = [] - for d in coredata.deps: + for d in coredata.deps.values(): if d.found(): args = {'compile_args': d.get_compile_args(), 'link_args': d.get_link_args()} diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 6ec7040..6c22976 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -619,7 +619,7 @@ class GnomeModule(ExtensionModule): langs = mesonlib.stringlistify(kwargs.pop('languages', [])) media = mesonlib.stringlistify(kwargs.pop('media', [])) - symlinks = kwargs.pop('symlink_media', False) + symlinks = kwargs.pop('symlink_media', True) if not isinstance(symlinks, bool): raise MesonException('symlink_media must be a boolean') diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py index 47dfb71..978a870 100644 --- a/mesonbuild/scripts/yelphelper.py +++ b/mesonbuild/scripts/yelphelper.py @@ -74,13 +74,24 @@ def install_help(srcdir, blddir, sources, media, langs, install_dir, destdir, pr if not os.path.exists(infile): if lang == 'C': mlog.warning('Media file "%s" did not exist in C directory' % m) + continue elif symlinks: srcfile = os.path.join(c_install_dir, m) mlog.log('Symlinking %s to %s.' % (outfile, srcfile)) if '/' in m or '\\' in m: os.makedirs(os.path.dirname(outfile), exist_ok=True) - os.symlink(srcfile, outfile) - continue + try: + try: + os.symlink(srcfile, outfile) + except FileExistsError: + os.remove(outfile) + os.symlink(srcfile, outfile) + continue + except (NotImplementedError, OSError): + mlog.warning('Symlinking not supported, falling back to copying') + else: + # Lang doesn't have media file so copy it over 'C' one + infile = os.path.join(srcdir, 'C', m) mlog.log('Installing %s to %s' % (infile, outfile)) if '/' in m or '\\' in m: os.makedirs(os.path.dirname(outfile), exist_ok=True) diff --git a/run_project_tests.py b/run_project_tests.py index 66d7eb0..3c89d75 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -214,7 +214,8 @@ def validate_install(srcdir, installdir, compiler): expected[platform_fix_name(line.strip())] = False # Check if expected files were found for fname in expected: - if os.path.exists(os.path.join(installdir, fname)): + file_path = os.path.join(installdir, fname) + if os.path.exists(file_path) or os.path.islink(file_path): expected[fname] = True for (fname, found) in expected.items(): if not found: diff --git a/run_unittests.py b/run_unittests.py index 5100e6b..63462d8 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -30,7 +30,7 @@ import mesonbuild.mlog import mesonbuild.compilers import mesonbuild.environment import mesonbuild.mesonlib -from mesonbuild.mesonlib import is_windows, is_osx, is_cygwin +from mesonbuild.mesonlib import is_windows, is_osx, is_cygwin, windows_proof_rmtree from mesonbuild.environment import Environment from mesonbuild.dependencies import DependencyException from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram @@ -445,7 +445,7 @@ class BasePlatformTests(unittest.TestCase): print(f.read()) def tearDown(self): - shutil.rmtree(self.builddir) + windows_proof_rmtree(self.builddir) os.environ = self.orig_env super().tearDown() @@ -534,7 +534,7 @@ class BasePlatformTests(unittest.TestCase): self._run(self.mconf_command + [arg, self.builddir]) def wipe(self): - shutil.rmtree(self.builddir) + windows_proof_rmtree(self.builddir) def utime(self, f): ensure_backend_detects_changes(self.backend) @@ -1247,6 +1247,15 @@ int main(int argc, char **argv) { for path in rpath.split(':'): self.assertTrue(path.startswith('$ORIGIN'), msg=(each, path)) + def test_dash_d_dedup(self): + testdir = os.path.join(self.unit_test_dir, '10 d dedup') + self.init(testdir) + cmd = self.get_compdb()[0]['command'] + self.assertTrue('-D FOO -D BAR' in cmd or + '"-D" "FOO" "-D" "BAR"' in cmd or + '/D FOO /D BAR' in cmd or + '"/D" "FOO" "/D" "BAR"' in cmd) + class FailureTests(BasePlatformTests): ''' @@ -1265,7 +1274,7 @@ class FailureTests(BasePlatformTests): def tearDown(self): super().tearDown() - shutil.rmtree(self.srcdir) + windows_proof_rmtree(self.srcdir) def assertMesonRaises(self, contents, match, extra_args=None, langs=None): ''' @@ -1787,16 +1796,22 @@ class LinuxlikeTests(BasePlatformTests): self.init(testdir) # NOTE: .pc file has -Lfoo -lfoo -Lbar -lbar but pkg-config reorders # the flags before returning them to -Lfoo -Lbar -lfoo -lbar - expected_order = ['-L/me/first', '-L/me/second','-lfoo1', '-lfoo2', - '-L/me/third', '-L/me/fourth', '-lfoo3', '-lfoo4'] + # but pkgconf seems to not do that. Sigh. Support both. + expected_order = [('-L/me/first', '-lfoo1'), + ('-L/me/second', '-lfoo2'), + ('-L/me/first', '-L/me/second'), + ('-lfoo1', '-lfoo2'), + ('-L/me/second', '-L/me/third'), + ('-L/me/third', '-L/me/fourth',), + ('-L/me/third', '-lfoo3'), + ('-L/me/fourth', '-lfoo4'), + ('-lfoo3', '-lfoo4'), + ] with open(os.path.join(self.builddir, 'build.ninja')) as ifile: for line in ifile: - if expected_order[0] in line: - previous_index = line.index(expected_order[0]) - for entry in expected_order[1:]: - current_index = line.index(entry) - self.assertLess(previous_index, current_index) - previous_index = current_index + if expected_order[0][0] in line: + for first, second in expected_order: + self.assertLess(line.index(first), line.index(second)) return raise RuntimeError('Linker entries not found in the Ninja file.') @@ -1833,7 +1848,7 @@ class RewriterTests(unittest.TestCase): self.test_dir = os.path.join(src_root, 'test cases/rewrite') def tearDown(self): - shutil.rmtree(self.tmpdir) + windows_proof_rmtree(self.tmpdir) def read_contents(self, fname): with open(os.path.join(self.workdir, fname)) as f: diff --git a/test cases/frameworks/13 yelp/help/meson.build b/test cases/frameworks/13 yelp/help/meson.build index 7c6f01d..85bc980 100644 --- a/test cases/frameworks/13 yelp/help/meson.build +++ b/test cases/frameworks/13 yelp/help/meson.build @@ -3,5 +3,13 @@ gnome = import('gnome') gnome.yelp('meson', sources: 'index.page', media: 'media/test.txt', + symlink_media: false, + languages: ['de', 'es'], +) + +gnome.yelp('meson-symlink', + sources: 'index.page', + media: 'media/test.txt', + symlink_media: true, languages: ['de', 'es'], ) diff --git a/test cases/frameworks/13 yelp/installed_files.txt b/test cases/frameworks/13 yelp/installed_files.txt index 59d2158..9fc097d 100644 --- a/test cases/frameworks/13 yelp/installed_files.txt +++ b/test cases/frameworks/13 yelp/installed_files.txt @@ -3,3 +3,10 @@ usr/share/help/C/meson/media/test.txt usr/share/help/es/meson/index.page usr/share/help/es/meson/media/test.txt usr/share/help/de/meson/index.page +usr/share/help/de/meson/media/test.txt +usr/share/help/C/meson-symlink/index.page +usr/share/help/C/meson-symlink/media/test.txt +usr/share/help/es/meson-symlink/media/test.txt +usr/share/help/es/meson-symlink/index.page +usr/share/help/de/meson-symlink/index.page +usr/share/help/de/meson-symlink/media/test.txt diff --git a/test cases/frameworks/9 wxwidgets/meson.build b/test cases/frameworks/9 wxwidgets/meson.build index c1fa367..da3aa26 100644 --- a/test cases/frameworks/9 wxwidgets/meson.build +++ b/test cases/frameworks/9 wxwidgets/meson.build @@ -1,5 +1,6 @@ project('wxwidgets test', 'cpp') +wxd = dependency('wxwidgets', version : '>=5', required : false) wxd = dependency('wxwidgets', version : '>=3.0.0', required : false) if wxd.found() diff --git a/test cases/linuxlike/5 dependency versions/meson.build b/test cases/linuxlike/5 dependency versions/meson.build index ad513f2..d4140b7 100644 --- a/test cases/linuxlike/5 dependency versions/meson.build +++ b/test cases/linuxlike/5 dependency versions/meson.build @@ -92,7 +92,7 @@ endif objc_found = add_languages('objc', required : false) -foreach d : ['sdl2', 'gnustep', 'wx', 'gl', 'python3', 'boost', 'gtest', 'gmock'] +foreach d : ['sdl2', 'gnustep', 'wxwidgets', 'gl', 'python3', 'boost', 'gtest', 'gmock', 'valgrind'] if d == 'gnustep' and not objc_found message('Skipping gnustep because no ObjC compiler found') else diff --git a/test cases/unit/10 d dedup/meson.build b/test cases/unit/10 d dedup/meson.build new file mode 100644 index 0000000..08f3a6c --- /dev/null +++ b/test cases/unit/10 d dedup/meson.build @@ -0,0 +1,6 @@ +project('d dedup', 'c') + +add_project_arguments('-D', 'FOO', '-D', 'BAR', language : 'c') + +executable('prog', 'prog.c') + diff --git a/test cases/unit/10 d dedup/prog.c b/test cases/unit/10 d dedup/prog.c new file mode 100644 index 0000000..505f122 --- /dev/null +++ b/test cases/unit/10 d dedup/prog.c @@ -0,0 +1,14 @@ +#include<stdio.h> + +#ifndef FOO +#error FOO is not defined. +#endif + +#ifndef BAR +#error BAR is not defined. +#endif + +int main(int argc, char **argv) { + printf("All is well.\n"); + return 0; +} diff --git a/test cases/vala/16 mixed dependence/meson.build b/test cases/vala/16 mixed dependence/meson.build index e6967be..b44b47b 100644 --- a/test cases/vala/16 mixed dependence/meson.build +++ b/test cases/vala/16 mixed dependence/meson.build @@ -1,6 +1,10 @@ project('mixed dependence', 'vala', 'c') -deps = [dependency('glib-2.0'), dependency('gobject-2.0')] +cc = meson.get_compiler('c') + +deps = [dependency('glib-2.0'), dependency('gobject-2.0'), + # Should be ignored, see https://github.com/mesonbuild/meson/issues/1939 + cc.find_library('z')] mixer = static_library('mixer', 'mixer.vala', 'mixer-glue.c', dependencies : deps) diff --git a/test cases/windows/1 basic/prog.c b/test cases/windows/1 basic/prog.c index 8703980..58162a4 100644 --- a/test cases/windows/1 basic/prog.c +++ b/test cases/windows/1 basic/prog.c @@ -1,4 +1,4 @@ -#include <Windows.h> +#include <windows.h> int main(int argc, char **argv) { return 0; |