From 144565fabff7c872b7c45970bb0e30235b2e9324 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 30 May 2016 20:29:35 +0300 Subject: [PATCH] Added method to get current project name. --- mesonbuild/interpreter.py | 4 ++++ test cases/common/49 subproject/meson.build | 2 ++ .../common/49 subproject/subprojects/sublib/meson.build | 2 ++ 3 files changed, 8 insertions(+) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 8d260f0ed..47f9c7e38 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -837,6 +837,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_name' : self.project_name_method, }) def add_install_script_method(self, args, kwargs): @@ -933,6 +934,9 @@ class MesonMain(InterpreterObject): def project_version_method(self, args, kwargs): return self.build.dep_manifest[self.interpreter.active_projectname]['version'] + def project_name_method(self, args, kwargs): + return self.interpreter.active_projectname + class Interpreter(): def __init__(self, build, backend, subproject='', subdir='', subproject_dir='subprojects'): diff --git a/test cases/common/49 subproject/meson.build b/test cases/common/49 subproject/meson.build index 1e05ddfae..c6ec1160f 100644 --- a/test cases/common/49 subproject/meson.build +++ b/test cases/common/49 subproject/meson.build @@ -2,6 +2,8 @@ project('subproj user', 'c', version : '2.3.4', license : 'mylicense') +assert(meson.project_name() == 'subproj user', 'Incorrect project name') + sub = subproject('sublib', version : '1.0.0') if meson.project_version() != '2.3.4' diff --git a/test cases/common/49 subproject/subprojects/sublib/meson.build b/test cases/common/49 subproject/subprojects/sublib/meson.build index 3da031b49..269f8157f 100644 --- a/test cases/common/49 subproject/subprojects/sublib/meson.build +++ b/test cases/common/49 subproject/subprojects/sublib/meson.build @@ -6,6 +6,8 @@ if not meson.is_subproject() error('Claimed to be master project even though we are a subproject.') endif +assert(meson.project_name() == 'subproject', 'Incorrect subproject name') + if meson.project_version() != '1.0.0' error('Incorrect version string in subproject.') endif