Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve manual_build docs. #93

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .devcontainer/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ CXX=/usr/bin/clang++ cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SU
cmake --build . --target install --config Release

# Setup nvidia
bash /etc/cont-init.d/30-nvidia.sh
bash /etc/cont-init.d/30-nvidia.sh

# Create base wolf cfg folder
mkdir -p $WOLF_CFG_FOLDER
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"XDG_RUNTIME_DIR": "/tmp/sockets",
"WOLF_LOG_LEVEL": "DEBUG",
"HOST_APPS_STATE_FOLDER": "/etc/wolf",
"WOLF_CFG_FOLDER": "/etc/wolf/cfg/",
"WOLF_CFG_FILE": "/etc/wolf/cfg/config.toml",
"WOLF_PRIVATE_KEY_FILE": "/etc/wolf/cfg/key.pem",
"WOLF_PRIVATE_CERT_FILE": "/etc/wolf/cfg/cert.pem",
Expand Down
Binary file added docs/modules/ROOT/images/devcontainer_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/devcontainer_tests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/devcontainers_build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 84 additions & 14 deletions docs/modules/dev/pages/manual_build.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
= Dev environment setup

== Devcontainers

We provide a https://containers.dev/[devcontainer] configuration that will allow you to automatically setup a development environment for Wolf.
The advantage of this solution is that you'll be running the code in the exact same environment as users of the official docker image, plus you don't have to worry about setting up the dependencies manually.

The following are a few quickstep to get you started on VSCode:

* From an empty window open up the Command Palette using kbd:[CTRL+SHIFT+P] and search for `Dev containers: Clone Repository in Container Volume`
* Follow the instructions, you'll be asked to provide the repository URL, branch and so on; when you've finished VSCode will start building the container

.Give it time, this will go on for a while; luckily, only the first time you'll have to wait this long.
image::ROOT:devcontainers_build.png[]

Once the process is over you should be able to see the files on the left panel, and you can start editing the code.
Soon enough you'll get this prompt:

image::ROOT:devcontainer_pick_tools.png[]

Pick the last option: `Clang ....` and you'll be ready to go.

=== Build and run Wolf

In the bottom left corner of the window you should see these 3 handy little buttons, respectively: build, debug and run

image::ROOT:devcontainer_buttons.png[]

Pressing the play button should compile and start Wolf and you should be able to see the logs in the terminal.
To stop it, just press kbd:[CTRL+C] in the terminal.

=== Run unit tests

To run tests you have to change the cmake target from the default `wolf` to `wolftests`.
You can do that by clicking the cmake button on the bottom left corner of the window and selecting `wolftests` from the project outline.

image::ROOT:devcontainer_tests.png[]

== Manual installation

This has been tested on Debian 12, you should adjust the setup based on your distro of choice.
This guide will explain how to build and run Wolf outside of docker, but docker will need to be installed and configured on the host for Wolf to do anything useful.
Consult your distribution's documentation for instructions on setting up Docker.

== Install Nvidia driver + cuda

Expand Down Expand Up @@ -29,6 +69,8 @@ apt install -y build-essential ninja-build gcc meson cmake ccache bison equivs \
libharfbuzz-dev libpango1.0-dev
....

Please refer to `docker/gstreamer.Dockerfile` for an up-to-date list of parameters and versions.

.Build gstreamer
[source,bash]
....
Expand Down Expand Up @@ -75,12 +117,13 @@ This will install libraries and include files under `~/gstreamer`, in order for
.Custom env
[source,bash]
....
export PATH="$HOME/gstreamer/usr/local/bin:$PATH"
export LIBRARY_PATH="$LIBRARY_PATH:$HOME/gstreamer/usr/local/lib/x86_64-linux-gnu/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/gstreamer/lib/x86_64-linux-gnu/"
export LDFLAGS="$LDFLAGS -L$HOME/gstreamer/usr/local/lib/x86_64-linux-gnu/"
export CFLAGS="$CFLAGS -I$HOME/gstreamer/usr/local/include"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOME/gstreamer/usr/local/lib/x86_64-linux-gnu/pkgconfig/"
GSTREAMER_FOLDER="$HOME/gstreamer"
export PATH="$GSTREAMER_FOLDER/usr/local/bin:$PATH"
export LIBRARY_PATH="$LIBRARY_PATH:$GSTREAMER_FOLDER/usr/local/lib/x86_64-linux-gnu/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GSTREAMER_FOLDER/lib/x86_64-linux-gnu/"
export LDFLAGS="$LDFLAGS -L$GSTREAMER_FOLDER/usr/local/lib/x86_64-linux-gnu/"
export CFLAGS="$CFLAGS -I$GSTREAMER_FOLDER/usr/local/include"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$GSTREAMER_FOLDER/usr/local/lib/x86_64-linux-gnu/pkgconfig/"
....

You can now check that the `nvcodec` plugin correctly works (only on Nvidia hosts)
Expand Down Expand Up @@ -110,11 +153,12 @@ Like we have done for Gstreamer we are going to install this in a different dire
.Custom env
[source,bash]
....
export LIBRARY_PATH="$LIBRARY_PATH:$HOME/gst-wayland-display/lib/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/gst-wayland-display/lib/"
export LDFLAGS="$LDFLAGS -L$HOME/gst-wayland-display/lib"
export CFLAGS="$CFLAGS -I$HOME/gst-wayland-display/include"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOME/gst-wayland-display/lib/pkgconfig/"
GSTWAYLANDDISPLAY_FOLDER="$HOME/gst-wayland-display"
export LIBRARY_PATH="$LIBRARY_PATH:$GSTWAYLANDDISPLAY_FOLDER/lib/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GSTWAYLANDDISPLAY_FOLDER/lib/"
export LDFLAGS="$LDFLAGS -L$GSTWAYLANDDISPLAY_FOLDER/lib"
export CFLAGS="$CFLAGS -I$GSTWAYLANDDISPLAY_FOLDER/include -fPIC"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$GSTWAYLANDDISPLAY_FOLDER/lib/pkgconfig/"
....

=== Install Wolf deps
Expand Down Expand Up @@ -148,16 +192,42 @@ apt-get install -y --no-install-recommends \
.Compile
[source,bash]
....
cmake -Bbuild -DCMAKE_C_FLAGS=$CFLAGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_EXTENSIONS=OFF -G Ninja
cmake -Bbuild -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_EXTENSIONS=OFF -G Ninja
ninja -C build
....

If compilation completes correctly, you can finally start Wolf
If compilation completes correctly, you can finally start Wolf.
The built binary can be found at `build/src/moonlight-server/wolf`
Since Wolf is configured via a swoth of environment variables, it may be a good idea to lanch it via shell script.

.runwolf.sh
[source,bash]
....
#!/bin/bash

: ${WOLF_CFG_FOLDER:-"config"}

XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp/sockets}" \
WOLF_LOG_LEVEL="${WOLF_LOG_LEVEL:-INFO}" \
WOLF_CFG_FILE="${WOLF_CFG_FILE:-$WOLF_CFG_FOLDER/config.toml}" \
WOLF_PRIVATE_KEY_FILE="${WOLF_PRIVATE_KEY_FILE:-$WOLF_CFG_FOLDER/key.pem}" \
WOLF_PRIVATE_CERT_FILE="${WOLF_PRIVATE_CERT_FILE:-$WOLF_CFG_FOLDER/cert.pem}" \
WOLF_PULSE_IMAGE="${WOLF_PULSE_IMAGE:-ghcr.io/games-on-whales/pulseaudio:master}" \
WOLF_RENDER_NODE="${WOLF_RENDER_NODE:-/dev/dri/renderD128}" \
WOLF_STOP_CONTAINER_ON_EXIT="${WOLF_STOP_CONTAINER_ON_EXIT:-TRUE}" \
WOLF_DOCKER_SOCKET="${WOLF_DOCKER_SOCKET:-/var/run/docker.sock}" \
RUST_BACKTRACE="${RUST_BACKTRACE:-full}" \
RUST_LOG="${RUST_LOG:-WARN}" \
HOST_APPS_STATE_FOLDER="${HOST_APPS_STATE_FOLDER:-$WOLF_CFG_FOLDER}" \
GST_DEBUG="${GST_DEBUG:-2}" \
./build/src/moonlight-server/wolf
....

.Run!
[source,bash]
....
build/src/wolf/wolf
chmod +x runwolf.sh
./runwolf.sh
INFO | Reading config file from: config.toml
WARN | Unable to open config file: config.toml, creating one using defaults
INFO | x509 certificates not present, generating...
Expand Down
Loading