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)) raise InterpreterException('Subproject %s version is %s but %s required.' % (dirname, pv, wanted))
self.active_projectname = current_active self.active_projectname = current_active
mlog.log('\nSubproject', mlog.bold(dirname), 'finished.') 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.update(subi.subprojects)
self.subprojects[dirname] = SubprojectHolder(subi) self.subprojects[dirname] = SubprojectHolder(subi)
self.build_def_files += subi.build_def_files 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') raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
self.active_projectname = args[0] self.active_projectname = args[0]
self.project_version = kwargs.get('version', 'undefined') 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')) proj_license = mesonlib.stringlistify(kwargs.get('license', 'unknown'))
self.build.dep_manifest[args[0]] = {'version': self.project_version, self.build.dep_manifest[args[0]] = {'version': self.project_version,
'license': proj_license} 'license': proj_license}

@ -39,6 +39,8 @@ parser.add_argument('--benchmarks', action='store_true', dest='benchmarks', defa
help='List all benchmarks.') help='List all benchmarks.')
parser.add_argument('--dependencies', action='store_true', dest='dependencies', default=False, parser.add_argument('--dependencies', action='store_true', dest='dependencies', default=False,
help='list external dependencies.') help='list external dependencies.')
parser.add_argument('--projectinfo', action='store_true', dest='projectinfo', default=False,
help='information about projects.')
parser.add_argument('args', nargs='+') parser.add_argument('args', nargs='+')
def determine_installed_path(target, installdata): def determine_installed_path(target, installdata):
@ -179,6 +181,18 @@ def list_tests(testdata):
result.append(to) result.append(to)
print(json.dumps(result)) 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): def run(args):
options = parser.parse_args(args) options = parser.parse_args(args)
if len(options.args) > 1: if len(options.args) > 1:
@ -217,6 +231,8 @@ def run(args):
list_tests(benchmarkdata) list_tests(benchmarkdata)
elif options.dependencies: elif options.dependencies:
list_deps(coredata) list_deps(coredata)
elif options.projectinfo:
list_projinfo(builddata)
else: else:
print('No command specified') print('No command specified')
return 1 return 1

Loading…
Cancel
Save