diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cpp/CROSSTOOL.tpl | 44 | ||||
-rw-r--r-- | tools/cpp/cc_configure.bzl | 12 | ||||
-rw-r--r-- | tools/cpp/wrapper/bin/msvc_cl.bat | 2 | ||||
-rw-r--r-- | tools/cpp/wrapper/bin/msvc_link.bat | 2 | ||||
-rw-r--r-- | tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl | 26 |
5 files changed, 55 insertions, 31 deletions
diff --git a/tools/cpp/CROSSTOOL.tpl b/tools/cpp/CROSSTOOL.tpl index a2bf86b7a1..60fb955e95 100644 --- a/tools/cpp/CROSSTOOL.tpl +++ b/tools/cpp/CROSSTOOL.tpl @@ -222,6 +222,41 @@ toolchain { linker_flag: "-m64" feature { + name: "msvc_env" + env_set { + action: "c-compile" + action: "c++-compile" + action: "c++-module-compile" + action: "c++-header-parsing" + action: "c++-header-preprocessing" + action: "assemble" + action: "preprocess-assemble" + action: "c++-link-executable" + action: "c++-link-dynamic-library" + action: "c++-link-static-library" + action: "c++-link-alwayslink-static-library" + action: "c++-link-pic-static-library" + action: "c++-link-alwayslink-pic-static-library" + env_entry { + key: "PATH" + value: "%{msvc_env_path}" + } + env_entry { + key: "INCLUDE" + value: "%{msvc_env_include}" + } + env_entry { + key: "LIB" + value: "%{msvc_env_lib}" + } + env_entry { + key: "TMP" + value: "%{msvc_env_tmp}" + } + } + } + + feature { name: 'include_paths' flag_set { action: 'preprocess-assemble' @@ -301,6 +336,7 @@ toolchain { flag: '/Fi%{output_preprocess_file}' } } + implies: 'msvc_env' } action_config { @@ -334,6 +370,7 @@ toolchain { flag: '/Fi%{output_preprocess_file}' } } + implies: 'msvc_env' } action_config { @@ -348,6 +385,7 @@ toolchain { implies: 'input_param_flags' implies: 'legacy_link_flags' implies: 'linker_param_file' + implies: 'msvc_env' } action_config { @@ -364,6 +402,7 @@ toolchain { implies: 'has_configured_linker_path' implies: 'legacy_link_flags' implies: 'linker_param_file' + implies: 'msvc_env' } action_config { @@ -374,6 +413,7 @@ toolchain { } implies: 'input_param_flags' implies: 'linker_param_file' + implies: 'msvc_env' } action_config { @@ -384,6 +424,7 @@ toolchain { } implies: 'input_param_flags' implies: 'linker_param_file' + implies: 'msvc_env' } # TODO(pcloudy): The following action_config is listed in MANDATORY_LINK_TARGET_TYPES. @@ -396,6 +437,7 @@ toolchain { } implies: 'input_param_flags' implies: 'linker_param_file' + implies: 'msvc_env' } action_config { @@ -406,6 +448,7 @@ toolchain { } implies: 'input_param_flags' implies: 'linker_param_file' + implies: 'msvc_env' } action_config { @@ -416,6 +459,7 @@ toolchain { } implies: 'strip_debug_symbols' implies: 'linker_param_file' + implies: 'msvc_env' } feature { diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index a1eca746d2..66c4b19150 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -695,10 +695,6 @@ def _impl(repository_ctx): paths = (cuda_path.replace("\\", "\\\\") + "/bin;") + paths compute_capabilities = _cuda_compute_capabilities(repository_ctx) _tpl(repository_ctx, "wrapper/bin/pydir/msvc_tools.py", { - "%{tmp}": tmp_dir, - "%{path}": paths, - "%{include}": include_paths, - "%{lib}": lib_paths, "%{lib_tool}": lib_tool, "%{support_whole_archive}": support_whole_archive, "%{cuda_compute_capabilities}": ", ".join( @@ -714,6 +710,10 @@ def _impl(repository_ctx): "%{cpu}": cpu_value, "%{default_toolchain_name}": "msvc_x64", "%{toolchain_name}": "msys_x64", + "%{msvc_env_tmp}": tmp_dir, + "%{msvc_env_path}": paths, + "%{msvc_env_include}": include_paths, + "%{msvc_env_lib}": lib_paths, "%{content}": _get_windows_msys_crosstool_content(repository_ctx), "%{opt_content}": "", "%{dbg_content}": "", @@ -748,6 +748,10 @@ def _impl(repository_ctx): "%{dbg_content}": _build_crosstool(dbg_content, " "), "%{cxx_builtin_include_directory}": "", "%{coverage}": _coverage_feature(darwin), + "%{msvc_env_tmp}": "", + "%{msvc_env_path}": "", + "%{msvc_env_include}": "", + "%{msvc_env_lib}": "", }) diff --git a/tools/cpp/wrapper/bin/msvc_cl.bat b/tools/cpp/wrapper/bin/msvc_cl.bat index 50d116d5c1..f32dd44871 100644 --- a/tools/cpp/wrapper/bin/msvc_cl.bat +++ b/tools/cpp/wrapper/bin/msvc_cl.bat @@ -14,4 +14,4 @@ :: Invoke the python script under pydir with the same basename @echo OFF -call_python.bat %0 %* +external\local_config_cc\wrapper\bin\call_python.bat %0 %* diff --git a/tools/cpp/wrapper/bin/msvc_link.bat b/tools/cpp/wrapper/bin/msvc_link.bat index 50d116d5c1..f32dd44871 100644 --- a/tools/cpp/wrapper/bin/msvc_link.bat +++ b/tools/cpp/wrapper/bin/msvc_link.bat @@ -14,4 +14,4 @@ :: Invoke the python script under pydir with the same basename @echo OFF -call_python.bat %0 %* +external\local_config_cc\wrapper\bin\call_python.bat %0 %* diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl index ad51028b23..0695593d5f 100644 --- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl +++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl @@ -27,12 +27,6 @@ MAX_DRIVE_LENGTH = 3 # The maximum length of a drive. MAX_PATH_ADJUSTED = MAX_PATH - MAX_OPTION_LENGTH - MAX_DRIVE_LENGTH ASSEMBLY_AS_C_SOURCE = '/Tc' LIB_SUFFIX = '.lib' - -TMP_PATH = '%{tmp}' - -PATH = "%{path}" -INCLUDE = "%{include}" -LIB = "%{lib}" LIB_TOOL = "%{lib_tool}" supported_cuda_compute_capabilities = [ %{cuda_compute_capabilities} ] @@ -449,21 +443,6 @@ class WindowsRunner(object): % (str(abspath), MAX_PATH_ADJUSTED, len(abspath))) return abspath - def SetupEnvironment(self): - """Setup proper path for running. - - Returns: - An environment suitable for running on Windows. - """ - - build_env = os.environ.copy() - 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 - def RunBinary(self, binary, args, build_arch, parser): """Runs binary on Windows with the passed args. @@ -495,9 +474,6 @@ class WindowsRunner(object): name = arg.rpartition(ntpath.sep)[2] filters.append(name) - # Setup the Windows paths and the build environment. - build_env = self.SetupEnvironment() - # Construct a large regular expression for all filters. output_filter = re.compile('(' + ')|('.join(filters) + ')') includes_filter = re.compile(r'Note: including file:\s+(.*)') @@ -520,7 +496,7 @@ class WindowsRunner(object): # Unconmment the following line to see what exact command is executed. # print("Running: " + " ".join(cmd)) proc = subprocess.Popen(cmd, - env=build_env, + env=os.environ.copy(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) |