Skip to content
Open
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
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ body:

You can access the wslg logs using explorer at: `\\wsl$\<Distro-Name>\mnt\wslg` (e.g.: `\\wsl$\Ubuntu-20.04\mnt\wslg`)

* `pulseaudio.log`
* `stderr.log` (default log for the PipeWire / pipewire-pulse daemons; attach `pipewire-pulse.log` only if you set `WSLG_PIPEWIRE_PULSE_LOG_PATH` to write a dedicated file)
* `weston.log`
* `stderr.log`
label: "WSL logs:"
placeholder: |
Drag and drop files into this input field to upload them.
Expand Down
17 changes: 10 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any addi

# Building the WSLg System Distro

The heart of WSLg is what we call the WSL system distro. This is where the Weston compositor, XWayland and the PulseAudio server are running. The system distro runs these components and projects their communication sockets into the user distro. Every user distro is paired with a unique instance of the system distro. There is a single version of the system distro on disk which is instantiated in memory when a user distro is launched.
The heart of WSLg is what we call the WSL system distro. This is where the Weston compositor, XWayland and the PipeWire audio stack (with pipewire-pulse) are running. The system distro runs these components and projects their communication sockets into the user distro. Every user distro is paired with a unique instance of the system distro. There is a single version of the system distro on disk which is instantiated in memory when a user distro is launched.

The system distro is essentially a Linux container packaged and distributed as a vhd. The system distro is accessible to the user, but is mounted read-only. Any changes made by the user to the system distro while it is running are discarded when WSL is restarted. Although a user can log into the system distro, it is not meant to be used as a general purpose user distro. The reason behind this choice is due to the way we service WSLg. When updating WSLg we simply replace the existing system distro with a new one. If the user had data embedded into the system distro vhd, this data would be lost.

For folks who want to tinker with or customize their system distro, we give the ability to run a private version of the system distro. When running a private version of WSLg, Windows will load and run your private and ignore the Microsoft published one. If you update your WSL setup (`wsl --update`), the Microsoft published WSLg vhd will be updated, but you will continue to be running your private. You can switch between the Microsoft pulished WSLg system distro and a private one at any time although it does require restarting WSL (`wsl --shutdown`).

The WSLg system distro is built using docker build. We essentially start from a [Azure Linux 3.0](https://github.com/microsoft/azurelinux) base image, install various packages, then build and install version of Weston, FreeRDP and PulseAudio from our mirror repo. This repository contains a Dockerfile and supporting tools to build the WSLg container and convert the container into an ext4 vhd that Windows will load as the system distro.
The WSLg system distro is built using docker build. We essentially start from a [Azure Linux 3.0](https://github.com/microsoft/azurelinux) base image, install various packages, then build and install version of Weston, FreeRDP, PipeWire, and WirePlumber. This repository contains a Dockerfile and supporting tools to build the WSLg container and convert the container into an ext4 vhd that Windows will load as the system distro.

## Build instructions

Expand All @@ -39,12 +39,13 @@ The WSLg system distro is built using docker build. We essentially start from a
git clone https://github.com/microsoft/wslg wslg
```

2. Clone the vendor sub-projects (FreeRDP, Weston, PulseAudio, Mesa, DirectX-Headers) into `wslg/vendor/`. The Dockerfile (and `build-and-export.sh`) expect the source code to live there. Use the `working` branch for the mirrored projects; `main` tracks upstream.
2. Clone the vendor sub-projects (FreeRDP, Weston, PipeWire, WirePlumber, Mesa, DirectX-Headers) into `wslg/vendor/`. The Dockerfile (and `build-and-export.sh`) expect the source code to live there. Use the `working` branch for the mirrored projects; `main` tracks upstream. PipeWire and WirePlumber are built from upstream tags.

```bash
git clone https://github.com/microsoft/FreeRDP-mirror wslg/vendor/FreeRDP -b working
git clone https://github.com/microsoft/weston-mirror wslg/vendor/weston -b working
git clone https://github.com/microsoft/PulseAudio-mirror wslg/vendor/pulseaudio -b working
git clone https://github.com/PipeWire/pipewire wslg/vendor/pipewire -b 1.4.10
git clone https://github.com/PipeWire/wireplumber wslg/vendor/wireplumber -b 0.5.13
git clone https://github.com/microsoft/DirectX-Headers.git wslg/vendor/DirectX-Headers-1.0 -b v1.608.0
git clone https://gitlab.freedesktop.org/mesa/mesa.git wslg/vendor/mesa -b mesa-23.1.0
```
Expand All @@ -58,7 +59,7 @@ The WSLg system distro is built using docker build. We essentially start from a
./build-and-export.sh
```

This produces `system_x64.vhd` in the current directory. If you prefer to do it by hand, pass the same set of `--build-arg`s that `build-and-export.sh` and the production pipeline (wslg-build) use. **All 7 vendor/version `--build-arg`s are required** (`WSLG_VERSION`, `WSLG_COMMIT`, `DIRECTX_HEADERS_VERSION`, `FREERDP_COMMIT`, `MESA_VERSION`, `PULSEAUDIO_COMMIT`, `WESTON_COMMIT`) -- the Dockerfile fails fast at the start of the `dev` stage if any is unset or still holds the `<unknown>` / `unknown` / `<current>` placeholder. `WSLG_ARCH` defaults to `x86_64` and does not need to be passed for a standard build. (Previously the build would silently complete and you'd discover `<unknown>` baked into `/etc/versions.txt` later.)
This produces `system_x64.vhd` in the current directory. If you prefer to do it by hand, pass the same set of `--build-arg`s that `build-and-export.sh` and the production pipeline (wslg-build) use. **All 8 vendor/version `--build-arg`s are required** (`WSLG_VERSION`, `WSLG_COMMIT`, `DIRECTX_HEADERS_VERSION`, `FREERDP_COMMIT`, `MESA_VERSION`, `PIPEWIRE_COMMIT`, `WIREPLUMBER_COMMIT`, `WESTON_COMMIT`) -- the Dockerfile fails fast at the start of the `dev` stage if any is unset or still holds the `<unknown>` / `unknown` / `<current>` placeholder. `WSLG_ARCH` defaults to `x86_64` and does not need to be passed for a standard build. (Previously the build would silently complete and you'd discover `<unknown>` baked into `/etc/versions.txt` later.)

```bash
sudo docker build -f wslg/Dockerfile -t system-distro-x64 wslg \
Expand All @@ -68,7 +69,8 @@ The WSLg system distro is built using docker build. We essentially start from a
--build-arg DIRECTX_HEADERS_VERSION="$(git -C wslg/vendor/DirectX-Headers-1.0 rev-parse HEAD)" \
--build-arg FREERDP_COMMIT="$(git -C wslg/vendor/FreeRDP rev-parse HEAD)" \
--build-arg MESA_VERSION="$(git -C wslg/vendor/mesa rev-parse HEAD)" \
--build-arg PULSEAUDIO_COMMIT="$(git -C wslg/vendor/pulseaudio rev-parse HEAD)" \
--build-arg PIPEWIRE_COMMIT="$(git -C wslg/vendor/pipewire rev-parse HEAD)" \
--build-arg WIREPLUMBER_COMMIT="$(git -C wslg/vendor/wireplumber rev-parse HEAD)" \
--build-arg WESTON_COMMIT="$(git -C wslg/vendor/weston rev-parse HEAD)"
sudo docker export "$(sudo docker create system-distro-x64)" > system_x64.tar

Expand Down Expand Up @@ -112,7 +114,8 @@ To build a debug version of the system distro, append `--build-arg SYSTEMDISTRO_
--build-arg DIRECTX_HEADERS_VERSION="$(git -C wslg/vendor/DirectX-Headers-1.0 rev-parse HEAD)" \
--build-arg FREERDP_COMMIT="$(git -C wslg/vendor/FreeRDP rev-parse HEAD)" \
--build-arg MESA_VERSION="$(git -C wslg/vendor/mesa rev-parse HEAD)" \
--build-arg PULSEAUDIO_COMMIT="$(git -C wslg/vendor/pulseaudio rev-parse HEAD)" \
--build-arg PIPEWIRE_COMMIT="$(git -C wslg/vendor/pipewire rev-parse HEAD)" \
--build-arg WIREPLUMBER_COMMIT="$(git -C wslg/vendor/wireplumber rev-parse HEAD)" \
--build-arg WESTON_COMMIT="$(git -C wslg/vendor/weston rev-parse HEAD)" \
--build-arg SYSTEMDISTRO_DEBUG_BUILD=true
```
Expand Down
124 changes: 102 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ RUN echo "== Install UI dependencies ==" && \
libSM-devel \
libsndfile \
libsndfile-devel \
lua \
lua-devel \
libXcursor \
libXcursor-devel \
libXdamage-devel \
Expand Down Expand Up @@ -134,7 +136,8 @@ ARG WSLG_ARCH="x86_64"
ARG DIRECTX_HEADERS_VERSION="<unknown>"
ARG FREERDP_COMMIT="<unknown>"
ARG MESA_VERSION="<unknown>"
ARG PULSEAUDIO_COMMIT="<unknown>"
ARG PIPEWIRE_COMMIT="<unknown>"
ARG WIREPLUMBER_COMMIT="<unknown>"
ARG WESTON_COMMIT="<unknown>"
ARG SYSTEMDISTRO_DEBUG_BUILD
ARG FREERDP_VERSION=2
Expand All @@ -161,7 +164,8 @@ RUN set -e; \
"DIRECTX_HEADERS_VERSION=${DIRECTX_HEADERS_VERSION}" \
"FREERDP_COMMIT=${FREERDP_COMMIT}" \
"MESA_VERSION=${MESA_VERSION}" \
"PULSEAUDIO_COMMIT=${PULSEAUDIO_COMMIT}" \
"PIPEWIRE_COMMIT=${PIPEWIRE_COMMIT}" \
"WIREPLUMBER_COMMIT=${WIREPLUMBER_COMMIT}" \
"WESTON_COMMIT=${WESTON_COMMIT}"; do \
name=${kv%%=*}; val=${kv#*=}; \
case "$val" in \
Expand All @@ -172,7 +176,7 @@ RUN set -e; \
exit 1 ;; \
esac; \
done; \
echo "All 7 required --build-arg values present."
echo "All 8 required --build-arg values present."

WORKDIR /work
RUN printf 'WSLg: %s\nArchitecture: %s\nBuilt: %s\nOS: %s\n\n' \
Expand All @@ -186,7 +190,8 @@ RUN printf 'WSLg: %s\nArchitecture: %s\nBuilt: %s\nOS: %s\n\n' \
'DirectX-Headers:' "${DIRECTX_HEADERS_VERSION}" \
'FreeRDP:' "${FREERDP_COMMIT}" \
'mesa:' "${MESA_VERSION}" \
'pulseaudio:' "${PULSEAUDIO_COMMIT}" \
'pipewire:' "${PIPEWIRE_COMMIT}" \
'wireplumber:' "${WIREPLUMBER_COMMIT}" \
'weston:' "${WESTON_COMMIT}" \
>> /work/versions.txt

Expand Down Expand Up @@ -244,15 +249,86 @@ RUN /usr/bin/meson --prefix=${PREFIX} build \
-Dllvm=disabled && \
ninja -C build -j8 install

# Build PulseAudio
COPY vendor/pulseaudio /work/vendor/pulseaudio
WORKDIR /work/vendor/pulseaudio
RUN /usr/bin/meson --prefix=${PREFIX} build \
# Build PipeWire
COPY vendor/pipewire /work/vendor/pipewire
RUN /usr/bin/meson setup /work/vendor/pipewire/build /work/vendor/pipewire \
--prefix=${PREFIX} \
--buildtype=${BUILDTYPE_NODEBUGSTRIP} \
-Ddocs=disabled \
-Dman=disabled \
-Dexamples=disabled \
-Dtests=disabled \
-Dsystemd-system-service=disabled \
-Dsystemd-user-service=disabled \
-Dx11=disabled \
-Dx11-xfixes=disabled \
-Dsession-managers=[] \
-Dpipewire-jack=enabled \
-Dpipewire-v4l2=enabled \
-Dlibpulse=disabled \
-Dbluez5=disabled \
-Dffmpeg=disabled \
-Dgsettings=disabled \
-Davahi=disabled \
-Dsnap=disabled \
-Drlimits-install=false \
-Dgstreamer=disabled \
-Dgstreamer-device-provider=disabled \
-Dlv2=disabled \
-Droc=disabled \
-Dspa-plugins=enabled && \
ninja -C /work/vendor/pipewire/build -j8 install && \
DESTDIR="" ninja -C /work/vendor/pipewire/build -j8 install

# Build WSLg PipeWire RDP modules
COPY config/pipewire-rdp-module.c /work/vendor/pipewire/src/modules/module-wslg-rdp.c
COPY config/pipewire-wslg-rdp.patch /work/vendor/pipewire/pipewire-wslg-rdp.patch
RUN cd /work/vendor/pipewire && \
git apply pipewire-wslg-rdp.patch && \
/usr/bin/meson setup /work/vendor/pipewire/build-wslg /work/vendor/pipewire \
--prefix=${PREFIX} \
--buildtype=${BUILDTYPE_NODEBUGSTRIP} \
-Ddatabase=simple \
-Ddoxygen=false \
-Ddocs=disabled \
-Dman=disabled \
-Dexamples=disabled \
-Dtests=disabled \
-Dsystemd-system-service=disabled \
-Dsystemd-user-service=disabled \
-Dsession-managers=[] \
-Dpipewire-jack=enabled \
-Dpipewire-v4l2=enabled \
-Dpipewire-alsa=enabled \
-Dlibpulse=disabled \
-Dbluez5=disabled \
-Dffmpeg=disabled \
-Dgsettings=disabled \
-Dtests=false && \
-Davahi=disabled \
-Dsnap=disabled \
-Drlimits-install=false \
-Dgstreamer=disabled \
-Dgstreamer-device-provider=disabled \
-Dlv2=disabled \
-Droc=disabled \
-Dspa-plugins=enabled && \
ninja -C /work/vendor/pipewire/build-wslg -j8 src/modules/libpipewire-module-wslg-rdp-sink.so src/modules/libpipewire-module-wslg-rdp-source.so && \
install -m 0755 /work/vendor/pipewire/build-wslg/src/modules/libpipewire-module-wslg-rdp-sink.so ${DESTDIR}${PREFIX}/lib/pipewire-0.3/libpipewire-module-wslg-rdp-sink.so && \
install -m 0755 /work/vendor/pipewire/build-wslg/src/modules/libpipewire-module-wslg-rdp-source.so ${DESTDIR}${PREFIX}/lib/pipewire-0.3/libpipewire-module-wslg-rdp-source.so


# Build WirePlumber
COPY vendor/wireplumber /work/vendor/wireplumber
WORKDIR /work/vendor/wireplumber
RUN /usr/bin/meson --prefix=${PREFIX} build \
--buildtype=${BUILDTYPE_NODEBUGSTRIP} \
-Ddoc=disabled \
-Dtests=false \
-Dsystemd=disabled \
-Dsystemd-user-service=false \
-Dsystemd-system-service=false \
-Dintrospection=disabled \
-Ddaemon=true \
-Dtools=true \
-Dmodules=true && \
ninja -C build -j8 install

# Build FreeRDP
Expand Down Expand Up @@ -377,6 +453,7 @@ RUN echo "== Install Core/UI Runtime Dependencies ==" && \
libpng \
librsvg2 \
libsndfile \
lua \
libwayland-client \
libwayland-server \
libwayland-cursor \
Expand Down Expand Up @@ -468,17 +545,20 @@ COPY resources/linux.png /usr/share/icons/wsl/linux.png
COPY --from=dev /work/build/usr/ /usr/
COPY --from=dev /work/build/etc/ /etc/

# Append WSLg setttings to pulseaudio.
COPY config/default_wslg.pa /etc/pulse/default_wslg.pa
RUN cat /etc/pulse/default_wslg.pa >> /etc/pulse/default.pa
RUN rm /etc/pulse/default_wslg.pa

# Copy the licensing information for PulseAudio
COPY --from=dev /work/vendor/pulseaudio/GPL \
/work/vendor/pulseaudio/LGPL \
/work/vendor/pulseaudio/LICENSE \
/work/vendor/pulseaudio/NEWS \
/work/vendor/pulseaudio/README /usr/share/doc/pulseaudio/
# Append WSLg settings to PipeWire.
COPY config/pipewire.conf /etc/pipewire/pipewire.conf
COPY config/pipewire-pulse.conf /etc/pipewire/pipewire-pulse.conf

# Copy the licensing information for PipeWire
COPY --from=dev /work/vendor/pipewire/COPYING \
/work/vendor/pipewire/LICENSE \
/work/vendor/pipewire/NEWS \
/work/vendor/pipewire/README.md /usr/share/doc/pipewire/

# Copy the licensing information for WirePlumber
COPY --from=dev /work/vendor/wireplumber/LICENSE \
/work/vendor/wireplumber/NEWS.rst \
/work/vendor/wireplumber/README.rst /usr/share/doc/wireplumber/

# Copy the licensing information for Weston
COPY --from=dev /work/vendor/weston/COPYING /usr/share/doc/weston/COPYING
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.WSLg.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<repository type="git" url="https://github.com/microsoft/wslg.git" commit="$commit$" />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>WSLg system distribution and WSLDVCPlugin for the Windows Subsystem for Linux: Wayland, X11, audio (PulseAudio), and RemoteApp (RDP) support.</description>
<description>WSLg system distribution and WSLDVCPlugin for the Windows Subsystem for Linux: Wayland, X11, audio (PipeWire), and RemoteApp (RDP) support.</description>
<copyright>Copyright © Microsoft Corporation</copyright>
<tags>wsl wslg wayland weston x11 native</tags>
</metadata>
Expand Down
Loading