| Index: build/toolchain/win/setup_toolchain.py
|
| diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py
|
| index bba18dfc57e39401480a8175b9309470444ffb95..162c2e16cef6cbd5609ad9b02c39229b5c83ecd7 100644
|
| --- a/build/toolchain/win/setup_toolchain.py
|
| +++ b/build/toolchain/win/setup_toolchain.py
|
| @@ -35,6 +35,49 @@ def ExtractImportantEnvironment():
|
| 'required to be set to valid path' % required)
|
| return result
|
|
|
| +
|
| +# VC setup will add a path like this in 32-bit mode:
|
| +# c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN
|
| +# And this in 64-bit mode:
|
| +# c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64
|
| +# Note that in 64-bit it's duplicated but the 64-bit one comes first.
|
| +#
|
| +# What we get as the path when running this will depend on which VS setup
|
| +# script you've run. The following two functions try to do this.
|
| +
|
| +# For 32-bit compiles remove anything that ends in "\VC\WIN\amd64".
|
| +def FixupPath32(path):
|
| + find_64 = re.compile("VC\\\\BIN\\\\amd64\\\\*$", flags=re.IGNORECASE)
|
| +
|
| + for i in range(len(path)):
|
| + if find_64.search(path[i]):
|
| + # Found 32-bit path, insert the 64-bit one immediately before it.
|
| + dir_64 = path[i].rstrip("\\")
|
| + dir_64 = dir_64[:len(dir_64) - 6] # Trim off "\amd64".
|
| + path[i] = dir_64
|
| + break
|
| + return path
|
| +
|
| +# For 64-bit compiles, append anything ending in "\VC\BIN" with "\amd64" as
|
| +# long as that thing isn't already in the list, and append it immediately
|
| +# before the non-amd64-one.
|
| +def FixupPath64(path):
|
| + find_32 = re.compile("VC\\\\BIN\\\\*$", flags=re.IGNORECASE)
|
| +
|
| + for i in range(len(path)):
|
| + if find_32.search(path[i]):
|
| + # Found 32-bit path, insert the 64-bit one immediately before it.
|
| + dir_32 = path[i]
|
| + if dir_32[len(dir_32) - 1] == '\\':
|
| + dir_64 = dir_32 + "amd64"
|
| + else:
|
| + dir_64 = dir_32 + "\\amd64"
|
| + path.insert(i, dir_64)
|
| + break
|
| +
|
| + return path
|
| +
|
| +
|
| def FormatAsEnvironmentBlock(envvar_dict):
|
| """Format as an 'environment block' directly suitable for CreateProcess.
|
| Briefly this is a list of key=value\0, terminated by an additional \0. See
|
| @@ -59,14 +102,22 @@ def CopyTool(source_path):
|
| '# Generated by setup_toolchain.py do not edit.\n']
|
| + tool_source[1:]))
|
|
|
| +
|
| # Find the tool source, it's the first argument, and copy it.
|
| if len(sys.argv) != 2:
|
| print "Need one argument (win_tool source path)."
|
| sys.exit(1)
|
| CopyTool(sys.argv[1])
|
|
|
| -# Write the environment file to the current directory.
|
| -environ = FormatAsEnvironmentBlock(ExtractImportantEnvironment())
|
| +important_env_vars = ExtractImportantEnvironment()
|
| +path = important_env_vars["PATH"].split(";")
|
| +
|
| +important_env_vars["PATH"] = ";".join(FixupPath32(path))
|
| +environ = FormatAsEnvironmentBlock(important_env_vars)
|
| with open('environment.x86', 'wb') as env_file:
|
| env_file.write(environ)
|
|
|
| +important_env_vars["PATH"] = ";".join(FixupPath64(path))
|
| +environ = FormatAsEnvironmentBlock(important_env_vars)
|
| +with open('environment.x64', 'wb') as env_file:
|
| + env_file.write(environ)
|
|
|