Fixed buildoptions form source

pull/4547/head
Daniel Mensinger 6 years ago
parent 4b17bbc753
commit 9c214f4a70
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 8
      mesonbuild/environment.py
  2. 16
      mesonbuild/mintro.py

@ -328,14 +328,6 @@ class Environment:
self.first_invocation = False self.first_invocation = False
except FileNotFoundError: except FileNotFoundError:
self.create_new_coredata(options) self.create_new_coredata(options)
except MesonException as e:
# If we stored previous command line options, we can recover from
# a broken/outdated coredata.
if os.path.isfile(coredata.get_cmd_line_file(self.build_dir)):
mlog.warning('Regenerating configuration from scratch.')
mlog.log('Reason:', mlog.red(str(e)))
coredata.read_cmd_line_file(self.build_dir, options)
self.create_new_coredata(options)
except MesonException as e: except MesonException as e:
# If we stored previous command line options, we can recover from # If we stored previous command line options, we can recover from
# a broken/outdated coredata. # a broken/outdated coredata.

@ -251,7 +251,7 @@ class BuildoptionsInterperter(astinterpreter.AstInterpreter):
self.parse_project() self.parse_project()
self.run() self.run()
def list_buildoptions_from_source(sourcedir, backend): def list_buildoptions_from_source(sourcedir, backend, indent):
# Make sure that log entries in other parts of meson don't interfere with the JSON output # Make sure that log entries in other parts of meson don't interfere with the JSON output
mlog.disable() mlog.disable()
backend = backends.get_backend_from_name(backend, None) backend = backends.get_backend_from_name(backend, None)
@ -259,7 +259,8 @@ def list_buildoptions_from_source(sourcedir, backend):
intr.analyze() intr.analyze()
# Reenable logging just in case # Reenable logging just in case
mlog.enable() mlog.enable()
list_buildoptions(intr.coredata) buildoptions = list_buildoptions(intr.coredata)[1]
print(json.dumps(buildoptions, indent=indent))
def list_target_files(target_name, targets, builddata: build.Build): def list_target_files(target_name, targets, builddata: build.Build):
result = [] result = []
@ -424,7 +425,7 @@ class ProjectInfoInterperter(astinterpreter.AstInterpreter):
self.parse_project() self.parse_project()
self.run() self.run()
def list_projinfo_from_source(sourcedir): def list_projinfo_from_source(sourcedir, indent):
files = find_buildsystem_files_list(sourcedir) files = find_buildsystem_files_list(sourcedir)
result = {'buildsystem_files': []} result = {'buildsystem_files': []}
@ -453,21 +454,22 @@ def list_projinfo_from_source(sourcedir):
subprojects = [obj for name, obj in subprojects.items()] subprojects = [obj for name, obj in subprojects.items()]
result['subprojects'] = subprojects result['subprojects'] = subprojects
print(json.dumps(result)) print(json.dumps(result, indent=indent))
def run(options): def run(options):
datadir = 'meson-private' datadir = 'meson-private'
infodir = 'meson-info' infodir = 'meson-info'
indent = options.indent if options.indent > 0 else None
if options.builddir is not None: if options.builddir is not None:
datadir = os.path.join(options.builddir, datadir) datadir = os.path.join(options.builddir, datadir)
infodir = os.path.join(options.builddir, infodir) infodir = os.path.join(options.builddir, infodir)
if options.builddir.endswith('/meson.build') or options.builddir.endswith('\\meson.build') or options.builddir == 'meson.build': if options.builddir.endswith('/meson.build') or options.builddir.endswith('\\meson.build') or options.builddir == 'meson.build':
sourcedir = '.' if options.builddir == 'meson.build' else options.builddir[:-11] sourcedir = '.' if options.builddir == 'meson.build' else options.builddir[:-11]
if options.projectinfo: if options.projectinfo:
list_projinfo_from_source(sourcedir) list_projinfo_from_source(sourcedir, indent)
return 0 return 0
if options.buildoptions: if options.buildoptions:
list_buildoptions_from_source(sourcedir, options.backend) list_buildoptions_from_source(sourcedir, options.backend, indent)
return 0 return 0
if not os.path.isdir(datadir) or not os.path.isdir(infodir): if not os.path.isdir(datadir) or not os.path.isdir(infodir):
print('Current directory is not a meson build directory.' print('Current directory is not a meson build directory.'
@ -514,8 +516,6 @@ def run(options):
with open(curr, 'r') as fp: with open(curr, 'r') as fp:
results += [(i, json.load(fp))] results += [(i, json.load(fp))]
indent = options.indent if options.indent > 0 else None
if len(results) == 0 and not options.force_dict: if len(results) == 0 and not options.force_dict:
print('No command specified') print('No command specified')
return 1 return 1

Loading…
Cancel
Save