-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathvsvars.sh
executable file
·232 lines (203 loc) · 9.17 KB
/
vsvars.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# vim: syntax=bash noexpandtab ts=8 sts=8:
# === UCSF ChimeraX Copyright ===
# Copyright 2016 Regents of the University of California.
# All rights reserved. This software provided pursuant to a
# license agreement containing restrictions on its disclosure,
# duplication and use. For details see:
# http://www.rbvi.ucsf.edu/chimerax/docs/licensing.html
# This notice must be embedded in or attached to all copies,
# including partial copies, of the software or any revisions
# or derivations thereof.
# === UCSF ChimeraX Copyright ===
# port of VSINSTALLDIR/Common7/Tools/vsvars32.bat to bash
# and merged with Visual Studio 2008's version and 64-bit version
if [ ! -z "$AUTOMATIC_DISCOVERY" ]; then
if [ -e "$(cygpath --absolute C:/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/Installer)" ]; then
export VSWHEREPATH="$(cygpath --absolute C:/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/Installer)"
if ! command -v vswhere &>/dev/null; then
export PATH="$PATH:$VSWHEREPATH"
fi
VCTBinDirCRLF="$(vswhere.exe -find "VC/Tools/MSVC/*/bin/Hostx64/x64" | tail -n 1)"
VCTRedistDirCRLF="$(vswhere.exe -find "VC/Redist/MSVC/*/x64" | tail -n 1)"
VCTLibDirCRLF="$(vswhere.exe -find "VC/Tools/MSVC/*/lib/x64" | tail -n 1)"
VCTATLMFCLibDirCRLF="$(vswhere.exe -find "VC/Tools/MSVC/*/atlmfc/lib/x64" | tail -n 1)"
VCTATLMFCIncDirCRLF="$(vswhere.exe -find "VC/Tools/MSVC/*/atlmfc/include" | tail -n 1)"
VCTIncludeDirCRLF="$(vswhere.exe -find "VC/Tools/MSVC/*/include" | tail -n 1)"
VCTRefDirCRLF="$(vswhere.exe -find "VC/Tools/MSVC/*/lib/x86/store/references" | tail -n 1)"
CRTPathCRLF="$(vswhere.exe -find "VC/Redist/MSVC/*/x64/Microsoft*CRT" | tail -n 1)"
WindowsSDKDirCRLF="$(regtool -W get '/HKLM/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/InstallationFolder')"
WindowsSDKVerCRLF="$(regtool -W get '/HKLM/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/ProductVersion')"
WindowsSDKVer="${WindowsSDKVerCRLF%$'\r'}.0"
export VCTInstallDir="$(cygpath --absolute "${VCTBinDirCRLF%$'\r'}")"
export VCTRedistDir="$(cygpath -u "${VCTRedistDirCRLF%$'\r'}")"
export VCTLibDir="$(cygpath -w "${VCTLibDirCRLF%$'\r'}")"
export VCTATLMFCLibDir="$(cygpath -w "${VCTATLMFCLibDirCRLF%$'\r'}")"
export VCTATLMFCIncDir="$(cygpath -w "${VCTATLMFCIncDirCRLF%$'\r'}")"
export VCTIncludeDir="$(cygpath -w "${VCTIncludeDirCRLF%$'\r'}")"
export VCTRefDir="$(cygpath -w "${VCTRefDirCRLF%$'\r'}")"
export WindowsSDKUmDir="$(cygpath -w "${WindowsSDKDirCRLF}Lib\\${WindowsSDKVer}\um\x64")"
export WindowsSDKUmIncDir="$(cygpath -w "${WindowsSDKDirCRLF}Include\\${WindowsSDKVer}\um")"
export WindowsSDKUCRTDir="$(cygpath -w "${WindowsSDKDirCRLF}Lib\\${WindowsSDKVer}\ucrt\x64")"
export WindowsSDKUCRTIncDir="$(cygpath -w "${WindowsSDKDirCRLF}Include\\${WindowsSDKVer}\ucrt")"
export WindowsSDKSharedIncDir="$(cygpath -w "${WindowsSDKDirCRLF}Include\\${WindowsSDKVer}\shared")"
export WindowsSDKWinRTIncDir="$(cygpath -w "${WindowsSDKDirCRLF}Include\\${WindowsSDKVer}\winrt")"
export WindowsSDKCPPWinRTIncDir="$(cygpath -w "${WindowsSDKDirCRLF}Include\\${WindowsSDKVer}\cppwinrt")"
export WindowsSDKLibRefDir="$(cygpath -w "${WindowsSDKDirCRLF}References\\${WindowsSDKVer}")"
export WindowsSDKLibUMDir="$(cygpath -w "${WindowsSDKDirCRLF}UnionMetadata${WindowsSDKVer}")"
export WindowsSDKBinDir="$(cygpath -u "${WindowsSDKDirCRLF}bin\\${WindowsSDKVer}\x64")"
export CRTPath="$(cygpath -u "${CRTPathCRLF%$'\r'}")"
export NEW_STYLE_VSVARS=1
export VSINSTALLDIR=1
export PATH="${VCTInstallDir}:${WindowsSDKBinDir}:$PATH"
export INCLUDE="${VCTIncludeDir};${VCTATLMFCIncDir};${WindowsSDKUmIncDir};${WindowsSDKUCRTIncDir};${WindowsSDKSharedIncDir};${WindowsSDKWinRTIncDir};${WindowsSDKCPPWinRTIncDir};$INCLUDE"
export LIB="${VCTLibDir};${VCTATLMFCLibDir};${WindowsSDKUCRTDir};${WindowsSDKUmDir};$LIB"
export LIBPATH="${VCTLibDir};${VCTATLMFCLibDir};${VCTRefDir};${WindowsSDKLibRefDir};${WindowsSDKLibUMDir};$LIBPATH"
VCToolsVersion=$(echo "${VCTIncludeDir}" | cut -d'\' -f 9)
echo "VC Tools Version: ${VCToolsVersion}"
echo "Windows SDK Version: ${WindowsSDKVer}"
return 0
else
echo "error: Could not find vswhere.exe to automatically set vsvars"
return 1
fi
else
B64=""
X64=""
if [ ! -z "$GITHUB_ACTIONS_CI" ]; then
echo Setting environment for using Microsoft Visual Studio 2019
Platform=x64
VSINSTALLDIR="c:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise"
WindowsSdkDir="c:\\Program Files (x86)\\Windows Kits\\10"
ExtensionSdkDir="$WindowsSdkDir\\Extension SDKs" # Double-check the space here on local machine
# The GitHub Actions runner has a space there
# also use 64 bit tools
B64=64
X64="\\x64"
# If the windows build is ever spuriously breaking, GitHub probably changed the version
# of the tools out from under us.
VCToolsVersion=14.41.34120 # could be 14.16.27023 or 14.29.30133 instead
VisualStudioVersion=17.0
# Could be 10.0.10240.0; 10.0.17763.0; 10.0.19041.0; 10.0.20348.0; 10.0.22000.0; 10.0.22621.0
WindowsSDKLibVersion=10.0.19041.0
WindowsSDKVersion=10.0.19041.0
VCINSTALLDIR="$VSINSTALLDIR\\VC"
VCToolsInstallDir="$VCINSTALLDIR\\Tools\\MSVC\\$VCToolsVersion"
VCToolsRedistDir="$VCINSTALLDIR\\Redist\MSVC\\$VCToolsVersion" # could be 14.16.27012, 14.29.30133, 14.32.31326, or v143
else
if [ -e "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2019" ]; then
echo Setting environment for using Microsoft Visual Studio 2019
Platform=x64
VSINSTALLDIR="c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community"
WindowsSdkDir="c:\\Program Files (x86)\\Windows Kits\\10"
ExtensionSdkDir="$WindowsSdkDir\\ExtensionSDKs"
# also use 64 bit tools
B64=64
X64="\\x64"
Framework40Version=v4.0
FrameworkVersion=v4.0.30319
FrameworkVersion64=v4.0.30319
VCToolsVersion=14.24.28314
VisualStudioVersion=16.0
WindowsSDKLibVersion=10.0.18362.0
WindowsSDKVersion=10.0.18362.0
VCINSTALLDIR="$VSINSTALLDIR\\VC"
VCToolsInstallDir="$VCINSTALLDIR\\Tools\\MSVC\\$VCToolsVersion"
VCToolsRedistDir="$VCINSTALLDIR\\Redist\MSVC\\14.24.28127"
elif [ -e "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017" ]; then
echo Setting environment for using Microsoft Visual Studio 2017
Platform=x64
VSINSTALLDIR="c:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community"
WindowsSdkDir="c:\\Program Files (x86)\\Windows Kits\\10"
ExtensionSdkDir="$WindowsSdkDir\\ExtensionSDKs"
# also use 64 bit tools
B64=64
X64="\\x64"
Framework40Version=v4.0
FrameworkVersion=v4.0.30319
FrameworkVersion64=v4.0.30319
VCToolsVersion=14.16.27023
VisualStudioVersion=15.0
WindowsSDKLibVersion=10.0.17763.0
WindowsSDKVersion=10.0.17763.0
VCINSTALLDIR="$VSINSTALLDIR\\VC"
VCToolsInstallDir="$VCINSTALLDIR\\Tools\\MSVC\\$VCToolsVersion"
VCToolsRedistDir="$VCINSTALLDIR\\Redist\MSVC\\14.16.27012"
else
echo "error: neither Microsoft Visual C++ 2019 nor 2017 compiler found"
return 1
fi
fi
export VSINSTALLDIR
export VCINSTALLDIR
export VCToolsInstallDir
export VCToolsRedistDir
export FrameworkDir="c:\\Windows\\Microsoft.NET\\Framework$B64"
export VisualStudioVersion
function GetMicrosoftSdkDir() {
GetMicrosoftSdkDirHelper HKLM >/dev/null 2>&1
if [ $? -ne 0 ]; then
GetMicrosoftSdkDirHelper HKCU >/dev/null 2>&1
if [ $? -ne 0 ]; then
# VS2003 location
export MicrosoftSdkDir="$VCINSTALLDIR\\PlatformSDK"
fi
fi
return 0
}
function GetMicrosoftSdkDirHelper() {
i=$(regtool get "/$1/SOFTWARE/Microsoft/Microsoft SDKs/Windows/CurrentInstallFolder")
if [ "$i" ]; then
export MicrosoftSdkDir="$i"
return 0
fi
return 1
}
GetMicrosoftSdkDir
# Don't care about .NET tools, libs or includes
#if [ "$MicrosoftSdkDir" ]
#then
# WSD=`cygpath -u "$MicrosoftSdkDir"`
# export PATH="$WSD/bin:$PATH"
# export INCLUDE="$MicrosoftSdkDir\\include;$INCLUDE"
# export LIB="$MicrosoftSdkDir\\lib$X64;$LIB"
# unset WSD
#fi
#
# Root of Visual Studio ide installed files.
#
export DevEnvDir="$VSINSTALLDIR\\Common7\\IDE"
DED=$(cygpath -u "$DevEnvDir")
VSD=$(cygpath -u "$VSINSTALLDIR")
VCD=$(cygpath -u "$VCINSTALLDIR")
VCT=$(cygpath -u "$VCToolsInstallDir")
FD=$(cygpath -u "$FrameworkDir")
WSD=$(cygpath -u "$WindowsSdkDir")
export PATH="$VCT/bin/HostX64/x64:\
$WSD/bin/x64:\
$VSD/Team Tools/Performance Tools/x64:\
$VSD/Team Tools/Performance Tools:\
$WSD/bin/$WindowsSDKVersion/x64:\
$WSD/bin/x64:\
$VSD/Common7/Tools:\
$PATH"
export INCLUDE="$VCToolsInstallDir\\include;\
$VCToolsInstallDir\\atlmfc\\include;\
$WindowsSdkDir\\include\\$WindowsSDKVersion\\ucrt;\
$WindowsSdkDir\\include\\$WindowsSDKVersion\\shared;\
$WindowsSdkDir\\include\\$WindowsSDKVersion\\um;\
$WindowsSdkDir\\include\\$WindowsSDKVersion\\winrt;\
$WindowsSdkDir\\include\\$WindowsSDKVersion\\cppwinrt;\
$INCLUDE"
export LIB="$VCToolsInstallDir\\lib\\$X64;\
$VCToolsInstallDir\\atlmfc\\lib\\$X64;\
$WindowsSdkDir\\lib\\$WindowsSDKLibVersion\\ucrt$X64;\
$WindowsSdkDir\\lib\\$WindowsSDKLibVersion\\um$X64;\
$LIB"
export LIBPATH="$VCToolsInstallDir\\lib\\$X64;\
$VCToolsInstallDir\\atlmfc\\lib\\$X64;\
$VCToolsInstallDir\\lib\\x86\\store\\references\\$X64;\
$WindowsSdkDir\\UnionMetadata\\$WindowsSDKVersion;\
$WindowsSdkDir\\References\\$WindowsSDKVersion;\
$LIBPATH"
unset DED VSD VCD FD WSD VCT
fi