Skip to content

Commit 7482a76

Browse files
committed
update to current upstream (44dc13b)
1 parent 06e3ae0 commit 7482a76

File tree

4 files changed

+406
-132
lines changed

4 files changed

+406
-132
lines changed

msvc/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The following instructions are for setting up MSVC without docker.
4848

4949
```bash
5050
apt-get update
51-
apt-get install -y wine64-development python3 msitools python3-simplejson python3-six ca-certificates winbind
51+
apt-get install -y wine64 python3 msitools ca-certificates winbind
5252
```
5353

5454
## Installation
@@ -89,7 +89,7 @@ as usual. You need less prerequisites as wine won't be needed:
8989

9090
```bash
9191
apt-get update
92-
apt-get install -y python3 msitools python3-simplejson python3-six ca-certificates
92+
apt-get install -y python3 msitools ca-certificates
9393

9494
# Download and unpack MSVC
9595
./vsdownload.py --dest ~/my_msvc
@@ -183,6 +183,26 @@ Other generators are untested and may or may not work. Use it at your own peril.
183183

184184
No. Using Ninja or GNU Make directly should work.
185185

186+
## How to integrate with vcpkg?
187+
188+
You need define your own triplets, e.g. `my-triplets/x64-windows.cmake`:
189+
```cmake
190+
set(VCPKG_TARGET_ARCHITECTURE x64)
191+
set(VCPKG_CRT_LINKAGE dynamic)
192+
set(VCPKG_LIBRARY_LINKAGE dynamic)
193+
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/scripts/toolchains/windows.cmake)
194+
195+
set(ENV{CC} cl.exe)
196+
set(ENV{CXX} cl.exe)
197+
set(ENV{PATH} "/opt/msvc/bin/x64:$ENV{PATH}")
198+
```
199+
200+
Then you can install packages using overlay triplets:
201+
```bash
202+
vcpkg install sqlite3:x64-windows --overlay-triplets=my-triplets
203+
```
204+
See examples [here](test/test-vcpkg.sh).
205+
186206
## I get `ninja: error: build.ninja:225: bad $-escape (literal $ must be written as $$)`
187207

188208
Visual Studio can switch between Debug/Release/RelWithDebInfo/etc at build time in the IDE.

msvc/fixinclude

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ sub dodir($) {
4444
while(my $line = <FHIN>) {
4545
# Make sure to match '#include <foo>' or '#include "bar"', but not
4646
# '#include IDENTIFIER'.
47-
if($line =~ m/^#\s*include\s+["<][\w\.\/\\]+[">]/) {
47+
if($line =~ m/^\s*#\s*include\s+["<][\w\.\/\\]+[">]/) {
4848
my @values = split('//', $line);
4949
$values[0] =~ tr [A-Z\\] [a-z/];
5050

msvc/install.sh

Lines changed: 78 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
set -e
1818

1919
if [ $# -lt 1 ]; then
20-
echo $0 {vc.zip sdk.zip target\|target}
20+
echo "$0 {vc.zip sdk.zip target|target}"
2121
exit 0
2222
fi
2323

2424
if [ $# -eq 3 ]; then
25-
VC_ZIP=$(cd $(dirname $1) && pwd)/$(basename $1)
26-
SDK_ZIP=$(cd $(dirname $2) && pwd)/$(basename $2)
25+
VC_ZIP=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
26+
SDK_ZIP=$(cd "$(dirname "$2")" && pwd)/$(basename "$2")
2727
DEST=$3
2828
else
2929
DEST=$1
3030
fi
31-
ORIG=$(cd $(dirname $0) && pwd)
31+
ORIG=$(cd "$(dirname "$0")" && pwd)
3232

33-
mkdir -p $DEST
34-
cd $DEST
33+
mkdir -p "$DEST"
34+
cd "$DEST"
3535
DEST=$(pwd)
3636

3737
ln_s() {
@@ -41,9 +41,9 @@ ln_s() {
4141
}
4242

4343
if [ -n "$VC_ZIP" ]; then
44-
unzip $VC_ZIP
44+
unzip "$VC_ZIP"
4545
fi
46-
ln_s kits "Windows Kits"
46+
ln_s "Windows Kits" kits
4747
ln_s VC vc
4848
ln_s Tools vc/tools
4949
ln_s MSVC vc/tools/msvc
@@ -71,15 +71,24 @@ cd ..
7171
# Thus process them to reference the other headers with lowercase names.
7272
# Also lowercase these files, as a few of them do have non-lowercase names,
7373
# and the call to fixinclude lowercases those references.
74-
$ORIG/lowercase -symlink include
75-
$ORIG/fixinclude include
74+
"$ORIG"/lowercase -symlink include
75+
"$ORIG"/fixinclude include
76+
if [ -d "atlmfc/include" ]; then
77+
# The ATL headers are lowercased themselves, but they refer to
78+
# WinSDK headers with mixed casing.
79+
"$ORIG"/fixinclude "atlmfc/include"
80+
fi
7681
cd bin
7782
# vctip.exe is known to cause problems at some times; just remove it.
7883
# See https://bugs.chromium.org/p/chromium/issues/detail?id=735226 and
7984
# https://github.com/mstorsjo/msvc-wine/issues/23 for references.
8085
for i in $(find . -iname vctip.exe); do
8186
rm $i
8287
done
88+
if [ -d HostX64 ]; then
89+
# 15.x - 16.4
90+
mv HostX64 Hostx64
91+
fi
8392
if [ -d HostARM64 ]; then
8493
# 17.2 - 17.3
8594
mv HostARM64 Hostarm64
@@ -99,13 +108,15 @@ if [ -d kits/10 ]; then
99108
else
100109
mkdir kits
101110
cd kits
102-
unzip $SDK_ZIP
111+
unzip "$SDK_ZIP"
103112
cd 10
104113
fi
105114
ln_s Lib lib
106115
ln_s Include include
107116
cd ../..
108-
SDKVER=$(basename $(echo kits/10/include/* | awk '{print $NF}'))
117+
118+
SDKVER=$(basename $(echo kits/10/include/10.* | awk '{print $NF}'))
119+
echo Using SDK version $SDKVER
109120

110121
# Lowercase the SDK headers and libraries. As long as cl.exe is executed
111122
# within wine, this is mostly not necessary.
@@ -123,44 +134,78 @@ SDKVER=$(basename $(echo kits/10/include/* | awk '{print $NF}'))
123134
# The original casing of file names is preserved though, by adding lowercase
124135
# symlinks instead of doing a plain rename, so files can be referred to with
125136
# either the out of the box filename or with the lowercase name.
126-
$ORIG/lowercase -map_winsdk -symlink kits/10/include/$SDKVER/um
127-
$ORIG/lowercase -map_winsdk -symlink kits/10/include/$SDKVER/shared
128-
$ORIG/fixinclude -map_winsdk kits/10/include/$SDKVER/um
129-
$ORIG/fixinclude -map_winsdk kits/10/include/$SDKVER/shared
137+
for incdir in um shared winrt km; do
138+
SDK_INCDIR="kits/10/include/$SDKVER/$incdir"
139+
140+
if [ -d "$SDK_INCDIR" ]; then
141+
"$ORIG"/lowercase -map_winsdk -symlink "$SDK_INCDIR"
142+
"$ORIG"/fixinclude -map_winsdk "$SDK_INCDIR"
143+
fi
144+
done
145+
146+
# The WDF is a part of the Windows Driver Kit.
147+
WDF_INCDIR="kits/10/include/wdf"
148+
if [ -d "$WDF_INCDIR" ]; then
149+
"$ORIG"/lowercase -map_winsdk -symlink "$WDF_INCDIR"
150+
"$ORIG"/fixinclude -map_winsdk "$WDF_INCDIR"
151+
fi
152+
130153
for arch in x86 x64 arm arm64; do
131-
if [ ! -d "kits/10/lib/$SDKVER/um/$arch" ]; then
132-
continue
154+
SDK_LIBDIR="kits/10/lib/$SDKVER/um/$arch"
155+
DDK_LIBDIR="kits/10/lib/$SDKVER/km/$arch"
156+
157+
if [ -d "$SDK_LIBDIR" ]; then
158+
"$ORIG"/lowercase -symlink "$SDK_LIBDIR"
159+
fi
160+
if [ -d "$DDK_LIBDIR" ]; then
161+
"$ORIG"/lowercase -symlink "$DDK_LIBDIR"
133162
fi
134-
$ORIG/lowercase -symlink kits/10/lib/$SDKVER/um/$arch
135163
done
136164

137165
host=x64
166+
# .NET-based tools use different host arch directories
167+
dotnet_host=amd64
138168
if [ "$(uname -m)" = "aarch64" ]; then
139169
host=arm64
170+
dotnet_host=arm64
140171
fi
141172

142-
SDKVER=$(basename $(echo kits/10/include/* | awk '{print $NF}'))
143173
MSVCVER=$(basename $(echo vc/tools/msvc/* | awk '{print $1}'))
144-
cat $ORIG/wrappers/msvcenv.sh | sed 's/MSVCVER=.*/MSVCVER='$MSVCVER/ | sed 's/SDKVER=.*/SDKVER='$SDKVER/ | sed s/x64/$host/ > msvcenv.sh
174+
echo Using MSVC version $MSVCVER
175+
176+
# Support `import std` for CMake.
177+
if [ -d "VC/Tools/MSVC/$MSVCVER/modules" ]; then
178+
ln_s VC/Tools/MSVC/$MSVCVER/modules modules
179+
fi
180+
181+
cat "$ORIG"/wrappers/msvcenv.sh \
182+
| sed 's/MSVCVER=.*/MSVCVER='$MSVCVER/ \
183+
| sed 's/SDKVER=.*/SDKVER='$SDKVER/ \
184+
| sed s/x64/$host/ \
185+
| sed s/amd64/$dotnet_host/ \
186+
> msvcenv.sh
187+
145188
for arch in x86 x64 arm arm64; do
146-
if [ ! -d "vc/tools/msvc/$MSVCVER/bin/Hostx64/$arch" ]; then
189+
if [ ! -d "vc/tools/msvc/$MSVCVER/bin/Host$host/$arch" ]; then
147190
continue
148191
fi
149192
mkdir -p bin/$arch
150-
cp -a $ORIG/wrappers/* bin/$arch
193+
cp -a "$ORIG"/wrappers/* bin/$arch
151194
cat msvcenv.sh | sed 's/ARCH=.*/ARCH='$arch/ > bin/$arch/msvcenv.sh
152195
done
153196
rm msvcenv.sh
154197

155-
if [ -d "$DEST/bin/$host" ] && [ -x "$(which wine64 2>/dev/null)" ]; then
156-
WINEDEBUG=-all wine64 wineboot &>/dev/null
157-
echo "Build msvctricks ..."
158-
"$DEST/bin/$host/cl" /EHsc /O2 "$ORIG/msvctricks.cpp"
159-
if [ $? -eq 0 ]; then
160-
mv msvctricks.exe bin/
161-
rm msvctricks.obj
162-
echo "Build msvctricks done."
163-
else
164-
echo "Build msvctricks failed."
198+
if [ -d "$DEST/bin/$host" ]; then
199+
if WINE="$(command -v wine64 || command -v wine)"; then
200+
WINEDEBUG=-all "${WINE}" wineboot &>/dev/null
201+
echo "Build msvctricks ..."
202+
"$DEST/bin/$host/cl" /EHsc /O2 "$ORIG/msvctricks.cpp"
203+
if [ $? -eq 0 ]; then
204+
mv msvctricks.exe bin/
205+
rm msvctricks.obj
206+
echo "Build msvctricks done."
207+
else
208+
echo "Build msvctricks failed."
209+
fi
165210
fi
166211
fi

0 commit comments

Comments
 (0)