aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 0bd2a8c..71f75f9 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()