diff --git a/.devcontainer/dev-setup.sh b/.devcontainer/dev-setup.sh index 93141a55..125b1c15 100644 --- a/.devcontainer/dev-setup.sh +++ b/.devcontainer/dev-setup.sh @@ -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 \ No newline at end of file +bash /etc/cont-init.d/30-nvidia.sh + +# Create base wolf cfg folder +mkdir -p $WOLF_CFG_FOLDER \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 66193208..d8d13885 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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", diff --git a/docs/modules/ROOT/images/devcontainer_buttons.png b/docs/modules/ROOT/images/devcontainer_buttons.png new file mode 100644 index 00000000..c4a9b472 Binary files /dev/null and b/docs/modules/ROOT/images/devcontainer_buttons.png differ diff --git a/docs/modules/ROOT/images/devcontainer_pick_tools.png b/docs/modules/ROOT/images/devcontainer_pick_tools.png new file mode 100644 index 00000000..a872eff9 Binary files /dev/null and b/docs/modules/ROOT/images/devcontainer_pick_tools.png differ diff --git a/docs/modules/ROOT/images/devcontainer_tests.png b/docs/modules/ROOT/images/devcontainer_tests.png new file mode 100644 index 00000000..88a61b74 Binary files /dev/null and b/docs/modules/ROOT/images/devcontainer_tests.png differ diff --git a/docs/modules/ROOT/images/devcontainers_build.png b/docs/modules/ROOT/images/devcontainers_build.png new file mode 100644 index 00000000..764c7945 Binary files /dev/null and b/docs/modules/ROOT/images/devcontainers_build.png differ diff --git a/docs/modules/dev/pages/manual_build.adoc b/docs/modules/dev/pages/manual_build.adoc index fd1170b9..ad4ada6b 100644 --- a/docs/modules/dev/pages/manual_build.adoc +++ b/docs/modules/dev/pages/manual_build.adoc @@ -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 @@ -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] .... @@ -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) @@ -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 @@ -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...