44
55shopt -s extglob
66
7- if [ -z " $1 " ] || [ -z " $2 " ]; then
8- echo " Usage: $0 release destdir"
7+ if [ $# -lt 2 ]; then
8+ echo " Usage: $0 releasename destdir [--fakedll] "
99 exit 1
1010fi
1111
1212git submodule update --init --recursive
1313
1414VERSION=" $1 "
15+ DESTDIR=" $2 "
1516NVLIBS_SRC_DIR=$( dirname " $( readlink -f " $0 " ) " )
1617NVLIBS_BUILD_DIR=$( realpath " $2 " ) " /nvidia-libs-$VERSION "
18+ shift 2
19+
20+ FAKEDLL=" "
21+ LIBDIR=' x64'
22+
23+ for arg in " $@ " ; do
24+ case " $arg " in
25+ --fakedll)
26+ FAKEDLL=" -Dfakedll=true"
27+ LIBDIR=' lib'
28+ ;;
29+ * )
30+ echo " Error: unknown option '$arg '"
31+ exit 1
32+ ;;
33+ esac
34+ done
1735
1836if [ -e " $NVLIBS_BUILD_DIR " ]; then
1937 echo " Build directory $NVLIBS_BUILD_DIR already exists"
2038 exit 1
2139fi
2240
23- shift 2
24-
2541# Make version file
2642
2743meson --prefix " $NVLIBS_BUILD_DIR " \
@@ -44,8 +60,9 @@ meson setup \
4460 --cross-file " $NVCUDA_SRC_DIR /build-wine64.txt" \
4561 --buildtype release \
4662 --prefix " $NVLIBS_BUILD_DIR " \
47- --libdir " x64 " \
63+ --libdir $LIBDIR \
4864 --strip \
65+ $FAKEDLL \
4966 " $NVLIBS_BUILD_DIR /build.64"
5067
5168cd " $NVLIBS_BUILD_DIR /build.64"
@@ -81,8 +98,9 @@ meson setup \
8198 --cross-file " $NVENC_SRC_DIR /build-wine64.txt" \
8299 --buildtype release \
83100 --prefix " $NVLIBS_BUILD_DIR " \
84- --libdir " x64 " \
101+ --libdir $LIBDIR \
85102 --strip \
103+ $FAKEDLL \
86104 " $NVLIBS_BUILD_DIR /build.64"
87105
88106cd " $NVLIBS_BUILD_DIR /build.64"
@@ -99,8 +117,9 @@ meson setup \
99117 --cross-file " $NVOPTIX_SRC_DIR /build-wine64.txt" \
100118 --buildtype release \
101119 --prefix " $NVLIBS_BUILD_DIR " \
102- --libdir x64 \
120+ --libdir $LIBDIR \
103121 --strip \
122+ $FAKEDLL \
104123 " $NVLIBS_BUILD_DIR /build"
105124
106125cd " $NVLIBS_BUILD_DIR /build"
@@ -119,7 +138,7 @@ meson setup \
119138 --cross-file " $NVML_SRC_DIR /cross-mingw64.txt" \
120139 --buildtype release \
121140 --prefix " $NVLIBS_BUILD_DIR " \
122- --libdir " x64 " \
141+ --libdir $LIBDIR \
123142 --strip \
124143 " $NVLIBS_BUILD_DIR /build.mingw64"
125144
@@ -131,7 +150,7 @@ meson setup \
131150 --cross-file " $NVML_SRC_DIR /cross-wine64.txt" \
132151 --buildtype release \
133152 --prefix " $NVLIBS_BUILD_DIR " \
134- --libdir " x64 " \
153+ --libdir $LIBDIR \
135154 --strip \
136155 " $NVLIBS_BUILD_DIR /build.wine64"
137156
@@ -179,8 +198,8 @@ function build_arch {
179198 --buildtype release \
180199 --prefix " $NVLIBS_BUILD_DIR " \
181200 --strip \
182- --bindir " x $1 " \
183- --libdir " x $1 " \
201+ --bindir $LIBDIR \
202+ --libdir $LIBDIR \
184203 -Denable_tests=true \
185204 " $NVLIBS_BUILD_DIR /build.$1 "
186205
@@ -220,19 +239,31 @@ ninja install
220239rm -R " $NVLIBS_BUILD_DIR /build.layer"
221240
222241# Copy installscripts and README
223- cp $NVLIBS_SRC_DIR /* .sh " $NVLIBS_BUILD_DIR /"
224- rm $NVLIBS_BUILD_DIR /package-release.sh
225- chmod +x $NVLIBS_BUILD_DIR /* .sh
226- cp " $NVLIBS_SRC_DIR /Readme_nvml.txt" " $NVLIBS_BUILD_DIR /Readme_nvml.txt"
242+ if [ -z " $FAKEDLL " ]; then
243+ cp $NVLIBS_SRC_DIR /* .sh " $NVLIBS_BUILD_DIR /"
244+ rm $NVLIBS_BUILD_DIR /package-release.sh
245+ chmod +x $NVLIBS_BUILD_DIR /* .sh
246+ cp " $NVLIBS_SRC_DIR /Readme_nvml.txt" " $NVLIBS_BUILD_DIR /Readme_nvml.txt"
247+ fi
227248cp " $NVLIBS_SRC_DIR /README.md" " $NVLIBS_BUILD_DIR /README.md"
228249
229250# Move test
230251mkdir -p " $NVLIBS_BUILD_DIR /bin"
231- mv " $NVLIBS_BUILD_DIR /x64 /nvapi64-tests.exe" " $NVLIBS_BUILD_DIR /bin/"
232- mv " $NVLIBS_BUILD_DIR /x64 /nvofapi64-tests.exe" " $NVLIBS_BUILD_DIR /bin/"
252+ mv " $NVLIBS_BUILD_DIR /$LIBDIR /nvapi64-tests.exe" " $NVLIBS_BUILD_DIR /bin/"
253+ mv " $NVLIBS_BUILD_DIR /$LIBDIR /nvofapi64-tests.exe" " $NVLIBS_BUILD_DIR /bin/"
233254
234255# cleanup
235256cd $NVLIBS_BUILD_DIR
236257find . -name \* .a -type f -delete
237- find . -name " *.dll.so" -type f -exec bash -c ' mv "$0" "${0%.so}"' {} \;
258+ if [ -z " $FAKEDLL " ]; then
259+ find . -name " *.dll.so" -type f -exec bash -c ' mv "$0" "${0%.so}"' {} \;
260+ else
261+ # Hack the dxvk-nvapi dll's so that they look like wine builtin libraries
262+ winebuild --builtin " $NVLIBS_BUILD_DIR /$LIBDIR /nvapi64.dll"
263+ winebuild --builtin " $NVLIBS_BUILD_DIR /$LIBDIR /nvapi.dll"
264+ winebuild --builtin " $NVLIBS_BUILD_DIR /$LIBDIR /nvofapi64.dll"
265+ mkdir -p " $NVLIBS_BUILD_DIR /$LIBDIR /wine/i386-windows"
266+ mv " $NVLIBS_BUILD_DIR /$LIBDIR /nvapi.dll" " $NVLIBS_BUILD_DIR /$LIBDIR /wine/i386-windows"
267+ mv " $NVLIBS_BUILD_DIR /$LIBDIR /" * .dll " $NVLIBS_BUILD_DIR /$LIBDIR /wine/x86_64-windows"
268+ fi
238269echo " Done building!"
0 commit comments