Skip to content

Commit dfbdbfa

Browse files
committed
Add fakedll buildoption
If the buildoption --fakedll is given, this will build nvidia-libs as dll.so and fakedll that can be used directly with wine. Eg. package-release.sh name /folder --fakedll
1 parent c58a6b2 commit dfbdbfa

3 files changed

Lines changed: 68 additions & 18 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ nvoptix (wine-nvoptix - [https://github.com/SveSop/wine-nvoptix](https://github.
4343
eg. `./package-release.sh latest /home/yourname/`
4444
Will create a folder containing the libraries in `/home/yourname/nvidia-libs-latest`
4545

46+
### Optional build variables
47+
48+
If you put `--fakedll` after the buildscript like this:
49+
`./package-release.sh latest /home/yourname --fakedll`
50+
The library will be built as a winelib dll.so and a fakedll .dll placed in the
51+
output folder in typical wine folderstructure eg.
52+
`nvidia-libs-latest/lib/wine/x86_64-windows` and `nvidia-libs-latest/lib/wine/x86_64-unix`
53+
These can preferrably be used with the wine env variable `WINEDLLPATH` like this:
54+
`export WINEDLLPATH=/home/yourname/nvidia-libs-latest/lib/wine`
55+
56+
This should make `wineboot -u` copy the fakedlls to your WINEPREFIX automatically if you
57+
use wine > 10.0. Be aware that you must use this ENV variable whenever you use that
58+
WINEPREFIX.
59+
This is true also for `dxvk-nvapi` dll's and `wine-nvml` library in the filestructure.
60+
The files can also be copied directly into the wine binary folders in the same folderstructure,
61+
and it should work the same way.
62+
OBS: No WINEPREFIX or PROTON install scripts will be available with this build method (for now).
63+
4664
## How to install
4765

4866
### Wineprefix

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
option('fakedll', type: 'boolean', value: false)

package-release.sh

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,40 @@ set -e
44

55
shopt -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
1010
fi
1111

1212
git submodule update --init --recursive
1313

1414
VERSION="$1"
15+
DESTDIR="$2"
1516
NVLIBS_SRC_DIR=$(dirname "$(readlink -f "$0")")
1617
NVLIBS_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

1836
if [ -e "$NVLIBS_BUILD_DIR" ]; then
1937
echo "Build directory $NVLIBS_BUILD_DIR already exists"
2038
exit 1
2139
fi
2240

23-
shift 2
24-
2541
# Make version file
2642

2743
meson --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

5168
cd "$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

88106
cd "$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

106125
cd "$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
220239
rm -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
227248
cp "$NVLIBS_SRC_DIR/README.md" "$NVLIBS_BUILD_DIR/README.md"
228249

229250
# Move test
230251
mkdir -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
235256
cd $NVLIBS_BUILD_DIR
236257
find . -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
238269
echo "Done building!"

0 commit comments

Comments
 (0)