Bug 1264482 - Use the EnumString type for the different values we get out of split_triplet. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 06 Apr 2016 09:56:35 +0900
changeset 331689 4e3809b7b919db8ed2ba458b8514bda62c9917ef
parent 331688 177380345f2fc53853aa53e0aceca74a022a8e2f
child 331690 3abd062e590cf38b1addb1fd3a24fe38a5cc7d6d
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1264482
milestone48.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 1264482 - Use the EnumString type for the different values we get out of split_triplet. r=ted
build/moz.configure/android-ndk.configure
build/moz.configure/init.configure
python/mozbuild/mozbuild/configure/constants.py
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -34,17 +34,17 @@ def android_toolchain(target, host, ndk,
         return
     if toolchain:
         return toolchain[0]
     else:
         if target.cpu == 'arm' and target.endianness == 'little':
             target_base = 'arm-linux-androideabi'
         elif target.cpu == 'x86':
             target_base = 'x86'
-        elif target.cpu == 'mips' and target.endianness == 'little':
+        elif target.cpu == 'mips32' and target.endianness == 'little':
             target_base = 'mipsel-linux-android'
         else:
             die('Target cpu is not supported.')
 
         toolchain_format = '%s/toolchains/%s-%s/prebuilt/%s-%s'
 
         for version in gnu_compiler_version or ['4.9', '4.8', '4.7']:
             toolchain = toolchain_format % (ndk, target_base, version,
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -308,16 +308,20 @@ def shell(mozillabuild):
 # Host and target systems
 # ==============================================================
 option('--host', nargs=1, help='Define the system type performing the build')
 
 option('--target', nargs=1,
        help='Define the system type where the resulting executables will be '
             'used')
 
+@imports(_from='mozbuild.configure.constants', _import='CPU')
+@imports(_from='mozbuild.configure.constants', _import='Endianness')
+@imports(_from='mozbuild.configure.constants', _import='Kernel')
+@imports(_from='mozbuild.configure.constants', _import='OS')
 def split_triplet(triplet):
     # The standard triplet is defined as
     #   CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
     # There is also a quartet form:
     #   CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
     # But we can consider the "KERNEL-OPERATING_SYSTEM" as one.
     cpu, manufacturer, os = triplet.split('-', 2)
 
@@ -403,20 +407,20 @@ def split_triplet(triplet):
         canonical_cpu = 'aarch64'
         endianness = 'little'
     else:
         canonical_cpu = cpu
         endianness = 'unknown'
 
     return namespace(
         alias=triplet,
-        cpu=canonical_cpu,
-        kernel=canonical_kernel,
-        os=canonical_os,
-        endianness=endianness,
+        cpu=CPU(canonical_cpu),
+        kernel=Kernel(canonical_kernel),
+        os=OS(canonical_os),
+        endianness=Endianness(endianness),
         raw_cpu=cpu,
         raw_os=os,
         # Toolchains, most notably for cross compilation may use cpu-os
         # prefixes.
         toolchain='%s-%s' % (cpu, os),
     )
 
 
@@ -488,17 +492,17 @@ def target_variables(target):
     elif target.kernel == 'Darwin' or (target.kernel == 'Linux' and
                                        target.os == 'GNU'):
         os_target = target.kernel
         os_arch = target.kernel
     else:
         os_target = target.os
         os_arch = target.kernel
 
-    if target.os == 'Darwin' and target.cpu == 'x86':
+    if target.kernel == 'Darwin' and target.cpu == 'x86':
         os_test = 'i386'
     else:
         os_test = target.raw_cpu
 
     return namespace(
         OS_TARGET=os_target,
         OS_ARCH=os_arch,
         OS_TEST=os_test,
--- a/python/mozbuild/mozbuild/configure/constants.py
+++ b/python/mozbuild/mozbuild/configure/constants.py
@@ -8,8 +8,54 @@ from mozbuild.util import EnumString
 
 
 CompilerType = EnumString.subclass(
     'clang',
     'clang-cl',
     'gcc',
     'msvc',
 )
+
+OS = EnumString.subclass(
+    'Android',
+    'DragonFly',
+    'FreeBSD',
+    'GNU',
+    'iOS',
+    'NetBSD',
+    'OpenBSD',
+    'OSX',
+    'WINNT',
+)
+
+Kernel = EnumString.subclass(
+    'Darwin',
+    'DragonFly',
+    'FreeBSD',
+    'kFreeBSD',
+    'Linux',
+    'NetBSD',
+    'OpenBSD',
+    'WINNT',
+)
+
+CPU = EnumString.subclass(
+    'aarch64',
+    'Alpha',
+    'arm',
+    'hppa',
+    'ia64',
+    'mips32',
+    'mips64',
+    'ppc',
+    'ppc64',
+    's390',
+    's390x',
+    'sparc',
+    'sparc64',
+    'x86',
+    'x86_64',
+)
+
+Endianness = EnumString.subclass(
+    'big',
+    'little',
+)