VirtualBox

source: vbox/trunk/src/libs/dxvk-native-1.9.2a/setup_dxvk.sh@ 98322

Last change on this file since 98322 was 96497, checked in by vboxsync, 2 years ago

libs/dxvk-native-1.9.2a: export to OSE

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#!/usr/bin/env bash
2
3# default directories
4dxvk_lib32=${dxvk_lib32:-"x32"}
5dxvk_lib64=${dxvk_lib64:-"x64"}
6
7# figure out where we are
8basedir=$(dirname "$(readlink -f $0)")
9
10# figure out which action to perform
11action="$1"
12
13case "$action" in
14install)
15 ;;
16uninstall)
17 ;;
18*)
19 echo "Unrecognized action: $action"
20 echo "Usage: $0 [install|uninstall] [--without-dxgi] [--with-d3d10] [--symlink]"
21 exit 1
22esac
23
24# process arguments
25shift
26
27with_dxgi=true
28with_d3d10=false
29file_cmd="cp -v"
30
31while (($# > 0)); do
32 case "$1" in
33 "--without-dxgi")
34 with_dxgi=false
35 ;;
36 "--with-d3d10")
37 with_d3d10=true
38 ;;
39 "--symlink")
40 file_cmd="ln -s -v"
41 ;;
42 esac
43 shift
44done
45
46# check wine prefix before invoking wine, so that we
47# don't accidentally create one if the user screws up
48if [ -n "$WINEPREFIX" ] && ! [ -f "$WINEPREFIX/system.reg" ]; then
49 echo "$WINEPREFIX:"' Not a valid wine prefix.' >&2
50 exit 1
51fi
52
53# find wine executable
54export WINEDEBUG=-all
55# disable mscoree and mshtml to avoid downloading
56# wine gecko and mono
57export WINEDLLOVERRIDES="mscoree,mshtml="
58
59wine="wine"
60wine64="wine64"
61wineboot="wineboot"
62
63# $PATH is the way for user to control where wine is located (including custom Wine versions).
64# Pure 64-bit Wine (non Wow64) requries skipping 32-bit steps.
65# In such case, wine64 and winebooot will be present, but wine binary will be missing,
66# however it can be present in other PATHs, so it shouldn't be used, to avoid versions mixing.
67wine_path=$(dirname "$(which $wineboot)")
68wow64=true
69if ! [ -f "$wine_path/$wine" ]; then
70 wine=$wine64
71 wow64=false
72fi
73
74# resolve 32-bit and 64-bit system32 path
75winever=$($wine --version | grep wine)
76if [ -z "$winever" ]; then
77 echo "$wine:"' Not a wine executable. Check your $wine.' >&2
78 exit 1
79fi
80
81# ensure wine placeholder dlls are recreated
82# if they are missing
83$wineboot -u
84
85win64_sys_path=$($wine64 winepath -u 'C:\windows\system32' 2> /dev/null)
86win64_sys_path="${win64_sys_path/$'\r'/}"
87if $wow64; then
88 win32_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null)
89 win32_sys_path="${win32_sys_path/$'\r'/}"
90fi
91
92if [ -z "$win32_sys_path" ] && [ -z "$win64_sys_path" ]; then
93 echo 'Failed to resolve C:\windows\system32.' >&2
94 exit 1
95fi
96
97# create native dll override
98overrideDll() {
99 $wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v $1 /d native /f >/dev/null 2>&1
100 if [ $? -ne 0 ]; then
101 echo -e "Failed to add override for $1"
102 exit 1
103 fi
104}
105
106# remove dll override
107restoreDll() {
108 $wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v $1 /f > /dev/null 2>&1
109 if [ $? -ne 0 ]; then
110 echo "Failed to remove override for $1"
111 fi
112}
113
114# copy or link dxvk dll, back up original file
115installFile() {
116 dstfile="${1}/${3}.dll"
117 srcfile="${basedir}/${2}/${3}.dll"
118
119 if [ -f "${srcfile}.so" ]; then
120 srcfile="${srcfile}.so"
121 fi
122
123 if ! [ -f "${srcfile}" ]; then
124 echo "${srcfile}: File not found. Skipping." >&2
125 return 1
126 fi
127
128 if [ -n "$1" ]; then
129 if [ -f "${dstfile}" ] || [ -h "${dstfile}" ]; then
130 if ! [ -f "${dstfile}.old" ]; then
131 mv -v "${dstfile}" "${dstfile}.old"
132 else
133 rm -v "${dstfile}"
134 fi
135 $file_cmd "${srcfile}" "${dstfile}"
136 else
137 echo "${dstfile}: File not found in wine prefix" >&2
138 return 1
139 fi
140 fi
141 return 0
142}
143
144# remove dxvk dll, restore original file
145uninstallFile() {
146 dstfile="${1}/${3}.dll"
147 srcfile="${basedir}/${2}/${3}.dll"
148
149 if [ -f "${srcfile}.so" ]; then
150 srcfile="${srcfile}.so"
151 fi
152
153 if ! [ -f "${srcfile}" ]; then
154 echo "${srcfile}: File not found. Skipping." >&2
155 return 1
156 fi
157
158 if ! [ -f "${dstfile}" ] && ! [ -h "${dstfile}" ]; then
159 echo "${dstfile}: File not found. Skipping." >&2
160 return 1
161 fi
162
163 if [ -f "${dstfile}.old" ]; then
164 rm -v "${dstfile}"
165 mv -v "${dstfile}.old" "${dstfile}"
166 return 0
167 else
168 return 1
169 fi
170}
171
172install() {
173 installFile "$win64_sys_path" "$dxvk_lib64" "$1"
174 inst64_ret="$?"
175
176 inst32_ret=-1
177 if $wow64; then
178 installFile "$win32_sys_path" "$dxvk_lib32" "$1"
179 inst32_ret="$?"
180 fi
181
182 if (( ($inst32_ret == 0) || ($inst64_ret == 0) )); then
183 overrideDll "$1"
184 fi
185}
186
187uninstall() {
188 uninstallFile "$win64_sys_path" "$dxvk_lib64" "$1"
189 uninst64_ret="$?"
190
191 uninst32_ret=-1
192 if $wow64; then
193 uninstallFile "$win32_sys_path" "$dxvk_lib32" "$1"
194 uninst32_ret="$?"
195 fi
196
197 if (( ($uninst32_ret == 0) || ($uninst64_ret == 0) )); then
198 restoreDll "$1"
199 fi
200}
201
202# skip dxgi during install if not explicitly
203# enabled, but always try to uninstall it
204if $with_dxgi || [ "$action" == "uninstall" ]; then
205 $action dxgi
206fi
207
208$action d3d9
209
210if $with_d3d10 || [ "$action" == "uninstall" ]; then
211 $action d3d10
212 $action d3d10_1
213fi
214
215$action d3d10core
216$action d3d11
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette