-
Notifications
You must be signed in to change notification settings - Fork 0
/
wine-link-template
109 lines (97 loc) · 3.67 KB
/
wine-link-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
105
106
107
108
109
#!/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" = "/?" ];
}
is_help_param2(){
[ "$1" = '/link' ] || [ "$1" = 'link' ] || \
[ "$1" = '/lib' ] || [ "$1" = 'lib' ] || \
[ "$1" = '/dump' ] || [ "$1" = 'dumpbin' ] || \
[ "$1" = '/edit' ] || [ "$1" = 'editbin' ] || \
[ "$1" = '/cvtcil' ] || \
[ "$1" = '/pushthunkobj' ];
}
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 :;
G_VERBOSE="$VERBOSE";
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_help_param2 "$key"; then :;
# help "$EXE" "$key";
# 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" = "/debug" ] || [ "$key" = "/debug:FASTLINK" ] || [ "$key" = "/debug:FULL" ] ; then :;
# causes issues, on x86 also triggered by cmake test suite
else
for sub in 'ASSEMBLYLINKRESOURCE' 'ASSEMBLYMODULE' 'ASSEMBLYRESOURCE' 'DEF' 'IDLOUT' 'IMPLIB' 'KEYFILE' 'MANIFESTFILE' 'MANIFESTINPUT' 'MAP' 'MIDL' 'NATVIS' 'ORDER' 'OUT' 'PDB' 'PDBSTRIPPED' 'SOURCELINK' 'STUB' 'TLBOUT' 'WINMDFILE' 'WINMDKEYFILE'; 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
LIB="${LIB_DEFAULT_PATH}" \
exec wine "$EXE" ${G_VERBOSE:+"/VERBOSE"} /nologo "$@";
}
main "$@";