diff options
| author | coco875 <59367621+coco875@users.noreply.github.com> | 2025-12-08 16:49:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-08 08:49:21 -0700 |
| commit | 5b79a1c9106bd1d327d624362620cba1fe4cc674 (patch) | |
| tree | 3bc089a2af7a56c4de11e42ef10318e828c2fa14 /script | |
| parent | b2479390ba7d0facf9bafcfe862d29ff03798671 (diff) | |
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
Diffstat (limited to 'script')
| -rw-r--r-- | script/Dockerfile | 52 | ||||
| -rwxr-xr-x | script/build-release.sh | 56 | ||||
| -rw-r--r-- | script/check_type_yamls.py | 42 | ||||
| -rwxr-xr-x | script/valgrind_callgrind.sh | 2 |
4 files changed, 152 insertions, 0 deletions
diff --git a/script/Dockerfile b/script/Dockerfile new file mode 100644 index 000000000..ebfe509cf --- /dev/null +++ b/script/Dockerfile @@ -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 diff --git a/script/build-release.sh b/script/build-release.sh new file mode 100755 index 000000000..084b8c3c2 --- /dev/null +++ b/script/build-release.sh @@ -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" diff --git a/script/check_type_yamls.py b/script/check_type_yamls.py new file mode 100644 index 000000000..5ad5edb41 --- /dev/null +++ b/script/check_type_yamls.py @@ -0,0 +1,42 @@ +import os +import yaml + +def enumerate_yaml_files(directory): + """Recursively enumerate all YAML files in the given directory.""" + for root, dirs, files in os.walk(directory): + for filename in files: + if filename.endswith(".yaml") or filename.endswith(".yml"): + yield os.path.join(root, filename) + +folder_path = "yamls/us" + +def is_models(element): + """Check if the element is a gfx or vtx type.""" + return element.get("type").lower() in ["gfx", "vtx", "mk64:course_vtx", "blob"] + +def is_textures(element): + """Check if the element is a texture type.""" + return element.get("type").lower() == "texture" + +def is_other(element): + """Check if the element is of any other type.""" + return element.get("type").lower() not in ["gfx", "vtx", "texture", "mk64:course_vtx"] + +def check_element_type(directory, fun): + """Check the type of elements in YAML files.""" + for yaml_file in enumerate_yaml_files(directory): + with open(yaml_file, 'r') as file: + try: + data = yaml.safe_load(file) + assert isinstance(data, dict), "YAML file must contain a dictionary" + for key, value in data.items(): + if key == ":config": + continue + if not fun(value): + print(f"Element '{key}' in {yaml_file} does not match the expected type") + except yaml.YAMLError as e: + print(f"Error parsing {yaml_file}: {e}") + +check_element_type(os.path.join(folder_path, "models"), is_models) +check_element_type(os.path.join(folder_path, "textures"), is_textures) +check_element_type(os.path.join(folder_path, "other"), is_other)
\ No newline at end of file diff --git a/script/valgrind_callgrind.sh b/script/valgrind_callgrind.sh new file mode 100755 index 000000000..cd0345d73 --- /dev/null +++ b/script/valgrind_callgrind.sh @@ -0,0 +1,2 @@ +timeout 2m valgrind --tool=callgrind --callgrind-out-file=spaghetti.out ./build/Spaghettify +callgrind_annotate spaghetti.out > spaghetti_bench.out
\ No newline at end of file |
