aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/cpp/wrapper/bin
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-07-12 10:55:57 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-07-13 11:15:16 +0000
commit56b16e75ab84007772db78c694729696c4f7cf05 (patch)
tree8d6dd38473d271bfed76bdb3a7d6f4d6cf4ac5a0 /tools/cpp/wrapper/bin
parentfeb1321044e3b7be34f9c1d7dacf9881d99a7327 (diff)
Autoconfigure MSVC CROSSTOOL
-- Change-Id: I55b2c567a3fc6be15f29d03c5c6e9891ef540072 Reviewed-on: https://bazel-review.googlesource.com/#/c/4012 MOS_MIGRATED_REVID=127184463
Diffstat (limited to 'tools/cpp/wrapper/bin')
-rw-r--r--tools/cpp/wrapper/bin/call_python.bat.tpl (renamed from tools/cpp/wrapper/bin/call_python.bat)3
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl (renamed from tools/cpp/wrapper/bin/pydir/msvc_tools.py)105
2 files changed, 10 insertions, 98 deletions
diff --git a/tools/cpp/wrapper/bin/call_python.bat b/tools/cpp/wrapper/bin/call_python.bat.tpl
index 93ab0fea3f..0307f08af0 100644
--- a/tools/cpp/wrapper/bin/call_python.bat
+++ b/tools/cpp/wrapper/bin/call_python.bat.tpl
@@ -21,6 +21,5 @@ for /F %%i in ("%arg0%") do set TOOLNAME=%%~ni
set PYDIR="%DRIVER_BIN%pydir"
-::TODO(pcloudy): Remove hard code path, user should be able to configure
-if not defined MSVCPYTHON set MSVCPYTHON=C:\python_27_amd64\files\python.exe
+if not defined MSVCPYTHON set MSVCPYTHON=%{python_binary}
%MSVCPYTHON% -B "%PYDIR%\%TOOLNAME%.py" %*
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
index f84efc33de..517aaf7ff3 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
@@ -26,14 +26,11 @@ MAX_DRIVE_LENGTH = 3 # The maximum length of a drive.
ASSEMBLY_AS_C_SOURCE = '/Tc'
LIB_SUFFIX = '.lib'
-VC_PATH = 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0'
-VC_VERSION = '140'
-PLATFORM_SDK_PATH = 'C:\\Program Files (x86)\\Windows Kits'
-PLATFORM_SDK_VERSION = '10.0.10240.0'
-TMP_PATH = 'C:\\Windows\\Temp'
-PYTHON_PATH = 'C:\\python_27_amd64\\files'
-GNU_PATH = 'C:\\Program Files (x86)\\GnuWin32'
+TMP_PATH = '%{tmp}'
+PATH = "%{path}"
+INCLUDE = "%{include}"
+LIB = "%{lib}"
class Error(Exception):
"""Base class for all script-specific errors."""
@@ -280,100 +277,17 @@ class WindowsRunner(object):
raise Error('path is too long: ' + long_path)
return None
- def SetupEnvironment(self, build_arch):
+ def SetupEnvironment(self):
"""Setup proper path for running.
- Args:
- build_arch: Either 'x64' or 'x86', which binary architecture to build for.
-
Returns:
An environment suitable for running on Windows.
"""
- common_paths = [
- 'C:\\Windows',
- 'C:\\Windows\\system32',
- 'C:\\Windows\\System32\\Wbem',
- os.path.join(VC_PATH, 'Common7\\IDE'),
- os.path.join(VC_PATH,
- 'Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow'),
- os.path.join(VC_PATH, 'Common7\\Tools'),
- os.path.join(VC_PATH, 'VC\\VCPackages'),
- ]
-
- x86_paths = [
- os.path.join(VC_PATH, 'VC\\bin'),
- os.path.join(VC_PATH, 'VC\\redist\\x86\\Microsoft.VC' + VC_VERSION +
- '.CRT'),
- os.path.join(PLATFORM_SDK_PATH, 'bin\\x86'),
- ] + common_paths
-
- x64_paths = [
- os.path.join(VC_PATH, 'VC\\bin\\x86_amd64'),
- os.path.join(VC_PATH, 'VC\\bin'),
- os.path.join(VC_PATH, 'VC\\redist\\x64\\Microsoft.VC' + VC_VERSION +
- '.CRT'),
- os.path.join(VC_PATH, 'VC\\redist\\x86\\Microsoft.VC' + VC_VERSION +
- '.CRT'),
- os.path.join(PLATFORM_SDK_PATH, 'bin\\x64'),
- ] + common_paths
-
- path = x86_paths if build_arch == 'x86' else x64_paths
-
- include = [
- os.path.join(GNU_PATH, 'include'),
- os.path.join(PYTHON_PATH, 'include'),
- os.path.join(VC_PATH, 'VC\\INCLUDE'),
- os.path.join(VC_PATH, 'VC\\ATLMFC\\INCLUDE'),
- os.path.join(PLATFORM_SDK_PATH, '10\\include', PLATFORM_SDK_VERSION,
- 'ucrt'),
- os.path.join(PLATFORM_SDK_PATH, '8.1\\include'),
- os.path.join(PLATFORM_SDK_PATH, '8.1\\include\\um'),
- os.path.join(PLATFORM_SDK_PATH, '8.1\\include\\shared'),
- os.path.join(PLATFORM_SDK_PATH, '8.1\\include\\winrt'),
- os.path.join(PLATFORM_SDK_PATH, 'NETFXSDK\\4.6.1\\include\\um'),
- ]
-
- common_lib_paths = [
- os.path.join(GNU_PATH, 'bin'),
- os.path.join(GNU_PATH, 'lib'),
- os.path.join(PYTHON_PATH, 'libs'),
- ]
-
- x86_lib_path = [
- os.path.join(VC_PATH, 'VC\\bin'),
- os.path.join(VC_PATH, 'VC\\LIB'),
- os.path.join(VC_PATH, 'VC\\ATLMFC\\LIB'),
- os.path.join(VC_PATH, 'VC\\redist\\x86\\Microsoft.VC' + VC_VERSION +
- '.CRT'),
- os.path.join(PLATFORM_SDK_PATH, '10\\lib', PLATFORM_SDK_VERSION,
- 'ucrt\\x86'),
- os.path.join(PLATFORM_SDK_PATH, '8.1\\lib\\winv6.3\\um\\x86'),
- os.path.join(PLATFORM_SDK_PATH, 'NETFXSDK\\4.6.1\\lib\\um\\x86'),
- os.path.join(GNU_PATH, 'bin\\x86'),
- os.path.join(GNU_PATH, 'lib\\x86'),
- ] + common_lib_paths
-
- x64_lib_path = [
- os.path.join(VC_PATH, 'VC\\bin\\x86_amd64'),
- os.path.join(VC_PATH, 'VC\\LIB\\amd64'),
- os.path.join(VC_PATH, 'VC\\ATLMFC\\LIB\\amd64'),
- os.path.join(VC_PATH, 'VC\\redist\\x64\\Microsoft.VC' + VC_VERSION +
- '.CRT'),
- os.path.join(PLATFORM_SDK_PATH, '10\\lib', PLATFORM_SDK_VERSION,
- 'ucrt\\x64'),
- os.path.join(PLATFORM_SDK_PATH, '8.1\\lib\\winv6.3\\um\\x64'),
- os.path.join(PLATFORM_SDK_PATH, 'NETFXSDK\\4.6.1\\lib\\um\\x64'),
- os.path.join(GNU_PATH, 'bin\\x64'),
- os.path.join(GNU_PATH, 'lib\\x64'),
- ] + common_lib_paths
-
- lib = x86_lib_path if build_arch == 'x86' else x64_lib_path
-
build_env = os.environ.copy()
- build_env['PATH'] = ';'.join([build_env['PATH']] + path)
- build_env['INCLUDE'] = ';'.join(include)
- build_env['LIB'] = ';'.join(lib)
+ build_env['PATH'] = PATH
+ build_env['INCLUDE'] = INCLUDE
+ build_env['LIB'] = LIB
build_env['TEMP'] = TMP_PATH
build_env['TMP'] = TMP_PATH
return build_env
@@ -418,8 +332,7 @@ class WindowsRunner(object):
args = [arg for arg in args if arg not in ['/W2', '/W3', '/W4']]
# Setup the Windows paths and the build environment.
- # TODO(pcloudy): make these paths configurable
- build_env = self.SetupEnvironment(build_arch)
+ build_env = self.SetupEnvironment()
# Construct a large regular expression for all filters.
output_filter = re.compile('(' + ')|('.join(filters) + ')')