Bug 1461795 - Use FileAvoidWrite when writing mozinfo.json; r=chmanchester
authorMike Shal <mshal@mozilla.com>
Mon, 14 May 2018 17:30:21 -0400
changeset 475218 d90a5a4aab56b989e8780970ede900dd39916535
parent 475217 d12609149b23842215f0d715a0f875918589f2e9
child 475219 91762db62c2b724685bab9235b9f55baa46a2f1e
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/configure.py
+++ b/configure.py
@@ -103,17 +103,16 @@ def config_status(config):
     with open('configure.d', 'w') as 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.
--- 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 (
@@ -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]