Bug 1391427 - Add script 'arguments' key to toolchain tasks. r?glandium draft
authorRalph Giles <giles@mozilla.com>
Tue, 12 Sep 2017 16:06:15 -0700
changeset 663405 3fbcd1f4793cf1f1b4669c799f3a41e8a2c8c851
parent 663404 0abb2615759e48fb0a5237a15db6bd4a85f38977
child 663406 973931045ab7184229d8f67d0a7e2478aec2677f
child 663412 c3cadecc3d724f802d6a70bf81fa3f7ccc4fb154
push id79430
push userbmo:giles@thaumas.net
push dateTue, 12 Sep 2017 23:54:08 +0000
reviewersglandium
bugs1391427
milestone57.0a1
Bug 1391427 - Add script 'arguments' key to toolchain tasks. r?glandium Add an optional 'arguments' key to the yaml description for toolchain tasks. This is just a string which is appended to the script invocation. This lets us set behaviour, e.g. selecting the version to build or selecting targets from the task description instead of having to hard-code those things in the build script itself. Where the same script otherwise works for multiple configurations, that is easier to update and simplifies supporting variants. MozReview-Commit-ID: 30oJYnQaZ7A
taskcluster/taskgraph/transforms/job/toolchain.py
--- a/taskcluster/taskgraph/transforms/job/toolchain.py
+++ b/taskcluster/taskgraph/transforms/job/toolchain.py
@@ -24,19 +24,24 @@ from taskgraph.util.hash import hash_pat
 from taskgraph import GECKO
 
 
 TOOLCHAIN_INDEX = 'gecko.cache.level-{level}.toolchains.v1.{name}.{digest}'
 
 toolchain_run_schema = Schema({
     Required('using'): 'toolchain-script',
 
-    # the script (in taskcluster/scripts/misc) to run
+    # The script (in taskcluster/scripts/misc) to run.
+    # Python scripts are invoked with `mach python` so vendored libraries
+    # are available.
     Required('script'): basestring,
 
+    # Arguments to pass to the script.
+    Optional('arguments'): basestring,
+
     # If not false, tooltool downloads will be enabled via relengAPIProxy
     # for either just public files, or all files.  Not supported on Windows
     Required('tooltool-downloads', default=False): Any(
         False,
         'public',
         'internal',
     ),
 
@@ -59,31 +64,36 @@ def add_optimizations(config, run, taskd
     files.append('taskcluster/taskgraph/transforms/job/toolchain.py')
     # The script
     files.append('taskcluster/scripts/misc/{}'.format(run['script']))
     # Tooltool manifest if any is defined:
     tooltool_manifest = taskdesc['worker']['env'].get('TOOLTOOL_MANIFEST')
     if tooltool_manifest:
         files.append(tooltool_manifest)
 
-    digest = hash_paths(GECKO, files)
+    # Accumulate dependency hashes for index generation.
+    data = [hash_paths(GECKO, files)]
 
     # If the task has dependencies, we need those dependencies to influence
     # the index path. So take the digest from the files above, add the list
     # of its dependencies, and hash the aggregate.
     # If the task has no dependencies, just use the digest from above.
     deps = taskdesc['dependencies']
     if deps:
-        data = [digest] + sorted(deps.values())
-        digest = hashlib.sha256('\n'.join(data)).hexdigest()
+        data.extend(sorted(deps.values()))
+
+    # Likewise script arguments should influence the index.
+    args = run.get('arguments')
+    if args:
+        data.append(args)
 
     label = taskdesc['label']
     subs = {
         'name': label.replace('%s-' % config.kind, ''),
-        'digest': digest,
+        'digest': hashlib.sha256('\n'.join(data)).hexdigest()
     }
 
     optimizations = taskdesc.setdefault('optimizations', [])
 
     # We'll try to find a cached version of the toolchain at levels above
     # and including the current level, starting at the highest level.
     for level in reversed(range(int(config.params['level']), 4)):
         subs['level'] = level