summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2018-12-29 22:55:48 +0100
committerDaniel Mensinger <daniel@mensinger-ka.de>2018-12-29 23:55:45 +0100
commitc033af914ae706dfecc58213a4d756f16a21b8dc (patch)
tree77ae3f34ef4810c5cc4bf4ce27c523c109754732
parent10ce5deb71a06a6f323516c68f7522c9d5ee7056 (diff)
downloadmeson-c033af914ae706dfecc58213a4d756f16a21b8dc.tar.gz
Disable mlog and don't require build directory for environment
-rw-r--r--mesonbuild/environment.py43
-rw-r--r--mesonbuild/mlog.py12
2 files changed, 37 insertions, 18 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 0bd2a8cac..71f75f906 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -310,25 +310,32 @@ class Environment:
def __init__(self, source_dir, build_dir, options):
self.source_dir = source_dir
self.build_dir = build_dir
- self.scratch_dir = os.path.join(build_dir, Environment.private_dir)
- self.log_dir = os.path.join(build_dir, Environment.log_dir)
- os.makedirs(self.scratch_dir, exist_ok=True)
- os.makedirs(self.log_dir, exist_ok=True)
- try:
- self.coredata = coredata.load(self.get_build_dir())
- self.first_invocation = False
- except FileNotFoundError:
- 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)
+
+ # Do not try to create build directories when build_dir is none.
+ # This reduced mode is used by the --buildoptions introspector
+ if build_dir is not None:
+ self.scratch_dir = os.path.join(build_dir, Environment.private_dir)
+ self.log_dir = os.path.join(build_dir, Environment.log_dir)
+ os.makedirs(self.scratch_dir, exist_ok=True)
+ os.makedirs(self.log_dir, exist_ok=True)
+ try:
+ self.coredata = coredata.load(self.get_build_dir())
+ self.first_invocation = False
+ except FileNotFoundError:
self.create_new_coredata(options)
- else:
- raise e
+ 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)
+ else:
+ raise e
+ else:
+ # Just create a fresh coredata in this case
+ self.create_new_coredata(options)
self.exe_wrapper = None
self.machines = MachineInfos()
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index ea99d0971..57debb06a 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -47,6 +47,15 @@ log_fname = 'meson-log.txt'
log_depth = 0
log_timestamp_start = None
log_fatal_warnings = False
+log_disable_stdout = False
+
+def disable():
+ global log_disable_stdout
+ log_disable_stdout = True
+
+def enable():
+ global log_disable_stdout
+ log_disable_stdout = False
def initialize(logdir, fatal_warnings=False):
global log_dir, log_file, log_fatal_warnings
@@ -118,6 +127,9 @@ def process_markup(args, keep):
return arr
def force_print(*args, **kwargs):
+ global log_disable_stdout
+ if log_disable_stdout:
+ return
iostr = io.StringIO()
kwargs['file'] = iostr
print(*args, **kwargs)