Bug 1316957 - Include windows.configure conditionally instead of using @depends_win. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 12 Nov 2016 06:05:07 +0900
changeset 446067 d63d083ab7672423620d6d83366d3e1cbae86bad
parent 446066 8c1409a443ee41860f8caaf59a149ab83c467736
child 446068 faa9981549a6d24268e5259a2a20fc30ae5f0482
push id37692
push userdholbert@mozilla.com
push dateWed, 30 Nov 2016 22:11:55 +0000
Bug 1316957 - Include windows.configure conditionally instead of using @depends_win. r=chmanchester
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -962,10 +962,14 @@ def wrap_system_includes(target, visibil
            depends(visibility_flags)(lambda v: bool(v) or None))
            depends(visibility_flags)(lambda v: bool(v) or None))
 set_config('WRAP_SYSTEM_INCLUDES', wrap_system_includes)
 set_config('VISIBILITY_FLAGS', visibility_flags)
+def is_windows(target):
+    return target.kernel == 'WINNT'
+include('windows.configure', when=is_windows)
--- a/build/moz.configure/windows.configure
+++ b/build/moz.configure/windows.configure
@@ -3,27 +3,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 option('--with-windows-version', nargs=1, default='603',
        help='Windows SDK version to target. Win 8.1 (603) is currently'
             'the minimum supported version.')
-def is_windows(target):
-    return target.kernel == 'WINNT'
-def depends_win(*args):
-    return depends_when(*args, when=is_windows)
 @imports(_from='__builtin__', _import='ValueError')
 def valid_windows_version(value):
     if not value:
         die('Cannot build with --without-windows-version')
         version = int(value[0], 16)
         if version in (0x603,):
             return version
@@ -31,17 +21,17 @@ def valid_windows_version(value):
     die('Invalid value for --with-windows-version (%s)', value[0])
 option(env='WINDOWSSDKDIR', nargs=1,
        help='Directory containing the Windows SDK')
-@depends_win('WINDOWSSDKDIR', host)
+@depends('WINDOWSSDKDIR', host)
 def windows_sdk_dir(value, host):
     if value:
         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'
@@ -94,18 +84,17 @@ def get_sdk_dirs(sdk, subdir):
 @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')
+@depends(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,
     if windows_sdk_dir_env:
         windows_sdk_dir_env = windows_sdk_dir_env[0]
     sdks = {}
@@ -171,17 +160,17 @@ add_old_configure_assignment(
         lambda x: '0x%04X0000' % x.version if x else None))
 @imports(_from='mozbuild.shellutil', _import='quote')
 def valid_ucrt_sdk_dir_result(value):
     if value:
         return '%s in %s' % (value.version, quote(value.path))
-@depends_win(windows_sdk_dir, 'WINDOWSSDKDIR')
+@depends(windows_sdk_dir, 'WINDOWSSDKDIR')
 @checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result)
 @imports(_from='__builtin__', _import='sorted')
 @imports(_import='mozpack.path', _as='mozpath')
 def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env):
     if windows_sdk_dir_env:
         windows_sdk_dir_env = windows_sdk_dir_env[0]
     sdks = {}
@@ -237,17 +226,17 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, 
     return namespace(
 def vc_path(c_compiler):
     if c_compiler.type != 'msvc':
     # Normally, we'd start from c_compiler.compiler, but for now, it's not the
     # ideal full path to the compiler. At least, we're guaranteed find_program
     # will get us the one we found in toolchain.configure.
     cl = find_program(c_compiler.compiler)
@@ -258,27 +247,27 @@ def vc_path(c_compiler):
             die('Cannot determine the Visual C++ directory the compiler (%s) '
                 'is in' % cl)
         result = next
         if p.lower() == 'bin':
     return result
 @checking('for the Debug Interface Access SDK', lambda x: x or 'not found')
 @imports(_from='os.path', _import='isdir')
 def dia_sdk_dir(vc_path):
     if vc_path:
         path = os.path.join(os.path.dirname(vc_path), 'DIA SDK')
         if isdir(path):
             return path
-@depends_win(vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir)
+@depends(vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir)
 def include_path(vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir):
     if not vc_path:
     atlmfc_dir = os.path.join(vc_path, 'atlmfc', 'include')
     if not os.path.isdir(atlmfc_dir):
         die('Cannot find the ATL/MFC headers in the Visual C++ directory (%s). '
             'Please install them.' % vc_path)
@@ -305,17 +294,17 @@ def include_path(vc_path, windows_sdk_di
     # Set in the environment for old-configure
     includes = os.pathsep.join(includes)
     os.environ['INCLUDE'] = includes
     return includes
 set_config('INCLUDE', include_path)
-@depends_win(target, vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir)
+@depends(target, vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir)
 def lib_path(target, vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir):
     if not vc_path:
     vc_target = {
         'x86': '',
         'x86_64': 'amd64',
         'arm': 'arm',
@@ -359,17 +348,17 @@ def lib_path(target, vc_path, windows_sd
     os.environ['LIB'] = libs
     return libs
 set_config('LIB', lib_path)
 option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool')
 @imports(_from='os', _import='environ')
 def sdk_bin_path(valid_windows_sdk_dir):
     if not valid_windows_sdk_dir:
     vc_host = {
         'x86': 'x86',
@@ -381,23 +370,23 @@ def sdk_bin_path(valid_windows_sdk_dir):
         os.path.join(valid_windows_sdk_dir.path, 'bin', vc_host)
     if vc_host == 'x64':
             os.path.join(valid_windows_sdk_dir.path, 'bin', 'x86'))
     return result
-mt = check_prog('MT', depends_win()(lambda: ('mt.exe',)), input='MT',
+mt = check_prog('MT', ('mt.exe',), input='MT',
 # Check that MT is not something unexpected like "magnetic tape manipulation
 # utility".
 @checking('whether MT is really Microsoft Manifest Tool', lambda x: bool(x))
 def valid_mt(path):
         out = subprocess.check_output([path]).splitlines()
         out = '\n'.join(l for l in out
                         if 'Microsoft (R) Manifest Tool' in l)
         if out:
@@ -405,26 +394,25 @@ def valid_mt(path):
     except subprocess.CalledProcessError:
     raise FatalCheckError('%s is not Microsoft Manifest Tool')
 set_config('MSMANIFEST_TOOL', depends(valid_mt)(lambda x: bool(x)))
-link = check_prog('LINK', depends_win()(lambda: ('link.exe',)),
-                  paths=vc_compiler_path)
+link = check_prog('LINK', ('link.exe',), paths=vc_compiler_path)
-add_old_configure_assignment('LINK', depends_win(link)(lambda x: x))
+add_old_configure_assignment('LINK', link)
 # Normally, we'd just have CC, etc. set to absolute paths, but the build system
 # doesn't currently handle properly the case where the paths contain spaces.
 # Additionally, there's the issue described in toolchain.configure, in
 # valid_compiler().
 def alter_path(sdk_bin_path):
     path = os.pathsep.join(sdk_bin_path)
     os.environ['PATH'] = path
     return path
 set_config('PATH', alter_path)