Bug 1520681 - Use proper defaults for --enable-default-toolkit. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 17 Jan 2019 16:04:29 +0000
changeset 514341 bd5f0c60f8a9274030f8e38893fb72549ae3d5be
parent 514340 d08e4acf1e85a899548197db07871a9645935c7e
child 514342 6896f8bf818180ef3bdf042d707713a0aa410b9f
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1520681, 1322025
milestone66.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 1520681 - Use proper defaults for --enable-default-toolkit. r=froydnj Back when those were added, option defaults could not indirectly depend on `target` or `host`, but that changed with bug 1322025. Differential Revision: https://phabricator.services.mozilla.com/D16778
toolkit/moz.configure
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -178,49 +178,40 @@ def l10n_base(value, automation, target,
             'l10n-central')
     return os.path.realpath(os.path.abspath(path))
 
 set_config('L10NBASEDIR', l10n_base)
 
 
 # Default toolkit
 # ==============================================================
-# Normally, we'd want to use the `default` field on the option, but that
-# requires --target to be resolved at --help time, which requires to run
-# config.guess, which we want to avoid. Even better, we could actually set
-# `choices` depending on the target, but that doesn't pan out for the same
-# reason.
+@depends(target)
+def toolkit_choices(target):
+    if target.os == 'WINNT':
+        return ('cairo-windows',)
+    elif target.os == 'OSX':
+        return ('cairo-cocoa',)
+    elif target.os == 'iOS':
+        return ('cairo-uikit',)
+    elif target.os == 'Android':
+        return ('cairo-android',)
+    else:
+        return ('cairo-gtk3', 'cairo-gtk3-wayland')
+
+@depends(toolkit_choices)
+def toolkit_default(choices):
+    return choices[0]
+
 option('--enable-default-toolkit', nargs=1,
-       choices=('cairo-windows', 'cairo-gtk3', 'cairo-gtk3-wayland',
-                'cairo-cocoa', 'cairo-uikit', 'cairo-android'),
+       choices=toolkit_choices, default=toolkit_default,
        help='Select default toolkit')
 
-@depends('--enable-default-toolkit', target)
-def full_toolkit(value, target):
-    # Define possible choices for each platform. The default is the first one
-    # listed when there are several.
-    if target.os == 'WINNT':
-        platform_choices = ('cairo-windows',)
-    elif target.os == 'OSX':
-        platform_choices = ('cairo-cocoa',)
-    elif target.os == 'iOS':
-        platform_choices = ('cairo-uikit',)
-    elif target.os == 'Android':
-        platform_choices = ('cairo-android',)
-    else:
-        platform_choices = ('cairo-gtk3', 'cairo-gtk3-wayland')
-
-    if value:
-        if value[0] not in platform_choices:
-            die('`%s` is not a valid value for --enable-default-toolkit on %s\n'
-                'Valid values: %s', value[0], target.os,
-                ', '.join(platform_choices))
-        return value[0]
-
-    return platform_choices[0]
+@depends_if('--enable-default-toolkit')
+def full_toolkit(value):
+    return value[0]
 
 @depends(full_toolkit)
 def toolkit(toolkit):
     if toolkit == 'cairo-gtk3-wayland':
         widget_toolkit = 'gtk3'
     else:
         widget_toolkit = toolkit.replace('cairo-', '')
     return widget_toolkit