Bug 1192064 - Determine |mach artifact| job from mozconfig. r=me
authorNick Alexander <nalexander@mozilla.com>
Fri, 23 Oct 2015 15:02:02 -0700
changeset 304506 599cddea4a027034f05a3b99c8050c592a7241c8
parent 304505 48711da1e0658f9b533e2e45f50b9e90199016c5
child 304507 06a0edd5da4d5a485b4d64d0764149723c56c1c6
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1192064
milestone44.0a1
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 1192064 - Determine |mach artifact| job from mozconfig. r=me
mobile/android/mach_commands.py
--- a/mobile/android/mach_commands.py
+++ b/mobile/android/mach_commands.py
@@ -160,16 +160,33 @@ class MachCommands(MachCommandBase):
 
         if not quiet:
             if not code:
                 print(SUCCESS.format(topobjdir=self.topobjdir))
 
         return code
 
 
+class ArtifactSubCommand(SubCommand):
+    def __init__(self, *args, **kwargs):
+        SubCommand.__init__(self, *args, **kwargs)
+
+    def __call__(self, func):
+        after = SubCommand.__call__(self, func)
+        args = [
+            CommandArgument('--tree', metavar='TREE', type=str,
+                help='Firefox tree.'),
+            CommandArgument('--job', metavar='JOB', choices=['android-api-11', 'android-x86'],
+                help='Build job.'),
+        ]
+        for arg in args:
+            after = arg(after)
+        return after
+
+
 @CommandProvider
 class PackageFrontend(MachCommandBase):
     """Fetch and install binary artifacts from Mozilla automation."""
 
     @Command('artifact', category='post-build',
         description='Use pre-built artifacts to build Fennec.',
         conditions=[
             conditions.is_android,  # mobile/android only for now.
@@ -205,68 +222,57 @@ class PackageFrontend(MachCommandBase):
         import which
         hg = which.which('hg')
 
         # Absolutely must come after the virtualenv is populated!
         from mozbuild.artifacts import Artifacts
         artifacts = Artifacts(tree, job, log=self.log, cache_dir=cache_dir, hg=hg)
         return artifacts
 
-    @SubCommand('artifact', 'install',
+    def _compute_defaults(self, tree=None, job=None):
+        # Firefox front-end developers mostly use fx-team.  Post auto-land, make this central.
+        tree = tree or 'fx-team'
+        if job:
+            return (tree, job)
+        if self.substs['ANDROID_CPU_ARCH'] == 'x86':
+            return (tree, 'android-x86')
+        return (tree, 'android-api-11')
+
+    @ArtifactSubCommand('artifact', 'install',
         'Install a good pre-built artifact.')
-    @CommandArgument('--tree', metavar='TREE', type=str,
-        help='Firefox tree.',
-        default='fx-team')  # TODO: switch to central as this stabilizes.
-    @CommandArgument('--job', metavar='JOB', choices=['android-api-11', 'android-x86'],
-        help='Build job.',
-        default='android-api-11')  # TODO: fish job from build configuration.
     @CommandArgument('source', metavar='SRC', nargs='?', type=str,
         help='Where to fetch and install artifacts from.  Can be omitted, in '
             'which case the current hg repository is inspected; an hg revision; '
             'a remote URL; or a local file.',
         default=None)
     def artifact_install(self, source=None, tree=None, job=None):
+        tree, job = self._compute_defaults(tree, job)
         artifacts = self._make_artifacts(tree=tree, job=job)
         return artifacts.install_from(source, self.distdir)
 
-    @SubCommand('artifact', 'last',
+    @ArtifactSubCommand('artifact', 'last',
         'Print the last pre-built artifact installed.')
-    @CommandArgument('--tree', metavar='TREE', type=str,
-        help='Firefox tree.',
-        default='fx-team')
-    @CommandArgument('--job', metavar='JOB', type=str,
-        help='Build job.',
-        default='android-api-11')
     def artifact_print_last(self, tree=None, job=None):
+        tree, job = self._compute_defaults(tree, job)
         artifacts = self._make_artifacts(tree=tree, job=job)
         artifacts.print_last()
         return 0
 
-    @SubCommand('artifact', 'print-cache',
+    @ArtifactSubCommand('artifact', 'print-cache',
         'Print local artifact cache for debugging.')
-    @CommandArgument('--tree', metavar='TREE', type=str,
-        help='Firefox tree.',
-        default='fx-team')
-    @CommandArgument('--job', metavar='JOB', type=str,
-        help='Build job.',
-        default='android-api-11')
     def artifact_print_cache(self, tree=None, job=None):
+        tree, job = self._compute_defaults(tree, job)
         artifacts = self._make_artifacts(tree=tree, job=job)
         artifacts.print_cache()
         return 0
 
-    @SubCommand('artifact', 'clear-cache',
+    @ArtifactSubCommand('artifact', 'clear-cache',
         'Delete local artifacts and reset local artifact cache.')
-    @CommandArgument('--tree', metavar='TREE', type=str,
-        help='Firefox tree.',
-        default='fx-team')
-    @CommandArgument('--job', metavar='JOB', type=str,
-        help='Build job.',
-        default='android-api-11')
     def artifact_clear_cache(self, tree=None, job=None):
+        tree, job = self._compute_defaults(tree, job)
         artifacts = self._make_artifacts(tree=tree, job=job)
         artifacts.clear_cache()
         return 0
 
 @CommandProvider
 class AndroidEmulatorCommands(MachCommandBase):
     """
        Run the Android emulator with one of the AVDs used in the Mozilla