Bug 1289679 - Support detecting Windows SDK 10. r=chmanchester, a=me
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 27 Jul 2016 15:37:54 +0900
changeset 348942 db3ed1fdbbeaf5ab1e8fe454780146e7499be3db
parent 348941 fef429fba4c64c5b9c0c823a6ab713edbbcd4220
child 348989 afb47dfb71ed76d1bf86fe0101cda1a5e6038863
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester, me
bugs1289679
milestone50.0a1
first release with
nightly linux32
db3ed1fdbbea / 50.0a1 / 20160728030208 / files
nightly linux64
db3ed1fdbbea / 50.0a1 / 20160728030208 / files
nightly mac
db3ed1fdbbea / 50.0a1 / 20160728030208 / files
nightly win32
db3ed1fdbbea / 50.0a1 / 20160728030208 / files
nightly win64
db3ed1fdbbea / 50.0a1 / 20160728030208 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1289679 - Support detecting Windows SDK 10. r=chmanchester, a=me
build/moz.configure/windows.configure
--- a/build/moz.configure/windows.configure
+++ b/build/moz.configure/windows.configure
@@ -42,35 +42,65 @@ def windows_sdk_dir(value, host):
         return value
     if host.kernel != 'WINNT':
         return ()
 
     return tuple(x[1] for x in get_registry_values(
         r'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots'
         r'\KitsRoot*'))
 
+# The Windows SDK 8.1 and 10 have different layouts. The former has
+# $SDK/include/$subdir, while the latter has $SDK/include/$version/$subdir.
+# The vcvars* scripts don't actually care about the version, they just take
+# the last.
+@imports('os')
+@imports('re')
+@imports(_from='__builtin__', _import='sorted')
+@imports(_from='__builtin__', _import='WindowsError')
+def get_include_dir(sdk, subdir):
+    base = os.path.join(sdk, 'include')
+    try:
+        subdirs = [d for d in os.listdir(base)
+                   if os.path.isdir(os.path.join(base, d))]
+    except WindowsError:
+        subdirs = []
+    if not subdirs:
+        return None
+    if subdir in subdirs:
+        return os.path.join(base, subdir)
+    # At this point, either we have an incomplete or invalid SDK directory,
+    # or we exclusively have version numbers in subdirs.
+    versions = sorted((Version(d) for d in subdirs), reverse=True)
+    # Version('non-number').major is 0, so if the biggest version we have is
+    # 0, we have a problem.
+    if versions[0].major == 0:
+        return None
+    path = os.path.join(base, str(versions[0]), subdir)
+    return path if os.path.isdir(path) else None
+
+
 @imports(_from='mozbuild.shellutil', _import='quote')
 def valid_windows_sdk_dir_result(value):
     if value:
         return '0x%04x in %s' % (value.version, quote(value.path))
 
 @depends_win(c_compiler, windows_sdk_dir, valid_windows_version,
              'WINDOWSSDKDIR')
 @checking('for Windows SDK', valid_windows_sdk_dir_result)
 @imports(_from='__builtin__', _import='sorted')
 @imports(_from='textwrap', _import='dedent')
 def valid_windows_sdk_dir(compiler, windows_sdk_dir, target_version,
                           windows_sdk_dir_env):
     if windows_sdk_dir_env:
         windows_sdk_dir_env = windows_sdk_dir_env[0]
     sdks = {}
     for d in windows_sdk_dir:
-        um_dir = os.path.join(d, 'include', 'um')
-        shared_dir = os.path.join(d, 'include', 'shared')
-        if os.path.isdir(um_dir) and os.path.isdir(shared_dir):
+        um_dir = get_include_dir(d, 'um')
+        shared_dir = get_include_dir(d, 'shared')
+        if um_dir and shared_dir:
             check = dedent('''\
             #include <winsdkver.h>
             WINVER_MAXVER
             ''')
             result = try_preprocess(compiler.wrapper + [compiler.compiler] +
                                     compiler.flags +
                                     ['-I', um_dir, '-I', shared_dir], 'C',
                                     check)