diff options
-rw-r--r-- | docs/markdown/Reference-manual.md | 5 | ||||
-rw-r--r-- | docs/markdown/snippets/project-license.md | 4 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 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 |
5 files changed, 26 insertions, 1 deletions
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/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/interpreter.py b/mesonbuild/interpreter.py index 9c2fd00..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 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 |