-
Notifications
You must be signed in to change notification settings - Fork 0
/
wine-mt-template
100 lines (89 loc) · 3.34 KB
/
wine-mt-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
#!/bin/sh
set -o errexit
set -o nounset
export WINEPREFIX="__WINEPREFIX__";
export WINEDLLOVERRIDES="__WINEDLLOVERRIDES__"
export WINEARCH="__WINEARCH__"
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; # does not really how version info.. could gather from directory
}
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;
[ $# -eq 0 ] && set -- "$@" '?';
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;
else
for sub in 'rgs' 'tlb' 'winmd' 'dll' 'replacements' 'out' 'inputresource' 'outputresource' 'updateresource' 'hashupdate' 'validate_file_hashes'; 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
done
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
# 0x4102001 is success, but 0x4102001==68165633, and 68165633 modulo 256 == 1
# https://developercommunity.visualstudio.com/content/problem/138528/155-preview-tons-of-random-linker-errors-that-work.html
# https://docs.microsoft.com/en-us/windows/desktop/EventLog/event-identifiers
# https://gitlab.kitware.com/cmake/cmake/issues/17444
if wine "$EXE" ${1:+"/nologo"} "$@" || [ $? -eq 1 ]; then :;
exit 0;
else :;
exit $?;
fi
}
main "$@";