Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1742)

Unified Diff: win_toolchain/package_from_installed.py

Issue 1708223002: Make GenerateSetEnvCmd() more table driven. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: wot Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: win_toolchain/package_from_installed.py
diff --git a/win_toolchain/package_from_installed.py b/win_toolchain/package_from_installed.py
index e1bea2afc5183fcd9b4654cebe8983d675b13518..e2785d722003ee44c3bc68f793fbc1bc72a441fe 100644
--- a/win_toolchain/package_from_installed.py
+++ b/win_toolchain/package_from_installed.py
@@ -201,45 +201,71 @@ def GenerateSetEnvCmd(target_dir):
This is normally generated by a full install of the SDK, but we
do it here manually since we do not do a full install."""
- with open(os.path.join(
- target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f:
+ # All these paths are relative to the directory containing SetEnv.cmd.
+ include_dirs = [
+ ['..', '..', 'win_sdk', 'Include', WIN_VERSION, 'um'],
+ ['..', '..', 'win_sdk', 'Include', WIN_VERSION, 'shared'],
+ ['..', '..', 'win_sdk', 'Include', WIN_VERSION, 'winrt'],
+ ]
+ if VS_VERSION == '2015':
+ include_dirs.append(['..', '..', 'win_sdk', 'Include', WIN_VERSION, 'ucrt'])
+ include_dirs.extend([
+ ['..', '..', 'VC', 'include'],
+ ['..', '..', 'VC', 'atlmfc', 'include'],
+ ])
+ # Common to x86 and x64
+ env = [
+ # Yuck: These two have a trailing \ character. No good way to represent this
+ # in an OS-independent way.
+ ('VSINSTALLDIR', [['..', '..\\']]),
+ ('VCINSTALLDIR', [['..', '..', 'VC\\']]),
+ ('INCLUDE', include_dirs),
+ ]
+ # x86. Always use amd64_x86 cross, not x86 on x86.
+ env_x86 = [
+ ('PATH', [
+ ['..', '..', 'win_sdk', 'bin', 'x86'],
+ ['..', '..', 'VC', 'bin', 'amd64_x86'],
+ ['..', '..', 'VC', 'bin', 'amd64'], # Needed for mspdb1x0.dll.
+ ]),
+ ('LIB', [
+ ['..', '..', 'VC', 'lib'],
+ ['..', '..', 'win_sdk', 'Lib', WIN_VERSION, 'um', 'x86'],
+ ['..', '..', 'win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'x86'], # VS 2015
+ ['..', '..', 'VC', 'atlmfc', 'lib'],
+ ]),
+ ]
+ # x64.
+ env_x64 = [
+ ('PATH', [
+ ['..', '..', 'win_sdk', 'bin', 'x64'],
+ ['..', '..', 'VC', 'bin', 'amd64'],
+ ]),
+ ('LIB', [
+ ['..', '..', 'VC', 'lib', 'amd64'],
+ ['..', '..', 'win_sdk', 'Lib', WIN_VERSION, 'um', 'x64'],
+ ['..', '..', 'win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'x64'], # VS 2015
+ ['..', '..', 'VC', 'atlmfc', 'lib', 'amd64'],
+ ]),
+ ]
+ def BatDirs(dirs):
+ return ';'.join(['%~dp0' + os.path.join(*d) for d in dirs])
+ with open(os.path.join(target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f:
f.write('@echo off\n'
- ':: Generated by win_toolchain\\package_from_installed.py.\n'
- # Common to x86 and x64
- 'set VSINSTALLDIR=%~dp0..\\..\\\n'
- 'set VCINSTALLDIR=%~dp0..\\..\\VC\\\n'
- 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\um;'
- '%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\shared;'
- '%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\winrt;'.replace(
- 'WINVERSION', WIN_VERSION))
- if VS_VERSION == '2015':
- f.write('%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\ucrt;'.replace(
- 'WINVERSION', WIN_VERSION))
- f.write('%~dp0..\\..\\VC\\include;'
- '%~dp0..\\..\\VC\\atlmfc\\include\n'
- 'if "%1"=="/x64" goto x64\n')
-
- # x86. Always use amd64_x86 cross, not x86 on x86.
- f.write('set PATH=%~dp0..\\..\\win_sdk\\bin\\x86;'
- '%~dp0..\\..\\VC\\bin\\amd64_x86;'
- '%~dp0..\\..\\VC\\bin\\amd64;' # Needed for mspdb1x0.dll.
- '%PATH%\n')
- f.write('set LIB=%~dp0..\\..\\VC\\lib;'
- '%~dp0..\\..\\win_sdk\\Lib\\WINVERSION\\um\\x86;'
- '%~dp0..\\..\\win_sdk\\Lib\\WINVERSION\\ucrt\\x86;' # VS 2015
- '%~dp0..\\..\\VC\\atlmfc\\lib\n'
- 'goto :EOF\n'.replace('WINVERSION', WIN_VERSION))
-
- # x64.
- f.write(':x64\n'
- 'set PATH=%~dp0..\\..\\win_sdk\\bin\\x64;'
- '%~dp0..\\..\\VC\\bin\\amd64;'
- '%PATH%\n')
- f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;'
- '%~dp0..\\..\\win_sdk\\Lib\\WINVERSION\\um\\x64;'
- '%~dp0..\\..\\win_sdk\\Lib\\WINVERSION\\ucrt\\x64;' # VS 2015
- '%~dp0..\\..\\VC\\atlmfc\\lib\\amd64\n'
- .replace('WINVERSION', WIN_VERSION))
+ ':: Generated by win_toolchain\\package_from_installed.py.\n')
+ for var, dirs in env:
+ f.write('set %s=%s\n' % (var, BatDirs(dirs)))
+ f.write('if "%1"=="/x64" goto x64\n')
+
+ for var, dirs in env_x86:
+ f.write('set %s=%s%s\n' % (
+ var, BatDirs(dirs), ';%PATH%' if var == 'PATH' else ''))
+ f.write('goto :EOF\n')
+
+ f.write(':x64\n')
+ for var, dirs in env_x64:
+ f.write('set %s=%s%s\n' % (
+ var, BatDirs(dirs), ';%PATH%' if var == 'PATH' else ''))
def AddEnvSetup(files):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698