forked from cheald/dxvk-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-dxvk
executable file
·143 lines (123 loc) · 3.55 KB
/
make-dxvk
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
IMAGE=${IMAGE:-"cheald/dxvk-docker:latest"}
DXVK_REPO=${DXVK_REPO:-"https://github.com/doitsujin/dxvk.git"}
DEFAULT_GITREF=master
GITREF=""
REPO_DIR=${REPO_DIR:-dxvk}
while getopts "h?b:r:l:" opt; do
case "$opt" in
h|\?)
cat << EOF
$(basename "$0") [-h] [-b branch] [-r repository_url] [-m image] [-l install_location]
where:
-h Show this help text
-b Set the Git branch to build
-r Set the Git repository to build from (default: $DXVK_REPO)
-l Set the Lutris install location (path to lutris/runtime/dxvk)
EOF
exit 0
;;
b) GITREF=$OPTARG
;;
r) DXVK_REPO=$OPTARG
;;
m) IMAGE=$OPTARG
;;
l) INSTALL_LOCATION=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
if [[ ! -d $REPO_DIR ]] ; then
git clone $DXVK_REPO
fi
if [ -z "$GITREF" ]; then
read -p "What branch/tag/gitref do you want to build? [master]: " GITREF
GITREF=${GITREF:-$DEFAULT_GITREF}
fi
cd $REPO_DIR
git fetch -a
_=$(git show-ref --verify refs/heads/$GITREF 2>&1)
isBranch=$?
_=$(git show-ref --verify refs/tags/$GITREF 2>&1)
isTag=$?
_=$(git rev-parse --verify "$GITREF^{commit}" 2>&1)
isCommit=$?
if [ $isBranch -eq 0 ] ; then
git checkout origin/$GITREF
elif [ $isTag -eq 0 ] ; then
git checkout tags/$GITREF
elif [ $isCommit -eq 0 ] ; then
git checkout $GITREF
else
echo "Invalid gitref!"
exit 1
fi
echo ""
echo "About to build commit:"
echo "----------------------------------------------------------"
echo $(git log HEAD~1..HEAD)
echo "----------------------------------------------------------"
echo ""
cd ..
targetDir="dxvk-$(echo $GITREF | tr "/" "-" )"
forceBuild="y"
if [[ -d out/$targetDir ]] ; then
read -p "$targetDir appears to be built already. Do you want to rebuild it? [y/N]" forceBuild
forceBuild=${forceBuild:-n}
fi
case $forceBuild in
[yY])
docker run -e UID=$UID -e GID=$(id -g $USER) -it -v $(pwd)/$REPO_DIR:/root/build $IMAGE
rm -rf out
mkdir out
mv $REPO_DIR/out/dxvk-master out/$targetDir
;;
*)
echo "Skipping build..."
;;
esac
read -p "Install $targetDir to Lutris? [Y/n]: " install
install=${install:-Y}
case $install in
[yY])
if [ -z "$INSTALL_LOCATION" ] ; then
read -p "Do you want me to try to find your Lutris location? [Y/n]" doFind
doFind=${doFind:-y}
case $doFind in
[yY])
INSTALL_LOCATION=$(locate "lutris/runtime/dxvk" | grep -e "lutris/runtime/dxvk$" | head -n 1)
read -p "Found location: ${INSTALL_LOCATION} - is this right? [y/n]" isCorrect
isCorrect=${isCorrect:-y}
case $isCorrect in
[yY])
INSTALL_LOCATION=$INSTALL_LOCATION
;;
*)
INSTALL_LOCATION="/bogus/location"
;;
esac
;;
*)
INSTALL_LOCATION="/bogus/location"
;;
esac
fi
while [[ ! -d $INSTALL_LOCATION ]] ; do
read -p "Install location: [${INSTALL_LOCATION}]: " INSTALL_LOCATION
INSTALL_LOCATION=${INSTALL_LOCATION:-~/.local/share/lutris/runtime/dxvk}
if [[ ! -d $INSTALL_LOCATION ]]; then
echo "Invalid install location: $INSTALL_LOCATION does not exist"
fi
done
echo "Installing to ${INSTALL_LOCATION}"
rm -rf $INSTALL_LOCATION/$targetDir
cp -R out/$targetDir $INSTALL_LOCATION
echo "$targetDir installed. Enter '$targetDir' as your DXVK version in Lutris."
;;
*)
;;
esac