Skip to content
Draft
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
12 changes: 9 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# do not ignore .git, needed for versioning
!/.git

# do not ignore .rstcheck.cfg, needed to test building docs
!/.rstcheck.cfg

# ignore repo directories and files
docker/
gh-pages-template/
Expand All @@ -20,7 +17,16 @@ crowdin.yml
# ignore dev directories
build/
cmake-*/
node_modules/
venv/

# ignore pre-built deps for other platforms
third-party/build-deps/dist/Darwin*
third-party/build-deps/dist/FreeBSD*
third-party/build-deps/dist/Windows*

# ignore non Linux third-party submodules
third-party/TPCircularBuffer

# ignore artifacts
artifacts/
10 changes: 0 additions & 10 deletions .rstcheck.cfg

This file was deleted.

55 changes: 55 additions & 0 deletions cmake/toolchains/aarch64-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CMake toolchain file for cross-compiling to ARM64 (aarch64) on Debian/Ubuntu
# Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/aarch64-linux-gnu.cmake

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# Use GCC version from environment variable if available
if(DEFINED ENV{LINUX_GCC_VERSION}) # cmake-lint: disable=W0106
set(LINUX_GCC_VERSION "-$ENV{LINUX_GCC_VERSION}")
else()
set(LINUX_GCC_VERSION "") # default to no version suffix
endif()

# Set compiler prefix and target
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET})

# Which compilers to use for C and C++
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION})
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++${LINUX_GCC_VERSION})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION})

# Here is the target environment located
set(CMAKE_FIND_ROOT_PATH
/usr/${CMAKE_C_COMPILER_TARGET}
/usr/lib/${CMAKE_C_COMPILER_TARGET}
/usr/include/${CMAKE_C_COMPILER_TARGET}
)

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# OpenSSL hints for cross-compilation
set(OPENSSL_ROOT_DIR /usr/${CMAKE_C_COMPILER_TARGET})
set(OPENSSL_INCLUDE_DIR /usr/include/${CMAKE_C_COMPILER_TARGET})
set(OPENSSL_CRYPTO_LIBRARY /usr/lib/${CMAKE_C_COMPILER_TARGET}/libcrypto.so)
set(OPENSSL_SSL_LIBRARY /usr/lib/${CMAKE_C_COMPILER_TARGET}/libssl.so)

# Configure pkg-config for cross-compilation
set(ENV{PKG_CONFIG_PATH} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig")
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig:/usr/share/pkgconfig")
set(ENV{PKG_CONFIG_SYSROOT_DIR} "/")

# Use the cross-compilation pkg-config if available
find_program(PKG_CONFIG_EXECUTABLE NAMES ${CMAKE_C_COMPILER_TARGET}-pkg-config pkg-config)
if(PKG_CONFIG_EXECUTABLE)
set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE})
endif()

# Packaging
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
49 changes: 49 additions & 0 deletions cmake/toolchains/x86_64-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# CMake toolchain file for cross-compiling to x86_64 on Debian/Ubuntu
# Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/x86_64-linux-gnu.cmake

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# Use GCC version from environment variable if available
if(DEFINED ENV{LINUX_GCC_VERSION}) # cmake-lint: disable=W0106
set(LINUX_GCC_VERSION "-$ENV{LINUX_GCC_VERSION}")
else()
set(LINUX_GCC_VERSION "") # default to no version suffix
endif()

# Set compiler prefix and target
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET})

# Which compilers to use for C and C++
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION})
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++${LINUX_GCC_VERSION})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION})

# Here is the target environment located
set(CMAKE_FIND_ROOT_PATH
/usr/${CMAKE_C_COMPILER_TARGET}
/usr/lib/${CMAKE_C_COMPILER_TARGET}
/usr/include/${CMAKE_C_COMPILER_TARGET}
)

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Configure pkg-config for cross-compilation
set(ENV{PKG_CONFIG_PATH} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig")
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig:/usr/share/pkgconfig")
set(ENV{PKG_CONFIG_SYSROOT_DIR} "/")

# Use the cross-compilation pkg-config if available
find_program(PKG_CONFIG_EXECUTABLE NAMES ${CMAKE_C_COMPILER_TARGET}-pkg-config pkg-config)
if(PKG_CONFIG_EXECUTABLE)
set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE})
endif()

# Packaging
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
117 changes: 106 additions & 11 deletions docker/debian-trixie.dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# syntax=docker/dockerfile:1
# artifacts: true
# platforms: linux/amd64,linux/arm64/v8
# platforms_pr: linux/amd64
# no-cache-filters: sunshine-base,artifacts,sunshine
# platforms_pr: linux/arm64/v8
# no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine
ARG BASE=debian
ARG TAG=trixie
FROM ${BASE}:${TAG} AS sunshine-base

ENV DEBIAN_FRONTEND=noninteractive

FROM sunshine-base AS sunshine-deps
# Dependencies stage - runs on build platform but installs deps for target platform
FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps

ENV DEBIAN_FRONTEND=noninteractive

# Pass through build arguments
ARG BUILDPLATFORM
ARG TARGETPLATFORM

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand All @@ -18,21 +25,66 @@ WORKDIR /build/sunshine/
COPY --link scripts/linux_build.sh ./scripts/linux_build.sh
COPY --link packaging/linux/patches/ ./packaging/linux/patches/

# Install dependencies first - this layer will be cached
# Install dependencies first - this layer will be cached per target platform
RUN <<_DEPS
#!/bin/bash
set -e
chmod +x ./scripts/linux_build.sh

echo "BUILDPLATFORM: ${BUILDPLATFORM}"
echo "TARGETPLATFORM: ${TARGETPLATFORM}"

# Set up cross-compilation variables if building for different platform
if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then
cross_compile="--cross-compile"
case "${TARGETPLATFORM}" in
linux/amd64)
target_arch="amd64"
target_tuple="x86_64-linux-gnu"
;;
linux/arm64)
target_arch="arm64"
target_tuple="aarch64-linux-gnu"
;;
*)
echo "Unsupported target platform: ${TARGETPLATFORM}"
exit 1
;;
esac

# Enable multiarch support for cross-compilation
dpkg --add-architecture ${target_arch}
apt-get update

echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}"
echo "Target arch: ${target_arch}, Target triple: ${target_tuple}"
else
cross_compile=""
target_arch=$(dpkg --print-architecture)
target_tuple=""
echo "Native compilation for ${TARGETPLATFORM}"
fi

echo "Running dependency installation step for ${TARGETPLATFORM}..."
./scripts/linux_build.sh \
--step=deps \
--cuda-patches \
--sudo-off
--sudo-off \
--use-aptitude \
${cross_compile} \
${target_arch:+--target-arch=${target_arch}} \
${target_tuple:+--target-tuple=${target_tuple}}

echo "Cleaning up package cache..."
apt-get clean
rm -rf /var/lib/apt/lists/*
echo "Dependency installation completed for ${TARGETPLATFORM}."
_DEPS

FROM sunshine-deps AS sunshine-build
FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build

ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
Expand All @@ -49,28 +101,71 @@ COPY --link .. .
RUN <<_BUILD
#!/bin/bash
set -e

# Set up cross-compilation variables if building for different platform
if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then
cross_compile="--cross-compile"
case "${TARGETPLATFORM}" in
linux/amd64)
target_arch="amd64"
target_tuple="x86_64-linux-gnu"
;;
linux/arm64)
target_arch="arm64"
target_tuple="aarch64-linux-gnu"
;;
*)
echo "Unsupported target platform: ${TARGETPLATFORM}"
exit 1
;;
esac
echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}"
else
cross_compile=""
target_arch=""
target_tuple=""
echo "Native compilation for ${TARGETPLATFORM}"
fi

./scripts/linux_build.sh \
--step=cmake \
--publisher-name='LizardByte' \
--publisher-website='https://app.lizardbyte.dev' \
--publisher-issue-url='https://app.lizardbyte.dev/support' \
--sudo-off
--sudo-off \
${cross_compile} \
${target_arch:+--target-arch=${target_arch}} \
${target_tuple:+--target-tuple=${target_tuple}}

./scripts/linux_build.sh \
--step=validation \
--sudo-off
--sudo-off \
${cross_compile} \
${target_arch:+--target-arch=${target_arch}} \
${target_tuple:+--target-tuple=${target_tuple}}

./scripts/linux_build.sh \
--step=build \
--sudo-off
--sudo-off \
${cross_compile} \
${target_arch:+--target-arch=${target_arch}} \
${target_tuple:+--target-tuple=${target_tuple}}

./scripts/linux_build.sh \
--step=package \
--sudo-off
--sudo-off \
${cross_compile} \
${target_arch:+--target-arch=${target_arch}} \
${target_tuple:+--target-tuple=${target_tuple}}
_BUILD

# run tests
FROM sunshine-build AS sunshine-test

# This stage runs on the target architecture to avoid qemu overhead for tests
ARG TARGETPLATFORM

WORKDIR /build/sunshine/build/tests

RUN <<_TEST
#!/bin/bash
set -e
Expand Down
Loading
Loading