bug 1318143 - add a --with-visual-studio-version to choose which VS version configure chooses when multiple versions are installed. r=gps, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorTed Mielczarek <ted@mielczarek.org>
Thu, 20 Apr 2017 12:43:44 -0400
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357460 af87ef1f49d43d4cc97125025fa04aa4cd6e7d76
parent 357459 fa02f4b5f129bad7419f75a60f7dd559a68a23c7
child 357461 8a25ba5859ed45b6827ad7a96823b5570f297f7b
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, IanN
bugs1318143
milestone52.9.1
bug 1318143 - add a --with-visual-studio-version to choose which VS version configure chooses when multiple versions are installed. r=gps, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -420,37 +420,52 @@ def get_vc_paths(topsrcdir):
         tools_version = open(os.path.join(path, r'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt'), 'rb').read().strip()
         tools_path = os.path.join(path, r'VC\Tools\MSVC', tools_version, r'bin\HostX64')
         yield (Version(install['installationVersion']), {
             'x64': [os.path.join(tools_path, 'x64')],
             # The x64->x86 cross toolchain requires DLLs from the native x64 toolchain.
             'x86': [os.path.join(tools_path, 'x86'), os.path.join(tools_path, 'x64')],
         })
 
+option('--with-visual-studio-version', nargs=1,
+       choices=('2015', '2017'),
+       help='Select a specific Visual Studio version to use')
 
-@depends(host, target, check_build_environment)
+@depends('--with-visual-studio-version')
+def vs_major_version(value):
+    if value:
+        return {'2015': 14,
+                '2017': 15}[value[0]]
+
+@depends(host, target, vs_major_version, check_build_environment, '--with-visual-studio-version')
 @imports(_from='__builtin__', _import='sorted')
 @imports(_from='operator', _import='itemgetter')
 @imports('platform')
-def vc_compiler_path(host, target, env):
+def vc_compiler_path(host, target, vs_major_version, env, vs_release_name):
     if host.kernel != 'WINNT':
         return
     vc_target = {
         'x86': 'x86',
         'x86_64': 'x64',
         'arm': 'arm',
     }.get(target.cpu)
     if vc_target is None:
         return
 
     all_versions = sorted(get_vc_paths(env.topsrcdir), key=itemgetter(0))
     if not all_versions:
         return
-    # Choose the newest version.
-    data = all_versions[-1][1]
+    if vs_major_version:
+        versions = [d for (v, d) in all_versions if v.major == vs_major_version]
+        if not versions:
+            die('Visual Studio %s could not be found!' % vs_release_name)
+        data = versions[0]
+    else:
+        # Choose the newest version.
+        data = all_versions[-1][1]
     paths = data.get(vc_target)
     if not paths:
         return
     return paths
 
 
 @depends(vc_compiler_path)
 @imports('os')