diff options
-rw-r--r-- | docs/markdown/Compiler-properties.md | 2 | ||||
-rw-r--r-- | docs/markdown/Reference-manual.md | 5 | ||||
-rw-r--r-- | docs/markdown/Users.md | 1 | ||||
-rw-r--r-- | docs/markdown/snippets/project-license.md | 4 | ||||
-rw-r--r-- | mesonbuild/build.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 90 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 6 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 12 | ||||
-rw-r--r-- | test cases/common/140 get define/meson.build | 4 | ||||
-rw-r--r-- | test cases/common/175 get project license/bar.c | 6 | ||||
-rw-r--r-- | test cases/common/175 get project license/meson.build | 8 |
11 files changed, 90 insertions, 52 deletions
diff --git a/docs/markdown/Compiler-properties.md b/docs/markdown/Compiler-properties.md index 4def628..579417a 100644 --- a/docs/markdown/Compiler-properties.md +++ b/docs/markdown/Compiler-properties.md @@ -173,7 +173,7 @@ Does a structure contain a member? == Some platforms have different standard structures. Here's how one -would check if a struct called `mystruct` from header `myheader.h</hh> +would check if a struct called `mystruct` from header `myheader.h` contains a member called `some_member`. ```meson diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index a3e1ef0..31c4953 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -910,7 +910,8 @@ Project supports the following keyword arguments. 'GPL3']`. Note that the text is informal and is only written to the dependency manifest. Meson does not do any license validation, you are responsible for verifying that you abide by all licensing - terms. + terms. You can access the value in your Meson build files with + `meson.project_license()`. - `meson_version` takes a string describing which Meson version the project requires. Usually something like `>0.28.0`. @@ -1247,6 +1248,8 @@ the following methods. - `project_version()` returns the version string specified in `project` function call. +- `project_license()` returns the array of licenses specified in `project` function call. + - `project_name()` returns the project name specified in the `project` function call. - `version()` return a string with the version of Meson. diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md index 0503c22..4f67ddc 100644 --- a/docs/markdown/Users.md +++ b/docs/markdown/Users.md @@ -40,6 +40,7 @@ If you have a project that uses Meson that you want to add to this list, let us - [Outlier](https://github.com/kerolasa/outlier), a small Hello World style meson example project - [Pango](https://git.gnome.org/browse/pango/), an Internationalized text layout and rendering library (not the default yet) - [Parzip](https://github.com/jpakkane/parzip), a multithreaded reimplementation of Zip + - [PipeWire](https://pipewire.org/), a framework for video and audio for containerized applications - [Pitivi](http://pitivi.org/), a nonlinear video editor - [Polari](https://git.gnome.org/browse/polari), an IRC client - [Sysprof](https://wiki.gnome.org/Apps/Sysprof), a profiling tool diff --git a/docs/markdown/snippets/project-license.md b/docs/markdown/snippets/project-license.md new file mode 100644 index 0000000..5da2c6a --- /dev/null +++ b/docs/markdown/snippets/project-license.md @@ -0,0 +1,4 @@ +## New method meson.project_license() + +The `meson` builtin object now has a `project_license()` method that returns a +list of all licenses for the project. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 98fd764..dc19b73 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1637,6 +1637,10 @@ class CustomTarget(Target): for i in self.outputs: if not(isinstance(i, str)): raise InvalidArguments('Output argument not a string.') + if i == '': + raise InvalidArguments('Output must not be empty.') + if i.strip() == '': + raise InvalidArguments('Output must not consist only of whitespace.') if '/' in i: raise InvalidArguments('Output must not contain a path segment.') if '@INPUT@' in i or '@INPUT0@' in i: diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 2ea8ed1..542de39 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -63,9 +63,12 @@ from .base import ( # **On Unix**, official packaged versions of boost libraries follow the following schemes: # -# Linux / Debian: libboost_<module>.so.1.66.0 -> libboost_<module>.so -# Linux / Red Hat: libboost_<module>.so.1.66.0 -> libboost_<module>.so -# Linux / OpenSuse: libboost_<module>.so.1.66.0 -> libboost_<module>.so +# Linux / Debian: libboost_<module>.so -> libboost_<module>.so.1.66.0 +# Linux / Red Hat: libboost_<module>.so -> libboost_<module>.so.1.66.0 +# Linux / OpenSuse: libboost_<module>.so -> libboost_<module>.so.1.66.0 +# Win / Cygwin: libboost_<module>.dll.a (location = /usr/lib) +# libboost_<module>.a +# cygboost_<module>_1_64.dll (location = /usr/bin) # Mac / homebrew: libboost_<module>.dylib + libboost_<module>-mt.dylib (location = /usr/local/lib) # Mac / macports: libboost_<module>.dylib + libboost_<module>-mt.dylib (location = /opt/local/lib) # @@ -147,22 +150,7 @@ class BoostDependency(ExternalDependency): self.log_fail() return - invalid_modules = [c for c in self.requested_modules if 'boost_' + c not in BOOST_LIBS] - - # previous versions of meson allowed include dirs as modules - remove = [] - for m in invalid_modules: - if m in BOOST_DIRS: - mlog.warning('Requested boost library', mlog.bold(m), 'that doesn\'t exist. ' - 'This will be an error in the future') - remove.append(m) - - self.requested_modules = [x for x in self.requested_modules if x not in remove] - invalid_modules = [x for x in invalid_modules if x not in remove] - - if invalid_modules: - mlog.log(mlog.red('ERROR:'), 'Invalid Boost modules: ' + ', '.join(invalid_modules)) - self.log_fail() + if self.check_invalid_modules(): return mlog.debug('Boost library root dir is', mlog.bold(self.boost_root)) @@ -183,6 +171,26 @@ class BoostDependency(ExternalDependency): else: self.log_fail() + def check_invalid_modules(self): + invalid_modules = [c for c in self.requested_modules if 'boost_' + c not in BOOST_LIBS] + + # previous versions of meson allowed include dirs as modules + remove = [] + for m in invalid_modules: + if m in BOOST_DIRS: + mlog.warning('Requested boost library', mlog.bold(m), 'that doesn\'t exist. ' + 'This will be an error in the future') + remove.append(m) + + self.requested_modules = [x for x in self.requested_modules if x not in remove] + invalid_modules = [x for x in invalid_modules if x not in remove] + + if invalid_modules: + mlog.log(mlog.red('ERROR:'), 'Invalid Boost modules: ' + ', '.join(invalid_modules)) + self.log_fail() + return True + else: + return False def log_fail(self): module_str = ', '.join(self.requested_modules) @@ -359,15 +367,23 @@ class BoostDependency(ExternalDependency): fname = os.path.basename(entry) self.lib_modules[self.modname_from_filename(fname)] = [fname] + # - Linux leaves off -mt but libraries are multithreading-aware. + # - Cygwin leaves off -mt but libraries are multithreading-aware. + # - Mac requires -mt for multithreading, so should not fall back + # to non-mt libraries. + def abi_tag(self): + if mesonlib.for_windows(self.want_cross, self.env): + return None + if self.is_multithreading and mesonlib.for_darwin(self.want_cross, self.env): + return '-mt' + else: + return '' + def detect_lib_modules_nix(self): all_found = True for module in self.requested_modules: - args = None - libname = 'boost_' + module - if self.is_multithreading and mesonlib.for_darwin(self.want_cross, self.env): - # - Linux leaves off -mt but libraries are multithreading-aware. - # - Mac requires -mt for multithreading, so should not fall back to non-mt libraries. - libname = libname + '-mt' + libname = 'boost_' + module + self.abi_tag() + args = self.compiler.find_library(libname, self.env, self.extra_lib_dirs()) if args is None: mlog.debug('Couldn\'t find library "{}" for boost module "{}"'.format(module, libname)) @@ -416,29 +432,17 @@ class BoostDependency(ExternalDependency): if modname not in self.lib_modules: self.lib_modules[modname] = [entry] - def get_win_link_args(self): - args = [] - # TODO: should this check self.libdir? - if self.libdir: - args.append('-L' + self.libdir) - for lib in self.requested_modules: - args += self.lib_modules['boost_' + lib] - return args - def extra_lib_dirs(self): - dirs = [] - if self.boost_root: - dirs = [os.path.join(self.boost_root, 'lib')] - elif self.libdir: - dirs = [self.libdir] - return dirs + if self.libdir: + return [self.libdir] + elif self.boost_root: + return [os.path.join(self.boost_root, 'lib')] + return [] def get_link_args(self): - if mesonlib.is_windows(): - return self.get_win_link_args() args = [] for dir in self.extra_lib_dirs(): - args += ['-L' + dir] + args += self.compiler.get_linker_search_args(self.libdir) for lib in self.requested_modules: args += self.lib_modules['boost_' + lib] return args diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index edcb92c..459a16d 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1168,6 +1168,7 @@ class MesonMain(InterpreterObject): 'add_postconf_script': self.add_postconf_script_method, 'install_dependency_manifest': self.install_dependency_manifest_method, 'project_version': self.project_version_method, + 'project_license': self.project_license_method, 'version': self.version_method, 'project_name': self.project_name_method, 'get_cross_property': self.get_cross_property_method, @@ -1281,6 +1282,9 @@ class MesonMain(InterpreterObject): def project_version_method(self, args, kwargs): return self.build.dep_manifest[self.interpreter.active_projectname]['version'] + def project_license_method(self, args, kwargs): + return self.build.dep_manifest[self.interpreter.active_projectname]['license'] + def version_method(self, args, kwargs): return coredata.version @@ -3006,6 +3010,8 @@ different subdirectory. def add_target(self, name, tobj): if name == '': raise InterpreterException('Target name must not be empty.') + if name.strip() == '': + raise InterpreterException('Target name must not consist only of whitespace.') if name.startswith('meson-'): raise InvalidArguments("Target names starting with 'meson-' are reserved " "for Meson's internal use. Please rename.") diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 35ca5c8..6618dc8 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -265,6 +265,12 @@ class InterpreterBase: if not isinstance(node.elseblock, mparser.EmptyNode): self.evaluate_codeblock(node.elseblock) + def validate_comparison_types(self, val1, val2): + if type(val1) != type(val2): + mlog.warning('''Trying to compare values of different types ({}, {}). +The result of this is undefined and will become a hard error +in a future Meson release.'''.format(type(val1).__name__, type(val2).__name__)) + def evaluate_comparison(self, node): val1 = self.evaluate_statement(node.left) if is_disabler(val1): @@ -272,15 +278,11 @@ class InterpreterBase: val2 = self.evaluate_statement(node.right) if is_disabler(val2): return val2 + self.validate_comparison_types(val1, val2) if node.ctype == '==': return val1 == val2 elif node.ctype == '!=': return val1 != val2 - elif not isinstance(val1, type(val2)): - raise InterpreterException( - 'Values of different types ({}, {}) cannot be compared using {}.'.format(type(val1).__name__, - type(val2).__name__, - node.ctype)) elif not self.is_elementary_type(val1): raise InterpreterException('{} can only be compared for equality.'.format(node.left.value)) elif not self.is_elementary_type(val2): diff --git a/test cases/common/140 get define/meson.build b/test cases/common/140 get define/meson.build index fd87177..9f5539b 100644 --- a/test cases/common/140 get define/meson.build +++ b/test cases/common/140 get define/meson.build @@ -66,8 +66,8 @@ foreach lang : ['c', 'cpp'] if meson.is_cross_build() # Can't use an empty array as a fallback here because of # https://github.com/mesonbuild/meson/issues/1481 - lang_args = meson.get_cross_property(lang + '_args', false) - if lang_args != false + lang_args = meson.get_cross_property(lang + '_args', []) + if lang_args.length() != 0 foreach lang_arg : lang_args if lang_arg.contains('MESON_TEST_ISSUE_1665') run_1665_test = true diff --git a/test cases/common/175 get project license/bar.c b/test cases/common/175 get project license/bar.c new file mode 100644 index 0000000..864869b --- /dev/null +++ b/test cases/common/175 get project license/bar.c @@ -0,0 +1,6 @@ +#include<stdio.h> + +int main(int argc, char **argv) { + printf("I'm a main project bar.\n"); + return 0; +} diff --git a/test cases/common/175 get project license/meson.build b/test cases/common/175 get project license/meson.build new file mode 100644 index 0000000..37303e3 --- /dev/null +++ b/test cases/common/175 get project license/meson.build @@ -0,0 +1,8 @@ +project('bar', 'c', license: 'Apache') + +executable('bar', 'bar.c') + +license = meson.project_license()[0] +if license != 'Apache' + error('The license should be Apache, but it is: ' + license) +endif |