diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 728cc53..ff195de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,68 +4,83 @@ on: workflow_dispatch: jobs: - #osx-x64: - #osx-arm64: - win-x64: - runs-on: windows-2022 + osx-x64: + runs-on: macos-13 steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - - name: bootstrap vcpkg - run: ./vcpkg/bootstrap-vcpkg.bat + - name: Install Deps + run: brew install ninja - - name: build vcpkg packages - run: ./windows/build-vcpkg.ps1 x64-windows win-x64 + - name: Build + run: python ./scripts/osx.py - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: win-x64 - path: builds/win-x64/*.dll + name: osx-x64 + path: artifacts + if-no-files-found: error - win-arm64: - runs-on: windows-2022 + linux-x64: + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - - name: bootstrap vcpkg - run: ./vcpkg/bootstrap-vcpkg.bat + - uses: docker/build-push-action@v2 + with: + tags: native-build:latest + file: scripts/linux-build-env.Dockerfile + push: false - - name: build vcpkg packages - run: ./windows/build-vcpkg.ps1 arm64-windows win-arm64 + - uses: addnab/docker-run-action@v3 + with: + image: native-build:latest + run: python /work/scripts/linux.py + options: -v ${{ github.workspace }}:/work - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: win-arm64 - path: builds/win-arm64/*.dll + name: linux-x64 + path: artifacts + if-no-files-found: error + + win-x64: + runs-on: windows-2022 + env: + VCPKG_DEFAULT_TRIPLET: x64-windows-release + VCPKG_DEFAULT_HOST_TRIPLET: x64-windows-release + VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed - linux-x64: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - - name: bootstrap vcpkg - run: ./vcpkg/bootstrap-vcpkg.sh + - name: Install Deps + shell: cmd + run: choco install ninja --limit-output --no-progress - - name: create build container - run: | - cd linux - ./build-build-env.sh + - name: Install VCPkg dependencies + uses: lukka/run-vcpkg@v11 + with: + runVcpkgInstall: true + vcpkgJsonGlob: 'vcpkg.json' - - name: build vcpkg packages + - name: Build + shell: cmd run: | - cd linux - ./build-vcpkg.sh x64-linux-dynamic linux-x64 + call "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\VsDevCmd.bat" -arch=x64 -host_arch=x64 + python ./scripts/windows.py - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: linux-x64 - path: builds/linux-x64/*.so* + name: win-x64 + path: artifacts + if-no-files-found: error diff --git a/.gitignore b/.gitignore index 11246a5..80a5dcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ builds/ build/ .DS_Store +artifacts +__pycache__ +vcpkg_installed diff --git a/README.md b/README.md new file mode 100644 index 0000000..9735abc --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# SS14 Native-Build + +A collection of submodules providing dependencies for building [Space Station 14](https://github.com/space-wizards/space-station-14). + +Building is handled through the `Build Natives` workflow action and relies on Github's runners to perform the actual compilation. +Local building is possible by running your platform's python file under the [scripts](./scripts/) directory. Though you will need to make sure you have all dependencies setup to actually build. Consult the [workflow](./.github/workflows/build.yml) file for your platform and see what's installed from the `Install Deps` step. + +Each platform produces an zip file containing all relevant shared libs for it, any debug symbols, and a `notes.md` giving information on where and what commit the code came from. diff --git a/build_freetype_macos.ps1 b/build_freetype_macos.ps1 deleted file mode 100755 index 5ea60c3..0000000 --- a/build_freetype_macos.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env pwsh - -if (test-path builds/freetype) -{ - write-host "removing previous build directory" - remove-item -recurse builds/freetype -} - -new-item -itemtype directory builds/freetype | Out-Null - -push-location builds/freetype - -cmake ../../freetype -DCMAKE_RELEASE_TYPE=Release -DBUILD_SHARED_LIBS=true -$procCount = [Environment]::ProcessorCount -make "-j$procCount" - -pop-location \ No newline at end of file diff --git a/linux/.gitignore b/linux/.gitignore deleted file mode 100644 index c795b05..0000000 --- a/linux/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build \ No newline at end of file diff --git a/linux/__build-glfw-openal.sh b/linux/__build-glfw-openal.sh deleted file mode 100755 index 9e85c10..0000000 --- a/linux/__build-glfw-openal.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# This script is used internally in the Docker container. -# Don't run it directly. Run build-glfw-openal-linux.ps1 instead - -cd /opt - -# Build GLFW. -pushd glfw -mkdir build -cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -make -j $(nproc) -popd - -# Build OpenAL. -pushd openal-soft -mkdir build -cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -make -j $(nproc) -popd - -# Build FluidSynth -pushd fluidsynth -mkdir build -cd build -cmake .. -DCMAKE_BUILD_TYPE=Release \ --Denable-aufile=OFF -Denable-dbus=OFF -Denable-ipv6=OFF -Denable-jack=OFF -Denable-ladspa=OFF \ --Denable-libsndfile=OFF -Denable-midishare=OFF -Denable-network=OFF -Denable-oss=OFF -Denable-sdl2=OFF -Denable-pulseaudio=OFF -Denable-readline=OFF \ --Denable-lash=OFF -make -j $(nproc) -popd - diff --git a/linux/__build-sdl.sh b/linux/__build-sdl.sh deleted file mode 100755 index 6f542f6..0000000 --- a/linux/__build-sdl.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -cd /opt/linux - -mkdir -p build/sdl - -cd build/sdl - -cmake ../../../SDL/ \ - -DCMAKE_BUILD_TYPE=Release \ - -DSDL_STATIC=OFF \ - -DSDL_SHARED=ON \ - -DSDL_TEST=OFF - -make -j $(nproc) - diff --git a/linux/__build-zstd.sh b/linux/__build-zstd.sh deleted file mode 100755 index 57998a0..0000000 --- a/linux/__build-zstd.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -cd /opt/linux - -mkdir build/ -mkdir build/zstd - -cd build/zstd - -cmake ../../../zstd/build/cmake \ - -DZSTD_BUILD_SHARED=ON \ - -DZSTD_BUILD_STATIC=OFF \ - -DZSTD_BUILD_PROGRAMS=OFF \ - -DZSTD_BUILD_TESTS=OFF \ - -DZSTD_MULTITHREAD_SUPPORT=ON \ - -DZSTD_BUILD_CONTRIB=OFF \ - -DZSTD_LEGACY_SUPPORT=OFF \ - -DCMAKE_BUILD_TYPE=Release - -make -j $(nproc) - diff --git a/linux/build-build-env.sh b/linux/build-build-env.sh deleted file mode 100755 index ca401dd..0000000 --- a/linux/build-build-env.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker build -t ss14-native-build:1.0 -f build-env.Dockerfile . diff --git a/linux/build-glfw-openal-linux.ps1 b/linux/build-glfw-openal-linux.ps1 deleted file mode 100755 index 01a16b4..0000000 --- a/linux/build-glfw-openal-linux.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env pwsh - -# Make sure to run build-build-env.ps1 first to build the Docker container. - -Set-Location .. - -docker run --rm -v "${pwd}:/opt" ss14-native-build:1.0 "/bin/bash" "/opt/linux/__build-glfw-openal.sh" - -new-item -Force -itemtype Directory builds/glfw/ -new-item -Force -itemtype Directory builds/openal/ -new-item -Force -itemtype Directory builds/fluidsynth/ - -copy-item glfw/build/src/libglfw.so.3.3 builds/glfw/libglfw.so -copy-item openal-soft/build/libopenal.so.1.20.1 builds/openal/libopenal.so -copy-item fluidsynth/build/src/libfluidsynth.so.2.3.3 builds/fluidsynth/libfluidsynth.so - diff --git a/linux/build-sdl.ps1 b/linux/build-sdl.ps1 deleted file mode 100755 index 982153b..0000000 --- a/linux/build-sdl.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env pwsh - -docker run --rm -v "${pwd}/..:/opt" ss14-native-build:1.0 "/bin/bash" "/opt/linux/__build-sdl.sh" - -new-item -Force -itemtype Directory ../builds/sdl/ -copy-item build/sdl/libSDL2-2.0.so ../builds/sdl/ - diff --git a/linux/build-vcpkg.sh b/linux/build-vcpkg.sh deleted file mode 100755 index 1d89a92..0000000 --- a/linux/build-vcpkg.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Build all vcpkg-provided packages on Windows. - -TRIPLET=$1 -RID=$2 - -docker run --rm -v "$(pwd)/..:/opt" ss14-native-build:1.0 /opt/vcpkg/vcpkg install --triplet "$TRIPLET" "sdl2[vulkan]" "openal-soft" "freetype[core]" "glfw3" - -TO_COPY=("libSDL2-2.0.so.0" "libfreetype.so.6" "libglfw.so.3" "libopenal.so.1") - -mkdir -p "../builds/$RID" - -for native in ${TO_COPY[@]}; do - cp "../vcpkg/installed/$TRIPLET/lib/$native" "../builds/$RID/$native" -done diff --git a/linux/build-zstd.ps1 b/linux/build-zstd.ps1 deleted file mode 100755 index 3b4f951..0000000 --- a/linux/build-zstd.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env pwsh - -docker run --rm -v "${pwd}/..:/opt" ss14-native-build:1.0 "/bin/bash" "/opt/linux/__build-zstd.sh" - -new-item -Force -itemtype Directory ../builds/zstd/ -copy-item build/zstd/lib/libzstd.so ../builds/zstd/ - diff --git a/macos/.gitignore b/macos/.gitignore deleted file mode 100644 index c795b05..0000000 --- a/macos/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build \ No newline at end of file diff --git a/macos/build-sdl.sh b/macos/build-sdl.sh deleted file mode 100755 index c70ced8..0000000 --- a/macos/build-sdl.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -set -e - -mkdir -p "build/sdl/" -pushd "build/sdl" - -mkdir "arm64" -mkdir "x64" - -( - # ARM64 build - cmake -S ../../../SDL/ -B arm64 \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=11 \ - -DCMAKE_OSX_ARCHITECTURES=arm64 \ - -DSDL_STATIC=OFF \ - -DSDL_SHARED=ON \ - -DSDL_TEST=OFF - - cmake --build arm64 --parallel -) & - -( - # x64 build - cmake -S ../../../SDL/ -B x64 \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \ - -DCMAKE_OSX_ARCHITECTURES=x86_64 \ - -DSDL_STATIC=OFF \ - -DSDL_SHARED=ON \ - -DSDL_TEST=OFF - - cmake --build x64 --parallel -) & - -wait - -popd - -mkdir -p builds/sdl/osx-arm64 -mkdir -p builds/sdl/osx-x64 - -cp build/sdl/arm64/libSDL2-2.0.0.dylib builds/sdl/osx-arm64/ -cp build/sdl/x64/libSDL2-2.0.0.dylib builds/sdl/osx-x64/ \ No newline at end of file diff --git a/macos/build-zstd.sh b/macos/build-zstd.sh deleted file mode 100755 index 99173fa..0000000 --- a/macos/build-zstd.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -mkdir build/ -mkdir build/zstd - -pushd build/zstd - -cmake ../../../zstd/build/cmake \ - -DZSTD_BUILD_SHARED=ON \ - -DZSTD_BUILD_STATIC=OFF \ - -DZSTD_BUILD_PROGRAMS=OFF \ - -DZSTD_BUILD_TESTS=OFF \ - -DZSTD_MULTITHREAD_SUPPORT=ON \ - -DZSTD_BUILD_CONTRIB=OFF \ - -DZSTD_LEGACY_SUPPORT=OFF \ - -DCMAKE_BUILD_TYPE=Release - -# I don't know how to do nproc on mac and this 10 year old iMac has 4 cores so have fun. -make -j 4 - -popd - -mkdir ../builds -mkdir ../builds/zstd -mkdir ../builds/zstd/osx-x64 -cp build/zstd/lib/libzstd.dylib ../builds/zstd/osx-x64/libzstd.dylib - diff --git a/scripts/common.py b/scripts/common.py new file mode 100644 index 0000000..de011b5 --- /dev/null +++ b/scripts/common.py @@ -0,0 +1,140 @@ +from abc import abstractmethod +from pathlib import Path +from enum import Enum +import platform as _platform # Python gets confused with similar names here +import shutil +import subprocess +import sys + +SCRIPT_DIR = Path(__file__).resolve().parent +ROOT_DIR = SCRIPT_DIR.parent +BUILD_DIR = ROOT_DIR.joinpath("build") +ARTIFACT_DIR = ROOT_DIR.joinpath("artifacts") + + +class Platform(Enum): + Windows = (1,) + Linux = (2,) + OSX = (3,) + + @staticmethod + def get() -> "Platform": + platform = _platform.system() + if platform == "Windows": + return Platform.Windows + elif platform == "Linux": + return Platform.Linux + elif platform == "Darwin": + return Platform.OSX + else: + raise RuntimeError(f"Unknown platform {platform}") + + +class Github: + @staticmethod + def log(msg: str) -> None: + print(msg, flush=True) + + @staticmethod + def notice(msg: str) -> None: + print(f"::notice::{msg}", flush=True) + + @staticmethod + def warning(msg: str) -> None: + print(f"::warning::{msg}", flush=True) + + @staticmethod + def error(msg: str) -> None: + print(f"::error::{msg}", flush=True) + + @staticmethod + def bail(msg: str) -> None: + Github.error(msg) + sys.exit(1) + + class LogGroup: + def __init__(self, msg: str) -> None: + self.msg = msg + + def __enter__(self) -> None: + print(f"::group::{self.msg}", flush=True) + + def __exit__(self, type, value, traceback) -> None: + print(f"::endgroup::", flush=True) + + +def dump_build_notes(name: str, working_dir: Path, output: Path, contents: list[str]): + # Check if the source directory is a git one, if so we can add some cool + # git information to the output directory for storage later. + try: + remote = subprocess.check_output( + ["git", "remote", "get-url", "origin"], text=True, cwd=working_dir + ).strip() + commit_hash = subprocess.check_output( + ["git", "rev-parse", "HEAD"], text=True, cwd=working_dir + ).strip() + + note_text = f"""# {name} + +Compiled from `{remote}`:`{commit_hash}` + +Contains: + +""" + note_text += "\n".join(contents) + output.write_text(note_text) + + except Exception as e: + # Not a git directory or some other failure, don't need to fail anything though + Github.notice( + f"Skipping git information for {working_dir} due to exception: {e}" + ) + pass + + +class Software: + def __init__(self, name: str, dir: str) -> None: + self.name = name + self.source_dir: Path = ROOT_DIR.joinpath(dir) + self.dest_dir: Path = BUILD_DIR.joinpath(dir) + if self.dest_dir.exists(): + shutil.rmtree(self.dest_dir) + self.dest_dir.mkdir(exist_ok=True, parents=True) + + self.publish_dir = ARTIFACT_DIR.joinpath(self.name) + if self.publish_dir.exists(): + shutil.rmtree(self.publish_dir) + self.publish_dir.mkdir(exist_ok=True, parents=True) + + self.outputs: dict[str, list[str]] = [] + self.tools: dict[str, Path] = {} + + @abstractmethod + def build(self) -> None: + pass + + def publish(self) -> None: + os = Platform.get() + if os not in self.outputs.keys(): + Github.bail(f"Unknown platform {os}, unable to handle outputs") + + for output in self.outputs[os]: + output_path = self.dest_dir.joinpath( + output + ).resolve() # Ensure we have resolved symlinks + if not output_path.exists(): + Github.bail(f"Failed to find output [{output_path}]") + continue # Shouldn't be hit, but leaving this here anyway + + # Since output_path might have changed (due to symlinks), re-use the expected + # output name here + new_path = self.publish_dir.joinpath(Path(output).name) + Github.log(f"[{output_path}] => [{new_path}]") + output_path.rename(new_path) + + dump_build_notes( + self.name, + self.source_dir, + self.publish_dir.joinpath("notes.md"), + [f"- {self.dest_dir.joinpath(output).name}" for output in self.outputs[os]], + ) diff --git a/linux/build-env.Dockerfile b/scripts/linux-build-env.Dockerfile similarity index 66% rename from linux/build-env.Dockerfile rename to scripts/linux-build-env.Dockerfile index 58586f8..c72192c 100644 --- a/linux/build-env.Dockerfile +++ b/scripts/linux-build-env.Dockerfile @@ -1,8 +1,21 @@ -FROM ubuntu:20.04 - -RUN apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends xorg-dev gcc build-essential git make cmake libpulse-dev libasound-dev zip tar curl unzip ca-certificates -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libglib2.0-dev -# SDL2 dependencies -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential git make autoconf automake libtool pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev -RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y +FROM ubuntu:20.04 + +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends xorg-dev gcc build-essential git make cmake libpulse-dev libasound-dev zip tar curl unzip ca-certificates +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libglib2.0-dev +# SDL2 dependencies +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential git make autoconf automake libtool pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev +RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y + +# Python setup +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3-openssl libssl-dev +ENV HOME="/root" +WORKDIR $HOME +RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv +ENV PYENV_ROOT="$HOME/.pyenv" +ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH" +RUN pyenv install 3.11 +RUN pyenv global 3.11 + +# Remove dubious ownership check from git +RUN git config --global --add safe.directory '*' diff --git a/scripts/linux.py b/scripts/linux.py new file mode 100644 index 0000000..8a840aa --- /dev/null +++ b/scripts/linux.py @@ -0,0 +1,48 @@ +#!/bin/bash python3 +from software.zstd import ZStd +from software.glfw import GLFW +from software.sdl import SDL +from software.openal import OpenAL +from software.fluidsynth import Fluidsynth + +from common import Github, Software, dump_build_notes, ARTIFACT_DIR, Platform, ROOT_DIR + +import subprocess + +if __name__ == "__main__": + to_build: list[Software] = [ + ZStd(), + GLFW(), + SDL(), + OpenAL(), + Fluidsynth(), + ] + + for build in to_build: + with Github.LogGroup(f"Building {build.name}"): + build.build() + + # Strip debug information out per build's outputs + new_outputs = [] + for output_name in build.outputs[Platform.Linux]: + Github.log(f"Moving debug information for {output_name}") + debug_name = f"{output_name}.debug" + subprocess.call( + [ + "objcopy", + "--only-keep-debug", + str(build.dest_dir.joinpath(output_name)), + str(build.dest_dir.joinpath(debug_name)), + ] + ) + new_outputs.append(debug_name) + build.outputs[Platform.Linux].extend(new_outputs) + + build.publish() + + dump_build_notes( + "native-build (Linux x64)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in to_build], + ) diff --git a/scripts/osx.py b/scripts/osx.py new file mode 100644 index 0000000..dc46c35 --- /dev/null +++ b/scripts/osx.py @@ -0,0 +1,31 @@ +#!/bin/bash python3 +from software.zstd import ZStd +from software.glfw import GLFW +from software.sdl import SDL +from software.openal import OpenAL +from software.freetype import Freetype +from software.fluidsynth import Fluidsynth + +from common import Github, Software, dump_build_notes, ARTIFACT_DIR, ROOT_DIR + +if __name__ == "__main__": + to_build: list[Software] = [ + ZStd(), + GLFW(), + SDL(), + OpenAL(), + Freetype(), + Fluidsynth(), + ] + + for build in to_build: + with Github.LogGroup(f"Building {build.name}"): + build.build() + build.publish() + + dump_build_notes( + "native-build (OSX x64)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in to_build], + ) diff --git a/scripts/software/fluidsynth.py b/scripts/software/fluidsynth.py new file mode 100644 index 0000000..2f4876f --- /dev/null +++ b/scripts/software/fluidsynth.py @@ -0,0 +1,85 @@ +#!/bin/bash python3 + +import os +import subprocess +import shutil +from common import Software, Github, Platform, ROOT_DIR + + +class Fluidsynth(Software): + def __init__(self) -> None: + super().__init__("Fluidsynth", "fluidsynth") + + self.outputs = { + Platform.Windows: ["src/fluidsynth.lib", "src/fluidsynth.pdb"], + Platform.Linux: ["src/libfluidsynth.so"], + Platform.OSX: ["src/FluidSynth.framework"], + } + + def build(self) -> None: + cmake = shutil.which("cmake") + + Github.log("Setting up CMake...") + generation_args = [ + cmake, + f"-B{self.dest_dir}", + "-GNinja", + "-Denable-aufile=OFF", + "-Denable-dbus=OFF", + "-Denable-ipv6=OFF", + "-Denable-jack=OFF", + "-Denable-ladspa=OFF", + "-Denable-libsndfile=OFF", + "-Denable-midishare=OFF", + "-Denable-network=OFF", + "-Denable-oss=OFF", + "-Denable-sdl2=OFF", + "-Denable-pulseaudio=OFF", + "-Denable-readline=OFF", + "-Denable-lash=OFF", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ] + + generation_env = os.environ.copy() + + if Platform.get() == Platform.Windows: + vc_install_dir = ROOT_DIR.joinpath("vcpkg_installed/x64-windows-release") + tools_directories = [ + str(vc_install_dir.joinpath("tools/pkgconf")), + str(vc_install_dir.joinpath("lib")), + ] + + generation_args += [ + "-DCMAKE_WARN_DEPRECATED=Off", # So much spam from the vcpkg.cmake file + f"-DCMAKE_TOOLCHAIN_FILE={os.getenv('VCPKG_ROOT')}/scripts/buildsystems/vcpkg.cmake", + f"-DCMAKE_PROGRAM_PATH={';'.join(tools_directories)}", + ] + + generation_env["PKG_CONFIG_PATH"] = str( + vc_install_dir.joinpath("lib\\pkgconfig") + ) + + result = subprocess.call( + generation_args, text=True, cwd=self.source_dir, env=generation_env + ) + if result != 0: + Github.bail("Failed to setup CMake") + + Github.log("Building up CMake...") + subprocess.call( + [ + cmake, + "--build", + ".", + ], + text=True, + cwd=self.dest_dir, + ) + if result != 0: + Github.bail("Failed to build") + + +if __name__ == "__main__": + library = Fluidsynth() + library.build() + library.publish() diff --git a/scripts/software/freetype.py b/scripts/software/freetype.py new file mode 100644 index 0000000..334841a --- /dev/null +++ b/scripts/software/freetype.py @@ -0,0 +1,56 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import Software, Github, Platform + + +class Freetype(Software): + def __init__(self) -> None: + super().__init__("Freetype", "freetype") + + self.outputs = { + Platform.Windows: [ + "freetype.dll", + "freetype.pdb", + ], + Platform.Linux: ["libfreetype.so"], + Platform.OSX: ["libfreetype.dylib"], + } + + def build(self) -> None: + cmake = shutil.which("cmake") + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + f"-B{self.dest_dir}", + "-GNinja", + "-DBUILD_SHARED_LIBS=On", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ], + text=True, + cwd=self.source_dir, + ) + if result != 0: + Github.bail("Failed to setup CMake") + + Github.log("Building up CMake...") + subprocess.call( + [ + cmake, + "--build", + ".", + ], + text=True, + cwd=self.dest_dir, + ) + if result != 0: + Github.bail("Failed to build") + + +if __name__ == "__main__": + library = Freetype() + library.build() + library.publish() diff --git a/scripts/software/glfw.py b/scripts/software/glfw.py new file mode 100644 index 0000000..824998b --- /dev/null +++ b/scripts/software/glfw.py @@ -0,0 +1,54 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import Software, Github, Platform + + +class GLFW(Software): + def __init__(self) -> None: + super().__init__("GLFW", "glfw") + + self.outputs = { + Platform.Windows: [ + "src/glfw3.dll", + "src/glfw3.pdb", + ], + Platform.Linux: ["src/libglfw.so"], + Platform.OSX: ["src/libglfw.dylib"], + } + + def build(self) -> None: + cmake = shutil.which("cmake") + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + f"-B{self.dest_dir}", + "-GNinja", + "-DBUILD_SHARED_LIBS=On", + "-DGLFW_BUILD_EXAMPLES=Off", + "-DGLFW_BUILD_TESTS=Off", + "-DGLFW_BUILD_DOCS=Off", + "-DGLFW_INSTALL=Off", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ], + text=True, + cwd=self.source_dir, + ) + if result != 0: + Github.bail("Failed to setup CMake") + + Github.log("Building up CMake...") + subprocess.call( + [ + cmake, + "--build", + ".", + ], + text=True, + cwd=self.dest_dir, + ) + if result != 0: + Github.bail("Failed to build") diff --git a/scripts/software/openal.py b/scripts/software/openal.py new file mode 100644 index 0000000..a03379e --- /dev/null +++ b/scripts/software/openal.py @@ -0,0 +1,53 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import Software, Github, Platform + + +class OpenAL(Software): + def __init__(self) -> None: + super().__init__("OpenAL-Soft", "openal-soft") + + self.outputs = { + Platform.Windows: [ + "OpenAL32.dll", + "OpenAL32.pdb", + ], + Platform.Linux: ["libopenal.so"], + Platform.OSX: ["libopenal.dylib"], + } + + def build(self) -> None: + cmake = shutil.which("cmake") + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + f"-B{self.dest_dir}", + "-GNinja", + "-DALSOFT_UTILS=Off", + "-DALSOFT_EXAMPLES=Off", + "-DALSOFT_TESTS=Off", + "-DALSOFT_INSTALL=Off", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ], + text=True, + cwd=self.source_dir, + ) + if result != 0: + Github.bail("Failed to setup CMake") + + Github.log("Building up CMake...") + subprocess.call( + [ + cmake, + "--build", + ".", + ], + text=True, + cwd=self.dest_dir, + ) + if result != 0: + Github.bail("Failed to build") diff --git a/scripts/software/sdl.py b/scripts/software/sdl.py new file mode 100644 index 0000000..e8cbfe6 --- /dev/null +++ b/scripts/software/sdl.py @@ -0,0 +1,56 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import Software, Github, Platform + + +class SDL(Software): + def __init__(self) -> None: + super().__init__("SDL", "SDL") + + self.outputs = { + Platform.Windows: [ + "SDL2.dll", + "SDL2.pdb", + ], + Platform.Linux: ["libSDL2-2.0.so"], + Platform.OSX: ["libSDL2-2.0.dylib"], + } + + def build(self) -> None: + cmake = shutil.which("cmake") + + cmake_args = [ + cmake, + f"-B{self.dest_dir}", + "-GNinja", + "-DSDL_SHARED=On", + "-DSDL_STATIC=Off", + "-DSDL_WERROR=Off", + "-DSDL_TESTS=Off", + "-DSDL_INSTALL_TESTS=Off", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ] + + Github.log("Setting up CMake...") + result = subprocess.call( + cmake_args, + text=True, + cwd=self.source_dir, + ) + if result != 0: + Github.bail("Failed to setup CMake") + + Github.log("Building up CMake...") + subprocess.call( + [ + cmake, + "--build", + ".", + ], + text=True, + cwd=self.dest_dir, + ) + if result != 0: + Github.bail("Failed to build") diff --git a/scripts/software/zstd.py b/scripts/software/zstd.py new file mode 100644 index 0000000..5dbc04d --- /dev/null +++ b/scripts/software/zstd.py @@ -0,0 +1,57 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import Software, Github, Platform + + +class ZStd(Software): + def __init__(self) -> None: + super().__init__("zstd", "zstd") + + self.outputs = { + Platform.Windows: [ + "lib/zstd.dll", + "lib/zstd.pdb", + ], + Platform.Linux: ["lib/libzstd.so"], + Platform.OSX: ["lib/libzstd.dylib"], + } + + def build(self) -> None: + cmake = shutil.which("cmake") + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + "build/cmake", + f"-B{self.dest_dir}", + "-GNinja", + "-DZSTD_BUILD_SHARED=ON", + "-DZSTD_BUILD_STATIC=OFF", + "-DZSTD_BUILD_PROGRAMS=OFF", + "-DZSTD_BUILD_TESTS=OFF", + "-DZSTD_MULTITHREAD_SUPPORT=ON", + "-DZSTD_BUILD_CONTRIB=OFF", + "-DZSTD_LEGACY_SUPPORT=OFF", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ], + text=True, + cwd=self.source_dir, + ) + if result != 0: + Github.bail("Failed to setup CMake") + + Github.log("Building up CMake...") + subprocess.call( + [ + cmake, + "--build", + ".", + ], + text=True, + cwd=self.dest_dir, + ) + if result != 0: + Github.bail("Failed to build") diff --git a/scripts/windows.py b/scripts/windows.py new file mode 100644 index 0000000..2a99f44 --- /dev/null +++ b/scripts/windows.py @@ -0,0 +1,36 @@ +#!/bin/bash python3 +from software.zstd import ZStd +from software.glfw import GLFW +from software.sdl import SDL +from software.openal import OpenAL +from software.fluidsynth import Fluidsynth +from software.freetype import Freetype + +from common import Github, Software, dump_build_notes, ARTIFACT_DIR, ROOT_DIR + +if __name__ == "__main__": + to_build: list[Software] = [ + Fluidsynth(), + ZStd(), + GLFW(), + SDL(), + OpenAL(), + Freetype(), + ] + + # We expect vcpkg_installed to exist on system, else Fluidsynth is going to fail + vcpkg_dir = ROOT_DIR.joinpath("vcpkg_installed") + if not vcpkg_dir.exists(): + Github.notice("VCPkgs are not installed to {vcpkg_dir}, some builds may fail") + + for build in to_build: + with Github.LogGroup(f"Building {build.name}"): + build.build() + build.publish() + + dump_build_notes( + "native-build (Windows x64)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in to_build], + ) diff --git a/vcpkg b/vcpkg index 36fb233..d5ec528 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 36fb23307e10cc6ffcec566c46c4bb3f567c82c6 +Subproject commit d5ec528843d29e3a52d745a64b469f810b2cedbf diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..ba06dad --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,14 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "2960d7d80e8d09c84ae8abf15c12196c2ca7d39a", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..75e4cf4 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "dependencies": [ + { + "name": "glib", + "version>=": "2.80.0" + }, + "pkgconf" + ] +} diff --git a/windows/.gitignore b/windows/.gitignore deleted file mode 100644 index c795b05..0000000 --- a/windows/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build \ No newline at end of file diff --git a/windows/build-vcpkg.ps1 b/windows/build-vcpkg.ps1 deleted file mode 100644 index 7ec2d03..0000000 --- a/windows/build-vcpkg.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -# Build all vcpkg-provided packages on Windows. - -param( - [Parameter(Position = 0, mandatory = $true)] - [string]$triplet, - - [Parameter(Position = 1, mandatory = $true)] - [string]$rid -) - -Push-Location $(Join-Path $PSScriptRoot "..") - -vcpkg\vcpkg.exe install --triplet $triplet "sdl2[vulkan]" "openal-soft" "freetype[core]" "glfw3" - -$files_to_copy = @("glfw3.dll", "SDL2.dll", "OpenAL32.dll", "freetype.dll") -New-Item -ItemType Directory -Force "builds" -New-Item -ItemType Directory -Force "builds\$rid" - -$files_to_copy | ForEach-Object { - Copy-Item "vcpkg\installed\$triplet\bin\$_" "builds\$rid\$_" -} diff --git a/windows/build_zstd.ps1 b/windows/build_zstd.ps1 deleted file mode 100644 index d7f71b6..0000000 --- a/windows/build_zstd.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -# Run from VS 2015 native tools (x64) - -$dir = New-Item -Force -ItemType Directory build/zstd -Push-Location $dir - -cmake ../../../zstd/build/cmake ` - -GNinja ` - -DZSTD_BUILD_SHARED=ON ` - -DZSTD_BUILD_STATIC=OFF ` - -DZSTD_BUILD_PROGRAMS=OFF ` - -DZSTD_BUILD_TESTS=OFF ` - -DZSTD_MULTITHREAD_SUPPORT=ON ` - -DZSTD_BUILD_CONTRIB=OFF ` - -DZSTD_LEGACY_SUPPORT=OFF ` - -DCMAKE_BUILD_TYPE=Release - -cmake --build . - -$dest = New-Item -Force -ItemType Directory ../../../builds/zstd -Copy-Item lib/zstd.dll $dest - -Pop-Location \ No newline at end of file