1diff --git build/toolchain/win/setup_toolchain.py build/toolchain/win/setup_toolchain.py 2index ec9e9eeda7cb7..b58e1900de059 100644 3--- build/toolchain/win/setup_toolchain.py 4+++ build/toolchain/win/setup_toolchain.py 5@@ -157,13 +157,17 @@ def _LoadToolchainEnv(cpu, toolchain_root, sdk_dir, target_store): 6 del os.environ['LIB'] 7 if 'LIBPATH' in os.environ: 8 del os.environ['LIBPATH'] 9- other_path = os.path.normpath(os.path.join( 10+ script_path = os.path.normpath(os.path.join( 11 os.environ['GYP_MSVS_OVERRIDE_PATH'], 12 'VC/Auxiliary/Build/vcvarsall.bat')) 13- if not os.path.exists(other_path): 14- raise Exception('%s is missing - make sure VC++ tools are installed.' % 15- script_path) 16- script_path = other_path 17+ if not os.path.exists(script_path): 18+ # Compiler environment variables must already be specified. 19+ variables = [] 20+ for k in sorted(os.environ.keys()): 21+ variables.append('%s=%s' % (str(k), str(os.environ[k]))) 22+ variables = '\n'.join(variables) 23+ return _ExtractImportantEnvironment(variables) 24+ 25 cpu_arg = "amd64" 26 if (cpu != 'x64'): 27 # x64 is default target CPU thus any other CPU requires a target set 28diff --git build/vs_toolchain.py build/vs_toolchain.py 29index e759bd6ca2afe..c146bfea59fc8 100755 30--- build/vs_toolchain.py 31+++ build/vs_toolchain.py 32@@ -107,9 +107,16 @@ def SetEnvironmentAndGetRuntimeDllDirs(): 33 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs) 34 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH'] 35 elif sys.platform == 'win32' and not depot_tools_win_toolchain: 36+ has_override_path = True 37 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ: 38+ has_override_path = False 39 os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath() 40 41+ if has_override_path: 42+ # Don't attempt to copy DLLs when using a custom toolchain. 43+ # The DLLs should already be discoverable via the PATH env variable. 44+ return None 45+ 46 # When using an installed toolchain these files aren't needed in the output 47 # directory in order to run binaries locally, but they are needed in order 48 # to create isolates or the mini_installer. Copying them to the output 49@@ -158,6 +165,10 @@ def _RegistryGetValue(key, value): 50 def GetVisualStudioVersion(): 51 """Return best available version of Visual Studio. 52 """ 53+ # Return the explicitly requested version, if any. 54+ if 'GYP_MSVS_VERSION' in os.environ: 55+ return os.environ['GYP_MSVS_VERSION'] 56+ 57 supported_versions = list(MSVS_VERSIONS.keys()) 58 59 # VS installed in depot_tools for Googlers 60