-
Notifications
You must be signed in to change notification settings - Fork 0
/
wine-cl-template
104 lines (93 loc) · 3.6 KB
/
wine-cl-template
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
#!/bin/sh
set -o errexit
set -o nounset
export WINEPREFIX="__WINEPREFIX__";
export WINEDLLOVERRIDES="__WINEDLLOVERRIDES__"
export WINEARCH="__WINEARCH__"
export WINEDEBUG=-all; # otheriwse too many "01c1:err:msvcrt:demangle_datatype Unknown type" outputs
INCLUDE_DEFAULT_PATHS="${INCLUDE:-}"'__INCLUDE_DEFAULT_PATHS__';
LIB_DEFAULT_PATH="${LIB:-}"'__LIB_DEFAULT_PATHS__';
is_help_param(){
[ "$1" = "-h" ] || [ "$1" = "h" ] || [ "$1" = "--help" ] || [ "$1" = "/help" ] || [ "$1" = "help" ] || [ "$1" = "?" ] || [ "$1" = "/?" ];
}
help(){
{ wine "$1" '/nologo' "$2"; printf 'Prefix: __WINEPREFIX__\nExecutable: __EXECUTABLE__'; } | less --quit-if-one-screen --no-init;
}
is_version_param(){
[ "$1" = "-v" ] || [ "$1" = "--version" ];
}
version(){
wine "$1" 2>&1 | head -n 2;
}
main(){
EXE='__EXECUTABLE__';
PARSE=true;
if [ -n "${VERBOSE+x}" ]; then :;
VERBOSE=true;
else :;
VERBOSE=false;
fi
NEXT_IS_WINSDK_VER=false;
NEXT_IS_WINSDK_DIR=false;
for key in "$@"; do :;
shift
if ! $PARSE; then :;
set -- "$@" "$key";
else
if [ "${key#/}" != "$key" ] && [ -f "$key" ]; then :;
set -- "$@" "$(winepath --windows "$key")";
elif [ "$key" = '--win-sdk-ver' ]; then :;
NEXT_IS_WINSDK_VER=true; # stop parsing, but do not give this key to cl.exe
elif $NEXT_IS_WINSDK_VER; then :;
winsdk_version="$key"; NEXT_IS_WIN_SDK_VER=false;
elif [ "$key" = '--win-sdk-dir' ]; then :;
NEXT_IS_WINSDK_DIR=true; # stop parsing, but do not give this key to cl.exe
elif $NEXT_IS_WINSDK_DIR; then :;
winsdk_dir="$key"; NEXT_IS_WIN_SDK_VER=false;
elif is_help_param "$key"; then :;
help "$EXE" '/?';
exit 0;
elif is_version_param "$key"; then :;
version "$EXE";
exit 0;
elif [ "$key" = "--" ] ; then :;
PARSE=false;
elif [ "$key" = "--verbose" ] ; then :;
VERBOSE=true;
elif [ "$key" = "/Zi" ] ; then :;
# nothing, just skip, or exchange with /FS
# generates with cmake "fatal error C1902: Program database manager mismatch"
# https://social.msdn.microsoft.com/Forums/vstudio/en-US/eb49be0b-2a8c-4d55-8791-17e3cb1364c1/fatal-error-c1902-program-database-manager-mismatch-please-check-your-installation?forum=vcgeneral
# https://www.winehq.org/pipermail/wine-bugs/2009-October/198928.html
# it causes error with parallel builds
else
for sub in Fa Fd Fm Fp FR doc FA Fe Fo Fr Fi FI FU Tc Yu Tp Yc I AI 'analyze:log'; do
if [ "${key#*/"$sub"}" != "$key" ] && { val=${key#*/"$sub"}; [ "${val#/}" != "$val" ]; }; then :;
key="/$sub$(winepath --windows "${key#*/"$sub"}")"; break;
elif [ "${key#*-"$sub"}" != "$key" ] && { val=${key#*-"$sub"}; [ "${val#/}" != "$val" ]; }; then :;
key="-$sub$(winepath --windows "${key#*-"$sub"}")"; break;
fi # @ not working (not prepended by / or -)
done
if [ "$sub" = "@" ]; then :;
key="$sub$(winepath --windows "${key#*"$sub"}")";
fi
set -- "$@" "$key";
fi
fi
done
if $VERBOSE; then
printf 'INCLUDE env: %s\n' "${INCLUDE_DEFAULT_PATHS}";
printf 'CL env: %s\n' "${CL:-}";
printf '_CL_ env: %s\n' "${_CL_:-}";
printf 'LIBPATH env: %s\n' "${LIBPATH:-}";
printf 'LIB env: %s\n' "${LIB_DEFAULT_PATH}";
printf 'executable: %s\n' "$EXE";
printf 'wine prefix: %s\n' "$WINEPREFIX";
printf 'parameters: '; printf '"%s" ' "$@"; printf '\n';
fi
CL="${CL:-}" \
INCLUDE="${INCLUDE_DEFAULT_PATHS}" \
LIB="${LIB_DEFAULT_PATH}" \
exec wine "$EXE" ${1:+"/nologo"} "$@";
}
main "$@";