Expose project information with mesonintrospect. Closes #1118.

pull/1154/head
Jussi Pakkanen 8 years ago
parent c7a2664cb7
commit b28da68faf
  1. 4
      mesonbuild/interpreter.py
  2. 16
      mesonbuild/mintro.py

@ -1399,7 +1399,7 @@ class Interpreter(InterpreterBase):
raise InterpreterException('Subproject %s version is %s but %s required.' % (dirname, pv, wanted))
self.active_projectname = current_active
mlog.log('\nSubproject', mlog.bold(dirname), 'finished.')
self.build.subprojects[dirname] = True
self.build.subprojects[dirname] = subi.project_version
self.subprojects.update(subi.subprojects)
self.subprojects[dirname] = SubprojectHolder(subi)
self.build_def_files += subi.build_def_files
@ -1473,6 +1473,8 @@ class Interpreter(InterpreterBase):
raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
self.active_projectname = args[0]
self.project_version = kwargs.get('version', 'undefined')
if self.build.project_version is None:
self.build.project_version = self.project_version
proj_license = mesonlib.stringlistify(kwargs.get('license', 'unknown'))
self.build.dep_manifest[args[0]] = {'version': self.project_version,
'license': proj_license}

@ -39,6 +39,8 @@ parser.add_argument('--benchmarks', action='store_true', dest='benchmarks', defa
help='List all benchmarks.')
parser.add_argument('--dependencies', action='store_true', dest='dependencies', default=False,
help='list external dependencies.')
parser.add_argument('--projectinfo', action='store_true', dest='projectinfo', default=False,
help='information about projects.')
parser.add_argument('args', nargs='+')
def determine_installed_path(target, installdata):
@ -179,6 +181,18 @@ def list_tests(testdata):
result.append(to)
print(json.dumps(result))
def list_projinfo(builddata):
result = {}
result['name'] = builddata.project_name
result['version'] = builddata.project_version
subprojects = []
for k, v in builddata.subprojects.items():
c = {'name' : k,
'version' : v}
subprojects.append(c)
result['subprojects'] = subprojects
print(json.dumps(result))
def run(args):
options = parser.parse_args(args)
if len(options.args) > 1:
@ -217,6 +231,8 @@ def run(args):
list_tests(benchmarkdata)
elif options.dependencies:
list_deps(coredata)
elif options.projectinfo:
list_projinfo(builddata)
else:
print('No command specified')
return 1

Loading…
Cancel
Save