From b52955ff3d3a73891c9250b0c6e3839593cd456b Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 7 Jul 2017 00:24:19 -0400 Subject: Run postconf scripts after dumping coredata. MESONINTROSPECT is set when running postconf scripts, which implies that introspection is possible. But it isn't really possible because coredata hasn't been written yet. We also still need to make sure to delete coredata if any postconf scripts fail. --- mesonbuild/environment.py | 1 + mesonbuild/mesonmain.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 07489a1..b0002a0 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -349,6 +349,7 @@ class Environment: cdf = os.path.join(self.get_build_dir(), Environment.coredata_file) coredata.save(self.coredata, cdf) os.utime(cdf, times=(mtime, mtime)) + return cdf def get_script_dir(self): import mesonbuild.scripts diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 603be18..0164945 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -180,20 +180,26 @@ If you want to change option values, use the mesonconf tool instead.''' intr.run() coredata_mtime = time.time() g.generate(intr) - g.run_postconf_scripts() dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') with open(dumpfile, 'wb') as f: pickle.dump(b, f) - # Write this last since we use the existence of this file to check if - # we generated the build file successfully, so we don't want an error - # that pops up during generation, post-conf scripts, etc to cause us to + # Write this as late as possible since we use the existence of this + # file to check if we generated the build file successfully, so we + # don't want an error that pops up during generation, etc to cause us to # incorrectly signal a successful meson run which will cause an error # about an already-configured build directory when the user tries again. # # However, we set the mtime to an earlier value to ensure that doing an # mtime comparison between the coredata dump and other build files # shows the build files to be newer, not older. - env.dump_coredata(coredata_mtime) + cdf = env.dump_coredata(coredata_mtime) + # Post-conf scripts must be run after writing coredata or else introspection fails. + try: + g.run_postconf_scripts() + except: + os.unlink(cdf) + raise + def run_script_command(args): cmdname = args[0] -- cgit v1.1