From c6b7fab94b8625caf62a26b8d98dffacf7ea8111 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 27 Jul 2016 17:03:09 +0900 Subject: [PATCH] Bug 1290026 - Automatically set INCLUDE from configure. r=chmanchester --- build/moz.configure/windows.configure | 107 ++++++++++++++++++++++++++ config/config.mk | 6 ++ 2 files changed, 113 insertions(+) diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure index db0bca5e0b10..219629c86b6d 100644 --- a/build/moz.configure/windows.configure +++ b/build/moz.configure/windows.configure @@ -151,6 +151,113 @@ 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') +@checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result) +@imports(_from='__builtin__', _import='sorted') +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 = {} + for d in windows_sdk_dir: + ucrt_dir = get_include_dir(d, 'ucrt') + if ucrt_dir: + version = os.path.basename(os.path.dirname(ucrt_dir)) + # We're supposed to always find a version in the directory, because + # the 8.1 SDK, which doesn't have a version in the directory, doesn't + # contain the Universal CRT SDK. When the main SDK is 8.1, there + # is, however, supposed to be a reduced install of the SDK 10 + # with the UCRT. + if version != 'include': + sdks[d] = Version(version) + continue + if d == windows_sdk_dir_env: + raise FatalCheckError( + 'The SDK in WINDOWSSDKDIR (%s) does not contain the Universal ' + 'CRT.' % windows_sdk_dir_env) + + valid_sdks = sorted(sdks, key=lambda x: sdks[x], reverse=True) + if not valid_sdks: + raise FatalCheckError('Cannot find the Universal CRT SDK. ' + 'Please install it.') + + return namespace( + path=valid_sdks[0], + version=sdks[valid_sdks[0]], + ) + + +@depends_win(c_compiler) +@imports('os') +def vc_path(c_compiler): + if c_compiler.type != 'msvc': + return + # 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) + result = os.path.dirname(cl) + while True: + next, p = os.path.split(result) + if next == result: + die('Cannot determine the Visual C++ directory the compiler (%s) ' + 'is in' % cl) + result = next + if p.lower() == 'bin': + break + return result + + +@depends_win(vc_path) +@checking('for the Debug Interface Access SDK', lambda x: x or 'not found') +def dia_sdk_dir(vc_path): + if vc_path: + path = os.path.join(os.path.dirname(vc_path), 'DIA SDK') + if os.path.isdir(path): + return path + + +@depends_win(vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir) +@imports('os') +def include_path(vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir): + if not vc_path: + return + 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) + + winrt_dir = get_include_dir(windows_sdk_dir.path, 'winrt') + if not os.path.isdir(winrt_dir): + die('Cannot find the WinRT headers in the Windows SDK directory (%s). ' + 'Please install them.' % windows_sdk_dir.path) + + includes = [] + include_env = os.environ.get('INCLUDE') + if include_env: + includes.append(include_env) + includes.extend(( + os.path.join(vc_path, 'include'), + atlmfc_dir, + get_include_dir(windows_sdk_dir.path, 'shared'), + get_include_dir(windows_sdk_dir.path, 'um'), + winrt_dir, + get_include_dir(ucrt_sdk_dir.path, 'ucrt'), + )) + if dia_sdk_dir: + includes.append(os.path.join(dia_sdk_dir, 'include')) + # Set in the environment for old-configure + includes = os.pathsep.join(includes) + os.environ['INCLUDE'] = includes + return includes + +set_config('INCLUDE', include_path) + + option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool') @depends_win(valid_windows_sdk_dir) diff --git a/config/config.mk b/config/config.mk index 11681418e5d7..0ca05f076e4f 100644 --- a/config/config.mk +++ b/config/config.mk @@ -358,6 +358,12 @@ ifdef MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET endif # MACOSX_DEPLOYMENT_TARGET +# Export to propagate to cl and submake for third-party code. +# Eventually, we'll want to just use -I. +ifdef INCLUDE +export INCLUDE +endif + ifdef MOZ_USING_CCACHE ifdef CLANG_CXX export CCACHE_CPP2=1