Bug 1449623 - allow annotating GENERATED_FILES with required environment variables; r?Build draft
authorMike Shal <mshal@mozilla.com>
Tue, 27 Mar 2018 17:24:59 -0400
changeset 773872 c86ed93e30493eb8c478850636415bb457f83c64
parent 773564 56d6db4ad38c869d0bbc2aea449a4a382f109163
child 773873 97b50b12b016103c85315a2e17187383f22a46bd
push id104335
push userbmo:mshal@mozilla.com
push dateWed, 28 Mar 2018 17:13:53 +0000
reviewersBuild
bugs1449623
milestone61.0a1
Bug 1449623 - allow annotating GENERATED_FILES with required environment variables; r?Build Tup needs to know which environment variables to export to a subprocess so that it can track changes to them. We should annotate GENERATED_FILES scripts with the environment variables they require so this information can get to the backend. MozReview-Commit-ID: B4XRVB5ZkRm
moz.build
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/data.py
python/mozbuild/mozbuild/frontend/emitter.py
--- a/moz.build
+++ b/moz.build
@@ -105,16 +105,17 @@ if not CONFIG['JS_STANDALONE'] or not CO
         '!source-repo.h',
     ]
 
     GENERATED_FILES += [
         'buildid.h',
         'source-repo.h',
     ]
 
+    GENERATED_FILES['buildid.h'].env = ['MOZ_BUILD_DATE']
     GENERATED_FILES['buildid.h'].script = 'build/variables.py:buildid_header'
     GENERATED_FILES['source-repo.h'].script = 'build/variables.py:source_repo_header'
 
     DIRS += [
         'build',
     ]
 
 DIRS += [
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -927,17 +927,18 @@ BugzillaComponent = TypedNamedTuple('Bug
 SchedulingComponents = ContextDerivedTypedRecord(
         ('inclusive', TypedList(unicode, StrictOrderingOnAppendList)),
         ('exclusive', TypedList(unicode, StrictOrderingOnAppendList)))
 
 GeneratedFilesList = StrictOrderingOnAppendListWithFlagsFactory({
     'script': unicode,
     'inputs': list,
     'force': bool,
-    'flags': list, })
+    'flags': list,
+    'env': list, })
 
 
 class Files(SubContext):
     """Metadata attached to files.
 
     It is common to want to annotate files with metadata, such as which
     Bugzilla component tracks issues with certain files. This sub-context is
     where we stick that metadata.
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -1137,28 +1137,30 @@ class GeneratedFile(ContextDerived):
         'script',
         'method',
         'outputs',
         'inputs',
         'flags',
         'required_for_compile',
         'localized',
         'force',
+        'env',
     )
 
     def __init__(self, context, script, method, outputs, inputs,
-                 flags=(), localized=False, force=False):
+                 flags=(), localized=False, force=False, env=[]):
         ContextDerived.__init__(self, context)
         self.script = script
         self.method = method
         self.outputs = outputs if isinstance(outputs, tuple) else (outputs,)
         self.inputs = inputs
         self.flags = flags
         self.localized = localized
         self.force = force
+        self.env = env
 
         suffixes = (
             '.c',
             '.cpp',
             '.h',
             '.inc',
             '.py',
             '.rs',
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -1390,17 +1390,18 @@ class TreeMetadataEmitter(LoggingMixin):
                     if (isinstance(p, SourcePath) and
                             not os.path.exists(p.full_path)):
                         raise SandboxValidationError(
                             'Input for generating %s does not exist: %s'
                             % (f, p.full_path), context)
                     inputs.append(p)
 
                 yield GeneratedFile(context, script, method, outputs, inputs,
-                                    flags.flags, localized=localized, force=flags.force)
+                                    flags.flags, localized=localized, force=flags.force,
+                                    env=flags.env)
 
     def _process_test_manifests(self, context):
         for prefix, info in TEST_MANIFESTS.items():
             for path, manifest in context.get('%s_MANIFESTS' % prefix, []):
                 for obj in self._process_test_manifest(context, info, path, manifest):
                     yield obj
 
         for flavor in REFTEST_FLAVORS: