# HG changeset patch # User Mike Shal # Date 1526333421 14400 # Mon May 14 17:30:21 2018 -0400 # Node ID d90a5a4aab56b989e8780970ede900dd39916535 # Parent a6c147f96297b8d200a64ac1bec2d18cd784bfd9 Bug 1461795 - Use FileAvoidWrite when writing mozinfo.json; r=chmanchester Since MozbuildObject.from_environment() reads from mozinfo.json, tup picks up that file as a dependency for anything that imports buildconfig (eg: all generated files). Using FileAvoidWrite when creating mozinfo.json will help avoid unnecessary work after re-running configure in the tup backend. MozReview-Commit-ID: EEOPQYJA1MV diff --git a/configure.py b/configure.py --- a/configure.py +++ b/configure.py @@ -103,17 +103,16 @@ def config_status(config): config['TOPSRCDIR']))) with open('configure.d', 'w') as fh: mk.dump(fh) # Other things than us are going to run this file, so we need to give it # executable permissions. os.chmod('config.status', 0o755) if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'): - os.environ[b'WRITE_MOZINFO'] = b'1' from mozbuild.config_status import config_status # Some values in sanitized_config also have more complex types, such as # EnumString, which using when calling config_status would currently # break the build, as well as making it inconsistent with re-running # config.status. Fortunately, EnumString derives from unicode, so it's # covered by converting unicode strings. diff --git a/python/mozbuild/mozbuild/config_status.py b/python/mozbuild/mozbuild/config_status.py --- a/python/mozbuild/mozbuild/config_status.py +++ b/python/mozbuild/mozbuild/config_status.py @@ -17,16 +17,17 @@ import time from argparse import ArgumentParser from mach.logging import LoggingManager from mozbuild.backend.configenvironment import ConfigEnvironment from mozbuild.base import MachCommandConditions from mozbuild.frontend.emitter import TreeMetadataEmitter from mozbuild.frontend.reader import BuildReader from mozbuild.mozinfo import write_mozinfo +from mozbuild.util import FileAvoidWrite from itertools import chain from mozbuild.backend import ( backends, get_backend_class, ) @@ -109,20 +110,18 @@ def config_status(topobjdir='.', topsrcd # Without -n, the current directory is meant to be the top object directory if not options.not_topobjdir: topobjdir = os.path.abspath('.') env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines, non_global_defines=non_global_defines, substs=substs, source=source, mozconfig=mozconfig) - # mozinfo.json only needs written if configure changes and configure always - # passes this environment variable. - if 'WRITE_MOZINFO' in os.environ: - write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ) + with FileAvoidWrite(os.path.join(topobjdir, 'mozinfo.json')) as f: + write_mozinfo(f, env, os.environ) cpu_start = time.clock() time_start = time.time() # Make appropriate backend instances, defaulting to RecursiveMakeBackend, # or what is in BUILD_BACKENDS. selected_backends = [get_backend_class(b)(env) for b in options.backend]