Improve cmake, make release need less dependancy and clean up some file (#584)

* Update CMakeLists.txt

* try something to use less dependancy

* improve script

* Delete addr_to_sym.py

* restore dockerfile

* move the docker for release and a script to execute it to script

* Delete build.sh

* move more script to script folder

* add the new docker in the CI

* Update vcpkg.json

* fix windows and macos in theory
This commit is contained in:
coco875 2025-12-08 16:49:21 +01:00 committed by GitHub
parent b2479390ba
commit 5b79a1c910
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 294 additions and 39 deletions

View File

@ -54,3 +54,84 @@ jobs:
name: spaghetti-linux-x64-${{ matrix.config }}
path: spaghetti-${{ matrix.config }}
retention-days: 1
build-docker:
runs-on: ubuntu-latest
strategy:
matrix:
config: [Release]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('script/Dockerfile', 'vcpkg.json') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./script/Dockerfile
push: false
load: true
tags: spaghettikart-builder:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Build project in Docker
run: |
docker run --rm \
-v "${{ github.workspace }}:/project" \
spaghettikart-builder:latest \
bash -c "
cp vcpkg.json /tmp/vcpkg.json && \
cd /tmp && \
\${VCPKG_ROOT}/vcpkg install --triplet x64-linux && \
cd /project && \
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
-DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux && \
cmake --build build --parallel
"
- name: Generate AppImage
run: |
docker run --rm \
-v "${{ github.workspace }}:/project" \
spaghettikart-builder:latest \
bash -c "
cd /project/build && \
cpack -G External || true
"
- name: Create Package
run: |
mkdir -p spaghetti-${{ matrix.config }}
cp build/Spaghettify spaghetti-${{ matrix.config }}/ || true
wget -O gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt
mv gamecontrollerdb.txt spaghetti-${{ matrix.config }}/
cp build/*.appimage spaghetti-${{ matrix.config }}/ 2>/dev/null || true
- name: Publish packaged artifacts
uses: actions/upload-artifact@v4
with:
name: spaghetti-linux-docker-x64-${{ matrix.config }}
path: spaghetti-${{ matrix.config }}
retention-days: 7
# Workaround for cache growing too large
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true

View File

@ -126,7 +126,7 @@ jobs:
build-macos-intel:
needs: generate-port-o2r
runs-on: macOS-13
runs-on: macOS-latest-intel
strategy:
matrix:
config: [Release, Debug]
@ -344,18 +344,6 @@ jobs:
run: |
cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }}
cmake --build build-cmake --config ${{ matrix.config }} -j3
(cd build-cmake && cpack -G External)
wget -O gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt
mv README.md readme.txt
mv build-cmake/*.appimage spaghetti.appimage
- name: Upload build
if: matrix.config == 'Release'
uses: actions/upload-artifact@v4
with:
name: spaghetti-linux-x64
path: |
spaghetti.appimage
gamecontrollerdb.txt
build-linux-docker:
needs: generate-port-o2r
@ -383,6 +371,87 @@ jobs:
- name: Build spaghetti
run: docker run --rm -v ${PWD}:/project spaghetti cmake --build build-cmake --config ${{ matrix.config }} -j$(nproc)
build-docker:
runs-on: ubuntu-latest
strategy:
matrix:
config: [Release]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('script/Dockerfile', 'vcpkg.json') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./script/Dockerfile
push: false
load: true
tags: spaghettikart-builder:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Build project in Docker
run: |
docker run --rm \
-v "${{ github.workspace }}:/project" \
spaghettikart-builder:latest \
bash -c "
cp vcpkg.json /tmp/vcpkg.json && \
cd /tmp && \
\${VCPKG_ROOT}/vcpkg install --triplet x64-linux && \
cd /project && \
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
-DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux && \
cmake --build build --parallel
"
- name: Generate AppImage
run: |
docker run --rm \
-v "${{ github.workspace }}:/project" \
spaghettikart-builder:latest \
bash -c "
cd /project/build && \
cpack -G External || true
"
- name: Create Package
run: |
mkdir -p spaghetti-${{ matrix.config }}
cp build/Spaghettify spaghetti-${{ matrix.config }}/ || true
wget -O gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt
mv gamecontrollerdb.txt spaghetti-${{ matrix.config }}/
cp build/*.appimage spaghetti-${{ matrix.config }}/ 2>/dev/null || true
- name: Publish packaged artifacts
uses: actions/upload-artifact@v4
with:
name: spaghetti-linux-x64
path: spaghetti-${{ matrix.config }}
# Workaround for cache growing too large
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true
build-switch:
needs: generate-port-o2r
runs-on: ubuntu-latest

1
.gitignore vendored
View File

@ -128,3 +128,4 @@ cmake-build-*/
build*/
.DS_Store
.cache/
_packages/

View File

@ -173,6 +173,10 @@ else()
set(CMAKE_CXX_FLAGS_DEBUG "-g -DNDEBUG ${COMMON_CXX_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG ${COMMON_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${COMMON_CXX_FLAGS}")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG ${COMMON_C_FLAGS}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG ${COMMON_CXX_FLAGS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG ${COMMON_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG ${COMMON_CXX_FLAGS}")
endif()
# Set game compilation version

View File

@ -1,20 +0,0 @@
import re
# Define the regex query to match the hex values
regex_query = r'0x07[0-9a-fA-F]{6}'
# Define a function to process each match
def process_match(match):
offset = int(match.group(0)[4:], 16)
return f"d_course_big_donut_packed_dl_{hex(offset)[2:].upper()}"
# Open the input file
with open("courses/big_donut/packed.inc.c", "r") as f:
# Read the file contents
file_content = f.read()
# Use re.sub() to find and replace all matches in the file content
modified_content = re.sub(regex_query, process_match, file_content)
# Print the modified content to console
print(modified_content)

52
script/Dockerfile Normal file
View File

@ -0,0 +1,52 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV VCPKG_ROOT=/opt/vcpkg
ENV PATH="${VCPKG_ROOT}:${PATH}"
# Install base dependencies
RUN apt-get update -y && apt-get -y upgrade && \
apt-get -y install \
build-essential \
gcc \
g++ \
git \
ninja-build \
curl \
zip \
unzip \
tar \
pkg-config \
wget \
file \
autoconf \
automake \
libtool \
python3 \
libx11-dev \
libxrandr-dev \
libxi-dev \
libxinerama-dev \
libxcursor-dev \
libgl1-mesa-dev \
libopengl-dev \
libwayland-dev \
libxkbcommon-dev \
libasound2-dev \
libpulse-dev \
libudev-dev \
libdbus-1-dev
# Install CMake 4.0.3
ENV DOCKER_CMAKE_VERSION="4.0.3"
RUN wget https://github.com/Kitware/CMake/releases/download/v${DOCKER_CMAKE_VERSION}/cmake-${DOCKER_CMAKE_VERSION}-linux-x86_64.sh && \
chmod +x cmake-${DOCKER_CMAKE_VERSION}-linux-x86_64.sh && \
./cmake-${DOCKER_CMAKE_VERSION}-linux-x86_64.sh --prefix=/usr/local --skip-license && \
rm cmake-${DOCKER_CMAKE_VERSION}-linux-x86_64.sh
# Install vcpkg
RUN git clone https://github.com/microsoft/vcpkg.git ${VCPKG_ROOT} && \
cd ${VCPKG_ROOT} && \
./bootstrap-vcpkg.sh -disableMetrics
WORKDIR /project

56
script/build-release.sh Executable file
View File

@ -0,0 +1,56 @@
#!/bin/bash
set -e
# Script to build SpaghettiKart using Docker
# Usage: ./docker/build.sh [Release|Debug]
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
BUILD_TYPE="${1:-Release}"
BUILD_DIR="build-docker"
IMAGE_NAME="spaghettikart-builder"
USER_ID=$(id -u)
GROUP_ID=$(id -g)
cd "$PROJECT_DIR"
# Build Docker image
echo "Building Docker image..."
docker build -t "${IMAGE_NAME}" -f script/Dockerfile .
# Clean build directory if it contains incompatible cache
if [[ -f "${BUILD_DIR}/CMakeCache.txt" ]] && grep -q "/home/coco" "${BUILD_DIR}/CMakeCache.txt" 2>/dev/null; then
echo "Cleaning incompatible build cache..."
rm -rf "${BUILD_DIR}"
fi
# Run build in Docker
echo "Building in Docker container..."
docker run --rm \
-v "$(pwd):/project" \
-e BUILD_TYPE="${BUILD_TYPE}" \
-e USER_ID="${USER_ID}" \
-e GROUP_ID="${GROUP_ID}" \
"${IMAGE_NAME}" \
bash -c "
# Copy vcpkg.json and install dependencies
cp vcpkg.json /tmp/vcpkg.json && \
cd /tmp && \
\${VCPKG_ROOT}/vcpkg install --triplet x64-linux && \
cd /project && \
cmake -B ${BUILD_DIR} -G Ninja \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux && \
cmake --build ${BUILD_DIR} --parallel && \
cp -f spaghetti.o2r ${BUILD_DIR}/ 2>/dev/null || true && \
cp -f mk64.o2r ${BUILD_DIR}/ 2>/dev/null || true && \
cd ${BUILD_DIR} && cpack -G External && \
chown -R ${USER_ID}:${GROUP_ID} /project/${BUILD_DIR} /project/logs 2>/dev/null || true
"
echo ""
echo "Build complete!"
echo "Executable: ${BUILD_DIR}/Spaghettify"
ls -1 "${BUILD_DIR}"/*.appimage 2>/dev/null && echo "AppImage generated successfully!" || echo "Note: AppImage generation may have failed"

View File

@ -166,8 +166,8 @@ GameEngine::GameEngine() {
{ BTN_DDOWN, "DDown" },
});
auto controlDeck = std::make_shared<LUS::ControlDeck>(std::vector<CONTROLLERBUTTONS_T>(), defaultMappings, buttonNames);
this->context->InitResourceManager({}, {}, 3); // without this line InitWindow fails in Gui::Init()
const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs("spaghetti.o2r");
this->context->InitResourceManager({assets_path}, {}, 3); // without this line InitWindow fails in Gui::Init()
this->context->InitConsole(); // without this line the GuiWindow constructor fails in ConsoleWindow::InitElement()
auto gui = std::make_shared<Ship::SpaghettiGui>(std::vector<std::shared_ptr<Ship::GuiWindow>>({}));
@ -176,7 +176,7 @@ GameEngine::GameEngine() {
// auto wnd = std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({}));
// auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
this->context->Init({}, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck);
this->context->Init({assets_path}, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck);
#ifndef __SWITCH__
Ship::Context::GetInstance()->GetLogger()->set_level(

View File

@ -1 +0,0 @@
"c:\Program Files\Blender Foundation\Blender 4.0\blender.exe" -b --python tools/blender_extension/blender_export.py -- courses/dks_jungle_parkway/course_data.inc.c d_course_dks_jungle_parkway_dl_E058

View File

@ -8,7 +8,20 @@
"bzip2",
"libzip",
"libpng",
"sdl2",
{
"name": "sdl2",
"features": ["x11", "alsa", "wayland"],
"platform": "linux",
"default-features": false
},
{
"name": "sdl2",
"platform": "windows"
},
{
"name": "sdl2",
"platform": "osx"
},
"sdl2-net",
"glew",
"glfw3",