Skip to content

Commit 81bb0c4

Browse files
committed
tools: add mingw update script
1 parent 2e424e0 commit 81bb0c4

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

tools/update_mingw.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/sh -e
2+
3+
if [ $# != 2 ]; then
4+
echo "usage: $0 <zig-lib-dir> <mingw-w64-dir>"
5+
exit 1
6+
fi
7+
8+
: ${MAKE:=make -j$(nproc)}
9+
ZIG="$(realpath $1)"
10+
set -x
11+
cd $2
12+
13+
cd mingw-w64-headers
14+
./configure --prefix= --includedir=/ --with-widl --with-default-win32-winnt=0x0A00 --with-default-msvcrt=ucrt
15+
$MAKE
16+
rm -r "$ZIG/libc/include/any-windows-any"
17+
$MAKE install DESTDIR="$ZIG/libc/include/any-windows-any"
18+
cd ..
19+
20+
cd mingw-w64-crt
21+
rm -r build-aux libce math/DFP math/softmath profile testcases
22+
rm .gitignore ChangeLog* Makefile.* aclocal.m4 config.h.in configure*
23+
rm gdtoa/README* lib*/Makefile.am lib*/ChangeLog*
24+
rm cfguard/mingw_cfguard_loadcfg.S
25+
rm crt/binmode.c crt/crtbegin.c crt/crtend.c crt/CRT_fp8.c crt/CRT_glob.c crt/CRT_noglob.c crt/txtmode.c crt/ucrtexe.c
26+
rm lib32/res.rc lib32/test.c
27+
rm mingw/mingwthrd.def mingw/mthr_stub.c
28+
for f in agtctl_i agtsvr_i cdoex_i cdoexm_i cdosys_i emostore_i iisext_i mtsadmin_i mtxadmin_i scardssp_i scardssp_p tsuserex_i; do
29+
mv libsrc/$f.c "$ZIG/libc/include/any-windows-any"
30+
done
31+
for f in COPYING include/config.h; do
32+
cp "$ZIG/libc/mingw/$f" $f;
33+
done
34+
rm -r "$ZIG/libc/mingw"
35+
cp -r . "$ZIG/libc/mingw"
36+
37+
set +x
38+
39+
echo
40+
echo 'Processing MRI files...'
41+
cd "$ZIG/libc/mingw"
42+
43+
first_arg() {
44+
echo $1
45+
}
46+
47+
for f in lib*/*.mri; do
48+
out=${f%.mri}.zri
49+
while read line; do
50+
case $line in
51+
ADDLIB\ lib*.a)
52+
lib=${line#ADDLIB lib}
53+
lib=${lib%.a}
54+
case $lib in
55+
*_extra|*_def|msvcrt_common) ;;
56+
*)
57+
case $(first_arg lib*/$lib.def*) in
58+
lib\**) echo "warning: $out: def file for $lib not found"
59+
esac
60+
echo $lib >>$out
61+
esac
62+
;;
63+
\;*|CREATE*|SAVE|END) ;;
64+
*)
65+
echo "error: unsupported line in $f: $line"
66+
exit 1
67+
esac
68+
done <$f
69+
rm $f
70+
done
71+
72+
echo
73+
echo 'Done.'
74+
echo
75+
echo 'If there were changes to mingw-w64-crt/Makefile.am since the last release,'
76+
echo 'edit src/mingw.zig to reflect them.'

0 commit comments

Comments
 (0)