-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (58 loc) · 4.06 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (58 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Toolchain image for cross-building Mesa NVK (Vulkan) for the Nintendo Switch.
# Base = devkitPro devkitA64 (aarch64-none-elf gcc + libnx + meson-cross helper).
# Adds: meson/mako (Mesa build), Rust nightly + rust-src (NAK shader compiler is Rust;
# the Switch is a tier-3 target `aarch64-nintendo-switch-freestanding` needing -Zbuild-std),
# bindgen (NAK's C<->Rust FFI), and the usual codegen tools.
FROM devkitpro/devkita64
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-pip bison flex curl ca-certificates pkg-config \
clang libclang-dev llvm-dev git \
&& rm -rf /var/lib/apt/lists/*
RUN python3 -m pip install --break-system-packages --no-cache-dir 'meson>=1.4' mako pyyaml
# Rust nightly (build-std needs nightly + rust-src for the tier-3 Switch target).
ENV RUSTUP_HOME=/opt/rust/rustup CARGO_HOME=/opt/rust/cargo
ENV PATH="/opt/rust/cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain nightly --profile minimal --component rust-src \
&& rustc --version && cargo --version
# bindgen (C->Rust FFI for NAK) + cbindgen (Rust->C headers for NIL, the nouveau image-layout lib).
RUN cargo install --locked bindgen-cli cbindgen && bindgen --version && cbindgen --version
# rustfmt: NAK's build formats its generated Rust bindings; meson errors without it.
RUN rustup component add rustfmt && rustfmt --version
# libclang for bindgen at runtime.
ENV LIBCLANG_PATH=/usr/lib/llvm-14/lib
# LLVM 15 + libclc-15 + SPIRV-LLVM-Translator (added as a late layer to keep the Rust layers cached).
# mesa_clc (build-time host tool for NVK's CL kernels) needs LLVM>=15 (Mesa 25.0) + libclc + the
# SPIR-V translator (LLVM-IR -> SPIR-V).
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake llvm-15-dev clang-15 libclang-15-dev libclc-15-dev libclc-15 \
llvm-spirv-15 libllvmspirvlib-15-dev spirv-tools libdrm-dev \
&& rm -rf /var/lib/apt/lists/*
# libdrm headers (xf86drm.h + drm-uapi) for the CROSS winsys. They are arch-neutral declarations;
# the native x86 build links the real libdrm.so, the Switch winsys will be reimplemented over libnx
# nv services (M1) so the aarch64 link is provided by our shim, not libdrm.so. Copy to a cross-safe
# include dir (NOT /usr/include, which would shadow newlib's stdio/etc. for the cross compiler).
RUN mkdir -p /opt/switch-cross-include/libdrm \
&& cp /usr/include/xf86drm.h /usr/include/xf86drmMode.h /opt/switch-cross-include/ 2>/dev/null || true \
&& cp -r /usr/include/libdrm/* /opt/switch-cross-include/ 2>/dev/null || true \
&& cp -r /usr/include/libdrm/* /opt/switch-cross-include/libdrm/ 2>/dev/null || true \
&& ls /opt/switch-cross-include/ | head
ENV LLVM_CONFIG=/usr/bin/llvm-config-15
# Make the build-machine CLC/SPIR-V deps visible to the Switch CROSS pkg-config + provide a stub
# libdl (Switch is static, no dlopen). mesa_clc is a host tool; these .pc's carry x86 paths (correct,
# the tool runs on the build machine). Baked here so cross-configure is self-contained.
RUN XDIR=/opt/devkitpro/portlibs/switch/lib/pkgconfig; mkdir -p "$XDIR"; \
for name in libclc LLVMSPIRVLib SPIRV-Tools SPIRV-Tools-shared SPIRV-Headers; do \
f=$(find /usr -name "$name.pc" 2>/dev/null | head -1); \
if [ -n "$f" ]; then cp "$f" "$XDIR/"; echo "baked $f"; fi; \
done; \
/opt/devkitpro/devkitA64/bin/aarch64-none-elf-ar rcs /opt/devkitpro/portlibs/switch/lib/libdl.a
# glslang (glslangValidator) to compile the M3 triangle's GLSL shaders -> SPIR-V.
RUN apt-get update && apt-get install -y --no-install-recommends glslang-tools \
&& rm -rf /var/lib/apt/lists/* && glslangValidator --version
# Pillow + a TTF font, to rasterise the credits/logo text into an RGBA texture at
# build time (gen-logo-image.py -> embedded logo_image.h). DejaVu is a free font.
RUN apt-get update && apt-get install -y --no-install-recommends fonts-dejavu-core \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m pip install --break-system-packages --no-cache-dir pillow