diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..241e560 --- /dev/null +++ b/.containerignore @@ -0,0 +1,2 @@ +* + diff --git a/.editorconfig b/.editorconfig index c84336e..e19f8f7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,7 @@ root = true +[*] +insert_final_newline = true + [*.sh] end_of_line = lf \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 526c8a3..176a458 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -*.sh text eol=lf \ No newline at end of file +* text=auto diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 728cc53..26c4a2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,68 +4,162 @@ on: workflow_dispatch: jobs: - #osx-x64: - #osx-arm64: - win-x64: - runs-on: windows-2022 + osx-x64: + runs-on: macos-15 steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - - name: bootstrap vcpkg - run: ./vcpkg/bootstrap-vcpkg.bat + - name: Bootstrap vcpkg + run: vcpkg/bootstrap-vcpkg.sh - - name: build vcpkg packages - run: ./windows/build-vcpkg.ps1 x64-windows win-x64 + - name: Vcpkg install + run: vcpkg/vcpkg install --triplet=x64-osx - - uses: actions/upload-artifact@v3 + - name: Build + run: python ./scripts/osx.py --rid osx-x64 + + - 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 + osx-arm64: + runs-on: macos-15 steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - - name: bootstrap vcpkg - run: ./vcpkg/bootstrap-vcpkg.bat + - name: Bootstrap vcpkg + run: vcpkg/bootstrap-vcpkg.sh + + - name: Vcpkg install + run: vcpkg/vcpkg install --triplet=arm64-osx - - name: build vcpkg packages - run: ./windows/build-vcpkg.ps1 arm64-windows win-arm64 + - name: Build + run: python ./scripts/osx.py --rid osx-arm64 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: win-arm64 - path: builds/win-arm64/*.dll + name: osx-arm64 + path: artifacts + if-no-files-found: error linux-x64: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Build server environment + run: docker build -t build-env-server -f linux-build-env-server.Containerfile . + + - name: Build client environment + run: docker build -t build-env-client -f linux-build-env-client.Containerfile . + + - name: Run server build + run: docker run --rm -v ${{ github.workspace }}:/work build-env-server /work/scripts/linux-server.py + + - name: Run client build + run: docker run --rm -v ${{ github.workspace }}:/work build-env-client /work/scripts/linux-from-container.sh linux-x64 x64-linux + + - uses: actions/upload-artifact@v4 + with: + name: linux-x64 + path: artifacts + if-no-files-found: error + + linux-arm64: + runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - - name: bootstrap vcpkg - run: ./vcpkg/bootstrap-vcpkg.sh + - name: Build server environment + run: docker build -t build-env-server -f linux-build-env-server.Containerfile . - - name: create build container + - name: Build client environment + run: docker build -t build-env-client -f linux-build-env-client-arm64.Containerfile . + + - name: Run server build + run: docker run --rm -v ${{ github.workspace }}:/work build-env-server /work/scripts/linux-server.py + + - name: Run client build + run: docker run --rm -v ${{ github.workspace }}:/work build-env-client /work/scripts/linux-from-container.sh linux-arm64 arm64-linux + + - uses: actions/upload-artifact@v4 + with: + name: linux-arm64 + path: artifacts + if-no-files-found: error + + win-x64: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Install Deps + shell: cmd + run: choco install ninja --limit-output --no-progress + + - name: Bootstrap vcpkg + run: vcpkg/bootstrap-vcpkg.bat + + - name: Vcpkg install + run: vcpkg/vcpkg.exe install --triplet=x64-windows + + - name: Build + shell: cmd run: | - cd linux - ./build-build-env.sh + call "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\VsDevCmd.bat" -arch=x64 -host_arch=x64 + python ./scripts/windows.py --rid=win-x64 - - name: build vcpkg packages + - uses: actions/upload-artifact@v4 + with: + name: win-x64 + path: artifacts + if-no-files-found: error + + win-arm64: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Install Deps + shell: cmd + run: choco install ninja --limit-output --no-progress + + - name: Bootstrap vcpkg + run: vcpkg/bootstrap-vcpkg.bat + + - name: Vcpkg install + run: vcpkg/vcpkg.exe install --triplet=arm64-windows + + - 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=arm64 -host_arch=x64 + python ./scripts/windows.py --rid=win-arm64 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: linux-x64 - path: builds/linux-x64/*.so* + name: win-arm64 + 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/.gitmodules b/.gitmodules index 6f610ad..a0fde93 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,10 +7,6 @@ [submodule "glfw"] path = glfw url = https://github.com/glfw/glfw.git -[submodule "fluidsynth"] - path = fluidsynth - url = https://github.com/FluidSynth/fluidsynth.git - [submodule "vcpkg"] path = vcpkg url = https://github.com/microsoft/vcpkg.git diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5bacf27 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.analysis.typeCheckingMode": "standard" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..a520bfa --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# SS14 Native-Build + +A collection of submodules providing dependencies for building [Space Station 14](https://github.com/space-wizards/space-station-14) and [RobustToolbox](https://github.com/space-wizards/RobustToolbox). + +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. + +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. + +## Building manually + +You should always start by running `git submodule update --init` to initialize the source code directories. + +Note that these instructions will not necessarily allow building "clean" binaries that are suitably shippable to end users. For example, Linux builds are normally ran in a container to have a clean environment. + +### Windows + +Ensure you have the following things installed & available in PATH: + +* MSVC +* Ninja +* CMake +* Python 3 + +To do the build, open up a command prompt set up for compiling with MSVC (by running e.g. `x64 Native Tools Command Prompt for VS 2022`) and then run the following commands: + +``` +vcpkg/bootstrap-vcpkg.bat +vcpkg/vcpkg.exe install + +scripts/windows.py +``` + +The built files will be in `artifacts/`. + +### macOS + +Ensure you have the following things installed & available in PATH: + +* XCode +* Ninja +* CMake +* Python 3 + +To do the build, open up a terminal and run the following commands: + +``` +vcpkg/bootstrap-vcpkg.sh +vcpkg/vcpkg install + +scripts/osx.py +``` + +The built files will be in `artifacts/`. + +### Linux + +Ensure you have the following things installed & available in PATH: + +* A crapload of dependencies. Check the docs of the libraries we're using and keep installing `-dev` packages until it builds. +* Ninja +* CMake +* Python 3 + +To do the build, open up a terminal and run the following commands: + +``` +vcpkg/bootstrap-vcpkg.sh +vcpkg/vcpkg install + +scripts/linux-server.py +scripts/linux.py +``` + +The built files will be in `artifacts/`. diff --git a/SDL b/SDL index adf31f6..96292a5 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit adf31f6ec0be0f9ba562889398f71172c7941023 +Subproject commit 96292a5b464258a2b926e0a3d72f8b98c2a81aa6 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/fluidsynth b/fluidsynth deleted file mode 160000 index 19a20eb..0000000 --- a/fluidsynth +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 19a20eb8526465fdf940b740b13462d71e190a1a diff --git a/freetype b/freetype index 0aef708..e0d36aa 160000 --- a/freetype +++ b/freetype @@ -1 +1 @@ -Subproject commit 0aef708a382a21295174ae5971c4d65b9f6f10e6 +Subproject commit e0d36aa902913c64c36efacb611d1b9e085d45ac diff --git a/glfw b/glfw index 0a49ef0..7b6aead 160000 --- a/glfw +++ b/glfw @@ -1 +1 @@ -Subproject commit 0a49ef0a00baa3ab520ddc452f0e3b1e099c5589 +Subproject commit 7b6aead9fb88b3623e3b3725ebb42670cbe4c579 diff --git a/linux-build-env-client-arm64.Containerfile b/linux-build-env-client-arm64.Containerfile new file mode 100644 index 0000000..28684b6 --- /dev/null +++ b/linux-build-env-client-arm64.Containerfile @@ -0,0 +1,4 @@ +FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk/arm64 + +# Remove dubious ownership check from git +RUN git config --global --add safe.directory '*' diff --git a/linux-build-env-client.Containerfile b/linux-build-env-client.Containerfile new file mode 100644 index 0000000..a58a775 --- /dev/null +++ b/linux-build-env-client.Containerfile @@ -0,0 +1,4 @@ +FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk + +# Remove dubious ownership check from git +RUN git config --global --add safe.directory '*' diff --git a/linux-build-env-server.Containerfile b/linux-build-env-server.Containerfile new file mode 100644 index 0000000..a9fd942 --- /dev/null +++ b/linux-build-env-server.Containerfile @@ -0,0 +1,17 @@ +FROM ubuntu:18.04 + +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gcc build-essential git make cmake ca-certificates curl ninja-build pkg-config + +# Python setup +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends zlib1g zlib1g-dev libssl-dev libbz2-dev libsqlite3-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/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-env.Dockerfile b/linux/build-env.Dockerfile deleted file mode 100644 index 58586f8..0000000 --- a/linux/build-env.Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -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 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/openal-soft b/openal-soft index f5e0eef..dc7d705 160000 --- a/openal-soft +++ b/openal-soft @@ -1 +1 @@ -Subproject commit f5e0eef34db3a3ab94b61a2f99f84f078ba947e7 +Subproject commit dc7d7054a5b4f3bec1dc23a42fd616a0847af948 diff --git a/scripts/common/__init__.py b/scripts/common/__init__.py new file mode 100644 index 0000000..575cb97 --- /dev/null +++ b/scripts/common/__init__.py @@ -0,0 +1,8 @@ +from .github import Github +from .software import Software, SoftwareImpl, filter_software_to_build, SoftwareOutput +from .platform import Platform, Architecture +from .helpers import dump_build_notes +from .paths import * +from .args import parse_args, BuildArgs +from .cmake import CmakeSoftware +from .vcpkg import VcpkgSoftware diff --git a/scripts/common/args.py b/scripts/common/args.py new file mode 100644 index 0000000..cf7e78c --- /dev/null +++ b/scripts/common/args.py @@ -0,0 +1,20 @@ +import argparse +from dataclasses import dataclass +from typing import Optional + +from .platform import Rid, get_host_rid + +@dataclass +class BuildArgs: + rid: Rid + software: Optional[set[str]] + +def parse_args(default_rid: Optional[Rid] = None) -> BuildArgs: + default_rid = default_rid or get_host_rid() + parser = argparse.ArgumentParser() + parser.add_argument("--rid", default=default_rid) + parser.add_argument("--software", nargs="*") + + args = parser.parse_args() + + return BuildArgs(Rid(args.rid), set(args.software or []) or None) diff --git a/scripts/common/cmake.py b/scripts/common/cmake.py new file mode 100644 index 0000000..c56bae5 --- /dev/null +++ b/scripts/common/cmake.py @@ -0,0 +1,37 @@ +import shutil + +from .platform import Architecture, Platform +from .osx import DEPLOYMENT_TARGET +from .args import BuildArgs +from .software import SelfBuiltSoftware + + +def locate_cmake() -> str: + path = shutil.which("cmake") + if path is None: + raise RuntimeError("Unable to locate cmake!") + + return path + + +def cmake_common_args(args: BuildArgs) -> list[str]: + cmake_args = [ + "-GNinja", + f"-DCMAKE_OSX_DEPLOYMENT_TARGET={DEPLOYMENT_TARGET}", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo" + ] + arch = Architecture.from_rid(args.rid) + if arch == Architecture.X64: + cmake_args.append(f"-DCMAKE_OSX_ARCHITECTURES=x86_64") + elif arch == Architecture.Arm64: + cmake_args.append(f"-DCMAKE_OSX_ARCHITECTURES=arm64") + + platform = Platform.from_rid(args.rid) + if platform == Platform.Linux: + cmake_args.append(f"-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-Bsymbolic") + + return cmake_args + + +class CmakeSoftware(SelfBuiltSoftware): + pass diff --git a/scripts/common/github.py b/scripts/common/github.py new file mode 100644 index 0000000..9c2be2d --- /dev/null +++ b/scripts/common/github.py @@ -0,0 +1,33 @@ +import sys + +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) diff --git a/scripts/common/helpers.py b/scripts/common/helpers.py new file mode 100644 index 0000000..0f700b6 --- /dev/null +++ b/scripts/common/helpers.py @@ -0,0 +1,48 @@ +import subprocess +import shutil +import errno +import os + +from pathlib import Path +from typing import Union + +from .github import Github + +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 + + +StrPath = Union[str, os.PathLike] + +# https://stackoverflow.com/a/1994840 +def copy_file_or_tree(src: StrPath, dst: StrPath): + try: + shutil.copytree(src, dst) + except OSError as exc: # python >2.5 + if exc.errno in (errno.ENOTDIR, errno.EINVAL): + shutil.copy(src, dst) diff --git a/scripts/common/linux.py b/scripts/common/linux.py new file mode 100644 index 0000000..54030e3 --- /dev/null +++ b/scripts/common/linux.py @@ -0,0 +1,34 @@ +import subprocess + +from .platform import Platform +from .software import Software, SoftwareOutput +from .github import Github + +def separate_debug_info(build: Software): + # Strip debug information out per build's outputs + new_outputs = [] + for output in build.outputs[Platform.Linux]: + output_name = SoftwareOutput.get_dst_name(output) + Github.log(f"Moving debug information for {output_name}") + debug_name = f"{output_name}.debug" + subprocess.run( + [ + "objcopy", + "--only-keep-debug", + str(build.publish_dir.joinpath(output_name)), + str(build.publish_dir.joinpath(debug_name)), + ], + check=True + ) + + subprocess.run( + [ + "strip", + str(build.publish_dir.joinpath(output_name)), + ], + check=True + ) + new_outputs.append(debug_name) + + + build.outputs[Platform.Linux].extend(new_outputs) diff --git a/scripts/common/osx.py b/scripts/common/osx.py new file mode 100644 index 0000000..97a8c95 --- /dev/null +++ b/scripts/common/osx.py @@ -0,0 +1 @@ +DEPLOYMENT_TARGET = 13 diff --git a/scripts/common/paths.py b/scripts/common/paths.py new file mode 100644 index 0000000..ded5094 --- /dev/null +++ b/scripts/common/paths.py @@ -0,0 +1,9 @@ +from pathlib import Path + +SCRIPT_DIR = Path(__file__).resolve().parent +ROOT_DIR = SCRIPT_DIR.parent.parent +BUILD_DIR = ROOT_DIR.joinpath("build") +ARTIFACT_DIR = ROOT_DIR.joinpath("artifacts") +VCPKG_INSTALLED_DIR = ROOT_DIR / "vcpkg_installed" + +__all__ = ["SCRIPT_DIR", "ROOT_DIR", "BUILD_DIR", "ARTIFACT_DIR"] diff --git a/scripts/common/platform.py b/scripts/common/platform.py new file mode 100644 index 0000000..2fad912 --- /dev/null +++ b/scripts/common/platform.py @@ -0,0 +1,88 @@ +from typing import NewType +from enum import Enum, auto +import platform as _platform # Python gets confused with similar names here + +Rid = NewType('Rid', str) + +RID_WIN_X64 = Rid("win-x64") +RID_WIN_ARM64 = Rid("win-arm64") +RID_OSX_X64 = Rid("osx-x64") +RID_OSX_ARM64 = Rid("osx-arm64") +RID_LINUX_X64 = Rid("linux-x64") +RID_LINUX_ARM64 = Rid("linux-arm64") + + +def get_host_rid() -> Rid: + platform = _platform.system() + machine = _platform.machine() + + platform = _platform.system() + if platform == "Windows": + if machine == "arm64" or machine == "aarch64": + return RID_WIN_ARM64 + if machine == "AMD64" or machine == "x86_64": + return RID_WIN_X64 + elif platform == "Linux": + if machine == "arm64" or machine == "aarch64": + return RID_LINUX_ARM64 + if machine == "AMD64" or machine == "x86_64": + return RID_LINUX_X64 + elif platform == "Darwin": + if machine == "arm64" or machine == "aarch64": + return RID_OSX_ARM64 + if machine == "AMD64" or machine == "x86_64": + return RID_OSX_X64 + + raise RuntimeError(f"Unknown platform {platform}/{machine}") + + +class Architecture(Enum): + X64 = auto() + Arm64 = auto() + + @staticmethod + def from_rid(rid: Rid) -> "Architecture": + if "arm64" in rid: + return Architecture.Arm64 + if "x64" in rid: + return Architecture.X64 + raise ValueError(f"Unable to determine architecture from RID: {rid}") + + def get_vcpkg_arch(self) -> str: + if self == Architecture.X64: + return "x64" + if self == Architecture.Arm64: + return "arm64" + raise ValueError() + +class Platform(Enum): + Windows = (1,) + Linux = (2,) + OSX = (3,) + FreeBSD = (4,) + + @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}") + + @staticmethod + def from_rid(rid: Rid) -> "Platform": + start = rid.split("-", maxsplit=1)[0] + if start == "osx": + return Platform.OSX + elif start == "win": + return Platform.Windows + elif start == "linux": + return Platform.Linux + elif start == "freebsd": + return Platform.FreeBSD + else: + raise RuntimeError(f"Unknown rid {rid}") diff --git a/scripts/common/software.py b/scripts/common/software.py new file mode 100644 index 0000000..2611f51 --- /dev/null +++ b/scripts/common/software.py @@ -0,0 +1,136 @@ +import shutil +from dataclasses import dataclass +from abc import abstractmethod, ABCMeta +from pathlib import Path +from typing import Callable, Iterable, Union + +from .platform import Platform +from .github import Github +from .helpers import dump_build_notes, copy_file_or_tree +from .paths import * +from .args import BuildArgs + + +@dataclass +class SoftwareOutput: + src: str + dst: str + + def get_src(self: "SoftwareOutputLike") -> str: + if isinstance(self, SoftwareOutput): + return self.src + + if isinstance(self, str): + return self + + raise ValueError() + + def get_dst(self: "SoftwareOutputLike") -> str: + if isinstance(self, SoftwareOutput): + return self.dst + + if isinstance(self, str): + return self + + raise ValueError() + + def get_dst_name(self: "SoftwareOutputLike") -> str: + return Path(SoftwareOutput.get_dst(self)).name + + +SoftwareOutputLike = Union[str, SoftwareOutput] + + +def software_output_get_src(output: SoftwareOutputLike) -> str: + if output is str: + return Path(output).name + + if output is SoftwareOutput: + return Path(output.dst).name + + raise ValueError() + + +def software_output_get_name(output: SoftwareOutputLike) -> str: + if output is str: + return Path(output).name + + if output is SoftwareOutput: + return Path(output.dst).name + + raise ValueError() + + +class Software(metaclass=ABCMeta): + def __init__(self, build_args: BuildArgs, name: str, version: str) -> None: + self.name = name + self.version = version + + self.publish_dir = ARTIFACT_DIR.joinpath(self.name, self.version, build_args.rid) + if self.publish_dir.exists(): + shutil.rmtree(self.publish_dir) + self.publish_dir.mkdir(exist_ok=True, parents=True) + + self.outputs: dict[Platform, list[SoftwareOutputLike]] = {} + self.tools: dict[str, Path] = {} + self.build_args = build_args + + @abstractmethod + def build(self) -> None: + pass + + @abstractmethod + def publish(self) -> None: + pass + + +SoftwareImpl = Callable[[BuildArgs], Software] + + +def filter_software_to_build(software_available: Iterable[SoftwareImpl], build_args: BuildArgs) -> list[Software]: + softwares = [] + for software_type in software_available: + software = software_type(build_args) + if build_args.software is not None and software.name not in build_args.software: + continue + + softwares.append(software) + + return softwares + + +class SelfBuiltSoftware(Software): + def __init__(self, build_args: BuildArgs, name: str, version: str, dir: str) -> None: + super().__init__(build_args, name, version) + + self.source_dir: Path = ROOT_DIR.joinpath(dir) + self.dest_dir: Path = BUILD_DIR.joinpath(dir, build_args.rid) + if self.dest_dir.exists(): + shutil.rmtree(self.dest_dir) + self.dest_dir.mkdir(exist_ok=True, parents=True) + + 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( + SoftwareOutput.get_src(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 / SoftwareOutput.get_dst_name(output) + Github.log(f"[{output_path}] => [{new_path}]") + copy_file_or_tree(output_path, new_path) + + dump_build_notes( + f"{self.name} [{self.version}] (`{self.build_args}`)", + self.source_dir, + self.publish_dir.joinpath("notes.md"), + [f"- {SoftwareOutput.get_dst_name(output)}" for output in self.outputs[os]] + ) diff --git a/scripts/common/vcpkg.py b/scripts/common/vcpkg.py new file mode 100644 index 0000000..2d04c40 --- /dev/null +++ b/scripts/common/vcpkg.py @@ -0,0 +1,74 @@ +import shutil +import platform as _platform +from pathlib import Path + + +from . import platform as p +from .args import BuildArgs +from .software import Software, SoftwareOutput +from .platform import Platform, Rid, get_host_rid +from .github import Github +from .paths import VCPKG_INSTALLED_DIR, ROOT_DIR +from .helpers import dump_build_notes, copy_file_or_tree + + +# vcpkg triplets we're using to build stuff. +RID_TO_TRIPLET_MAP = { + p.RID_WIN_X64: "x64-windows", + p.RID_WIN_ARM64: "arm64-windows", + p.RID_OSX_X64: "x64-osx", + p.RID_OSX_ARM64: "arm64-osx", + p.RID_LINUX_X64: "x64-linux", + p.RID_LINUX_ARM64: "arm64-linux", +} + + +def vcpkg_triplet_for_rid(rid: Rid) -> str: + res = RID_TO_TRIPLET_MAP.get(rid) + if res is None: + raise RuntimeError(f"Unknown RID: '{rid}'") + + return res + + +def get_vcpkg_host_triplet() -> str: + return vcpkg_triplet_for_rid(get_host_rid()) + + +class VcpkgSoftware(Software): + def __init__(self, build_args: BuildArgs, name: str, version: str) -> None: + super().__init__(build_args, name, version) + + self.vcpkg_installed_dir = VCPKG_INSTALLED_DIR / vcpkg_triplet_for_rid(build_args.rid) + + def build(self) -> None: + # Assume vcpkg installed ahead of time. + # Idk maybe I'll change this later. + Github.log("Not building vcpkg directly, expect it to be done before running script") + + 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.vcpkg_installed_dir.joinpath( + SoftwareOutput.get_src(output) + ).resolve() # Ensure we have resolved symlinks + if not output_path.exists(): + Github.bail(f"Failed to find vcpkg 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 / SoftwareOutput.get_dst_name(output) + Github.log(f"[{output_path}] => [{new_path}]") + copy_file_or_tree(output_path, new_path) + + dump_build_notes( + f"{self.name} (`{self.build_args}`)", + ROOT_DIR, + self.publish_dir.joinpath("notes.md"), + [f"- {SoftwareOutput.get_dst_name(output)}" for output in self.outputs[os]] + ) + diff --git a/scripts/linux-from-container.sh b/scripts/linux-from-container.sh new file mode 100755 index 0000000..24ba05f --- /dev/null +++ b/scripts/linux-from-container.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -xeu + +cd /work + +vcpkg/bootstrap-vcpkg.sh +vcpkg/vcpkg install --triplet=$2 +scripts/linux.py --rid=$1 diff --git a/scripts/linux-server.py b/scripts/linux-server.py new file mode 100755 index 0000000..a96709c --- /dev/null +++ b/scripts/linux-server.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +from software.zstd import ZStd + +from common import Github, dump_build_notes, filter_software_to_build, ARTIFACT_DIR, ROOT_DIR +from common.software import SoftwareImpl +from common.args import parse_args +from common.linux import separate_debug_info + +if __name__ == "__main__": + args = parse_args() + + to_build: list[SoftwareImpl] = [ + ZStd, + ] + + build_softwares = filter_software_to_build(to_build, args) + + for build in build_softwares: + with Github.LogGroup(f"Building {build.name}"): + build.build() + build.publish() + + separate_debug_info(build) + + + dump_build_notes( + "native-build (Linux)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in build_softwares], + ) diff --git a/scripts/linux.py b/scripts/linux.py new file mode 100755 index 0000000..d42713f --- /dev/null +++ b/scripts/linux.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +from software.glfw import GLFW +from software.sdl import SDL +from software.openal import OpenAL +from software.fluidsynth import Fluidsynth + +from common import Github, dump_build_notes, filter_software_to_build, ARTIFACT_DIR, ROOT_DIR +from common.software import SoftwareImpl +from common.args import parse_args +from common.linux import separate_debug_info + + +if __name__ == "__main__": + args = parse_args() + + to_build: list[SoftwareImpl] = [ + GLFW, + SDL, + OpenAL, + Fluidsynth, + ] + + build_softwares = filter_software_to_build(to_build, args) + + for build in build_softwares: + with Github.LogGroup(f"Building {build.name}"): + build.build() + build.publish() + + separate_debug_info(build) + + dump_build_notes( + "native-build (Linux)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in build_softwares], + ) diff --git a/scripts/osx.py b/scripts/osx.py new file mode 100755 index 0000000..b190f10 --- /dev/null +++ b/scripts/osx.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import subprocess + +from pathlib import Path + +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, Platform, Software, filter_software_to_build, dump_build_notes, ARTIFACT_DIR, ROOT_DIR, SoftwareOutput +from common.software import SoftwareImpl +from common.args import parse_args + +if __name__ == "__main__": + args = parse_args() + to_build: list[SoftwareImpl] = [ + ZStd, + GLFW, + SDL, + OpenAL, + Freetype, + Fluidsynth, + ] + + build_softwares = filter_software_to_build(to_build, args) + + for build in build_softwares: + with Github.LogGroup(f"Building {build.name}"): + build.build() + build.publish() + + new_outputs = [] + for output in build.outputs[Platform.OSX]: + output_name = SoftwareOutput.get_dst_name(output) + Github.log(f"Moving debug information for {output_name}") + debug_name = f"{output_name}.dSYM" + subprocess.run( + [ + "dsymutil", + str(build.publish_dir.joinpath(output_name)), + ], + check=True + ) + subprocess.run( + [ + "strip", + "-S", + str(build.publish_dir.joinpath(output_name)), + ], + check=True + ) + + new_outputs.append(debug_name) + + build.outputs[Platform.OSX].extend(new_outputs) + + + dump_build_notes( + f"native-build (macOS)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in build_softwares], + ) diff --git a/scripts/software/angle.py b/scripts/software/angle.py new file mode 100644 index 0000000..9945654 --- /dev/null +++ b/scripts/software/angle.py @@ -0,0 +1,9 @@ +from common import VcpkgSoftware, Platform, BuildArgs + +class Angle(VcpkgSoftware): + def __init__(self, args: BuildArgs) -> None: + super().__init__(args, "ANGLE", "chromium_7258") + + self.outputs = { + Platform.Windows: ["bin/libEGL.dll", "bin/libEGL.pdb", "bin/libGLESv2.dll", "bin/libGLESv2.pdb"], + } diff --git a/scripts/software/fluidsynth.py b/scripts/software/fluidsynth.py new file mode 100644 index 0000000..f2725cb --- /dev/null +++ b/scripts/software/fluidsynth.py @@ -0,0 +1,13 @@ +#!/bin/bash python3 + +from common import VcpkgSoftware, Platform, BuildArgs + +class Fluidsynth(VcpkgSoftware): + def __init__(self, args: BuildArgs) -> None: + super().__init__(args, "Fluidsynth", "2.4.6") + + self.outputs = { + Platform.Windows: ["bin/libfluidsynth-3.dll", "bin/libfluidsynth-3.pdb"], + Platform.Linux: ["lib/libfluidsynth.so.3"], + Platform.OSX: ["lib/libfluidsynth.3.dylib"], + } diff --git a/scripts/software/freetype.py b/scripts/software/freetype.py new file mode 100644 index 0000000..f95cad5 --- /dev/null +++ b/scripts/software/freetype.py @@ -0,0 +1,53 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import CmakeSoftware, Github, Platform, SoftwareOutput +from common.cmake import cmake_common_args, locate_cmake +from common.args import BuildArgs + + +class Freetype(CmakeSoftware): + def __init__(self, args: BuildArgs) -> None: + super().__init__(args, "Freetype", "2.13.3", "freetype") + + self.outputs = { + Platform.Windows: [ + SoftwareOutput("freetype.dll", "freetype6.dll"), + SoftwareOutput("freetype.pdb", "freetype6.pdb"), + ], + Platform.Linux: ["libfreetype.so.6"], + Platform.OSX: ["libfreetype.6.dylib"], + } + + def build(self) -> None: + cmake = locate_cmake() + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + f"-B{self.dest_dir}", + "-DBUILD_SHARED_LIBS=On", + "-DFT_DISABLE_PNG=TRUE", + "-DFT_DISABLE_BROTLI=TRUE", + "-DFT_DISABLE_HARFBUZZ=TRUE", + ] + cmake_common_args(self.build_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/glfw.py b/scripts/software/glfw.py new file mode 100644 index 0000000..a831e7f --- /dev/null +++ b/scripts/software/glfw.py @@ -0,0 +1,54 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import CmakeSoftware, Github, Platform +from common.cmake import cmake_common_args, locate_cmake +from common.args import BuildArgs + + +class GLFW(CmakeSoftware): + def __init__(self, args: BuildArgs) -> None: + super().__init__(args, "GLFW", "3.4", "glfw") + + self.outputs = { + Platform.Windows: [ + "src/glfw3.dll", + "src/glfw3.pdb", + ], + Platform.Linux: ["src/libglfw.so.3"], + Platform.OSX: ["src/libglfw.3.dylib"], + } + + def build(self) -> None: + cmake = locate_cmake() + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + f"-B{self.dest_dir}", + "-DBUILD_SHARED_LIBS=On", + "-DGLFW_BUILD_EXAMPLES=Off", + "-DGLFW_BUILD_TESTS=Off", + "-DGLFW_BUILD_DOCS=Off", + "-DGLFW_INSTALL=Off", + ] + cmake_common_args(self.build_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/openal.py b/scripts/software/openal.py new file mode 100644 index 0000000..95201c9 --- /dev/null +++ b/scripts/software/openal.py @@ -0,0 +1,53 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import CmakeSoftware, Github, Platform +from common.cmake import cmake_common_args, locate_cmake +from common.args import BuildArgs + +class OpenAL(CmakeSoftware): + def __init__(self, args: BuildArgs) -> None: + super().__init__(args, "OpenAL-Soft", "1.24.3", "openal-soft") + + self.outputs = { + Platform.Windows: [ + "OpenAL32.dll", + "OpenAL32.pdb", + ], + Platform.Linux: ["libopenal.so.1"], + Platform.OSX: ["libopenal.1.dylib"], + } + + def build(self) -> None: + cmake = locate_cmake() + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + f"-B{self.dest_dir}", + "-DALSOFT_UTILS=Off", + "-DALSOFT_EXAMPLES=Off", + "-DALSOFT_TESTS=Off", + "-DALSOFT_INSTALL=Off", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ] + cmake_common_args(self.build_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/sdl.py b/scripts/software/sdl.py new file mode 100644 index 0000000..8dfbaea --- /dev/null +++ b/scripts/software/sdl.py @@ -0,0 +1,59 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import CmakeSoftware, Github, Platform +from common.cmake import cmake_common_args, locate_cmake +from common.args import BuildArgs + + +class SDL(CmakeSoftware): + def __init__(self, build_args: BuildArgs) -> None: + super().__init__(build_args, "SDL", "3.2.20", "SDL") + + self.outputs = { + Platform.Windows: [ + "SDL3.dll", + "SDL3.pdb", + ], + Platform.Linux: ["libSDL3.so.0"], + Platform.OSX: ["libSDL3.0.dylib"], + } + + def build(self) -> None: + cmake = locate_cmake() + + cmake_args = [ + cmake, + f"-B{self.dest_dir}", + "-DSDL_SHARED=On", + "-DSDL_STATIC=Off", + "-DSDL_WERROR=Off", + "-DSDL_TESTS=Off", + "-DSDL_INSTALL_TESTS=Off", + "-DSDL_GPU=Off", + "-DSDL_RENDER=Off", + "-DSDL_CAMERA=Off", + ] + cmake_common_args(self.build_args) + + 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..dcde1d1 --- /dev/null +++ b/scripts/software/zstd.py @@ -0,0 +1,57 @@ +#!/bin/bash python3 + +import subprocess +import shutil +from common import CmakeSoftware, Github, Platform +from common.cmake import cmake_common_args, locate_cmake +from common.args import BuildArgs + + +class ZStd(CmakeSoftware): + def __init__(self, args: BuildArgs) -> None: + super().__init__(args, "zstd", "1.5.7", "zstd") + + self.outputs = { + Platform.Windows: [ + "lib/zstd.dll", + "lib/zstd.pdb", + ], + Platform.Linux: ["lib/libzstd.so.1"], + Platform.OSX: ["lib/libzstd.1.dylib"], + } + + def build(self) -> None: + cmake = locate_cmake() + + Github.log("Setting up CMake...") + result = subprocess.call( + [ + cmake, + "build/cmake", + f"-B{self.dest_dir}", + "-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", + ] + cmake_common_args(self.build_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/windows.py b/scripts/windows.py new file mode 100644 index 0000000..9cb6780 --- /dev/null +++ b/scripts/windows.py @@ -0,0 +1,42 @@ +#!/usr/bin/env 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 software.angle import Angle + +from common import Github, Software, SoftwareImpl, parse_args, dump_build_notes, filter_software_to_build, ARTIFACT_DIR, ROOT_DIR + +if __name__ == "__main__": + args = parse_args() + to_build: list[SoftwareImpl] = [ + ZStd, + GLFW, + SDL, + OpenAL, + Freetype, + Fluidsynth, + Angle + ] + + build_softwares = filter_software_to_build(to_build, args) + + # 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 build_softwares: + with Github.LogGroup(f"Building {build.name}"): + build.build() + build.publish() + + dump_build_notes( + "native-build (Windows)", + ROOT_DIR, + ARTIFACT_DIR.joinpath("notes.md"), + [f"- {build.name}" for build in build_softwares], + ) diff --git a/vcpkg b/vcpkg index 36fb233..08990a7 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 36fb23307e10cc6ffcec566c46c4bb3f567c82c6 +Subproject commit 08990a7bace02fd8aba4e01e74cd38f26cb5ed61 diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..dfd2afa --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,16 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "08990a7bace02fd8aba4e01e74cd38f26cb5ed61", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ], + "overlay-ports": ["./vcpkg-overlay-ports"], + "overlay-triplets": ["./vcpkg-overlay-triplets"] +} diff --git a/vcpkg-overlay-ports/angle/001-fix-uwp.patch b/vcpkg-overlay-ports/angle_/001-fix-uwp.patch similarity index 100% rename from vcpkg-overlay-ports/angle/001-fix-uwp.patch rename to vcpkg-overlay-ports/angle_/001-fix-uwp.patch diff --git a/vcpkg-overlay-ports/angle/002-fix-builder-error.patch b/vcpkg-overlay-ports/angle_/002-fix-builder-error.patch similarity index 100% rename from vcpkg-overlay-ports/angle/002-fix-builder-error.patch rename to vcpkg-overlay-ports/angle_/002-fix-builder-error.patch diff --git a/vcpkg-overlay-ports/angle/003-fix-mingw.patch b/vcpkg-overlay-ports/angle_/003-fix-mingw.patch similarity index 100% rename from vcpkg-overlay-ports/angle/003-fix-mingw.patch rename to vcpkg-overlay-ports/angle_/003-fix-mingw.patch diff --git a/vcpkg-overlay-ports/angle/CMakeLists.txt b/vcpkg-overlay-ports/angle_/CMakeLists.txt similarity index 100% rename from vcpkg-overlay-ports/angle/CMakeLists.txt rename to vcpkg-overlay-ports/angle_/CMakeLists.txt diff --git a/vcpkg-overlay-ports/angle/angle_commit.h.in b/vcpkg-overlay-ports/angle_/angle_commit.h.in similarity index 100% rename from vcpkg-overlay-ports/angle/angle_commit.h.in rename to vcpkg-overlay-ports/angle_/angle_commit.h.in diff --git a/vcpkg-overlay-ports/angle/portfile.cmake b/vcpkg-overlay-ports/angle_/portfile.cmake similarity index 100% rename from vcpkg-overlay-ports/angle/portfile.cmake rename to vcpkg-overlay-ports/angle_/portfile.cmake diff --git a/vcpkg-overlay-ports/angle/vcpkg.json b/vcpkg-overlay-ports/angle_/vcpkg.json similarity index 100% rename from vcpkg-overlay-ports/angle/vcpkg.json rename to vcpkg-overlay-ports/angle_/vcpkg.json diff --git a/vcpkg-overlay-ports/fluidsynth/gentables.patch b/vcpkg-overlay-ports/fluidsynth/gentables.patch new file mode 100644 index 0000000..6faa5f8 --- /dev/null +++ b/vcpkg-overlay-ports/fluidsynth/gentables.patch @@ -0,0 +1,51 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index e86a6429..9240e091 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -538,6 +538,9 @@ install(EXPORT FluidSynthTargets + + # ******* Auto Generated Lookup Tables ****** + ++if(VCPKG_BUILD_MAKE_TABLES) ++ add_subdirectory(gentables) ++elseif(0) + include(ExternalProject) + + set (GENTAB_SDIR ${CMAKE_CURRENT_SOURCE_DIR}/gentables) +@@ -557,4 +560,11 @@ ExternalProject_Add(gentables + "${CMAKE_COMMAND}" --build "${GENTAB_BDIR}" + INSTALL_COMMAND ${GENTAB_BDIR}/make_tables.exe "${FluidSynth_BINARY_DIR}/" + ) ++endif() ++if(TARGET make_tables AND NOT CMAKE_CROSSCOMPILING) ++ set(GENTABLES make_tables) ++else() ++ find_program(GENTABLES make_tables REQUIRED) ++endif() ++add_custom_target(gentables COMMAND "${GENTABLES}" "${CMAKE_BINARY_DIR}/") + add_dependencies(libfluidsynth-OBJ gentables) +diff --git a/src/gentables/CMakeLists.txt b/src/gentables/CMakeLists.txt +index 9cb69f2b..c393a670 100644 +--- a/src/gentables/CMakeLists.txt ++++ b/src/gentables/CMakeLists.txt +@@ -12,6 +12,7 @@ unset(ENV{LDFLAGS}) + + project (gentables C) + ++if (0) + set ( CMAKE_BUILD_TYPE Debug ) + + # hardcode ".exe" as suffix to the binary, else in case of cross-platform cross-compiling the calling cmake will not know the suffix used here and fail to find the binary +@@ -20,6 +21,7 @@ set ( CMAKE_EXECUTABLE_SUFFIX ".exe" ) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) ++endif() + + # Add the executable that generates the table + add_executable( make_tables +@@ -34,3 +36,4 @@ if ( WIN32 ) + else ( WIN32 ) + target_link_libraries (make_tables "m") + endif () ++install(TARGETS make_tables DESTINATION bin) diff --git a/vcpkg-overlay-ports/fluidsynth/pkgconfig-opensles.diff b/vcpkg-overlay-ports/fluidsynth/pkgconfig-opensles.diff new file mode 100644 index 0000000..c5f7b1f --- /dev/null +++ b/vcpkg-overlay-ports/fluidsynth/pkgconfig-opensles.diff @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 604e6b0..e315df5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -748,6 +748,7 @@ endif ( enable-midishare ) + unset ( OPENSLES_SUPPORT CACHE ) + if ( enable-opensles ) + find_package( OpenSLES ) ++ list ( APPEND PC_LIBS_PRIV "-lOpenSLES" ) + set ( OPENSLES_SUPPORT ${OpenSLES_FOUND} ) + endif ( enable-opensles ) + diff --git a/vcpkg-overlay-ports/fluidsynth/portfile.cmake b/vcpkg-overlay-ports/fluidsynth/portfile.cmake new file mode 100644 index 0000000..24bf585 --- /dev/null +++ b/vcpkg-overlay-ports/fluidsynth/portfile.cmake @@ -0,0 +1,98 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO FluidSynth/fluidsynth + REF "v${VERSION}" + SHA512 2d5424d80234742be45f1c7cdf696182c96b684232bb92b079edf270d726c5d1292c5fc42c8b580ae1a89642ad7b536245977928bbeecedd94443f6e1f47d5fd + HEAD_REF master + PATCHES + gentables.patch + pkgconfig-opensles.diff +) +# Do not use or install FindSndFileLegacy.cmake and its deps +file(REMOVE + "${SOURCE_PATH}/cmake_admin/FindFLAC.cmake" + "${SOURCE_PATH}/cmake_admin/Findmp3lame.cmake" + "${SOURCE_PATH}/cmake_admin/Findmpg123.cmake" + "${SOURCE_PATH}/cmake_admin/FindOgg.cmake" + "${SOURCE_PATH}/cmake_admin/FindOpus.cmake" + "${SOURCE_PATH}/cmake_admin/FindSndFileLegacy.cmake" + "${SOURCE_PATH}/cmake_admin/FindVorbis.cmake" +) + +vcpkg_check_features( + OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + buildtools VCPKG_BUILD_MAKE_TABLES + sndfile enable-libsndfile + pulseaudio enable-pulseaudio +) + +# enable platform-specific features, force the build to fail if the required libraries are not found, +# and disable all other features to avoid system libraries to be picked up +set(WINDOWS_OPTIONS enable-dsound enable-wasapi enable-waveout enable-winmidi HAVE_MMSYSTEM_H HAVE_DSOUND_H HAVE_OBJBASE_H) +set(MACOS_OPTIONS enable-coreaudio enable-coremidi COREAUDIO_FOUND COREMIDI_FOUND) +set(LINUX_OPTIONS enable-alsa ALSA_FOUND) +set(ANDROID_OPTIONS enable-opensles OpenSLES_FOUND) +set(IGNORED_OPTIONS enable-coverage enable-dbus enable-floats enable-fpe-check enable-framework enable-jack + enable-libinstpatch enable-midishare enable-oboe enable-openmp enable-oss enable-pipewire enable-portaudio + enable-profiling enable-readline enable-sdl2 enable-sdl3 enable-systemd enable-trap-on-fpe enable-ubsan) + +if(VCPKG_TARGET_IS_WINDOWS) + set(OPTIONS_TO_ENABLE ${WINDOWS_OPTIONS}) + set(OPTIONS_TO_DISABLE ${MACOS_OPTIONS} ${LINUX_OPTIONS} ${ANDROID_OPTIONS}) +elseif(VCPKG_TARGET_IS_OSX) + set(OPTIONS_TO_ENABLE ${MACOS_OPTIONS}) + set(OPTIONS_TO_DISABLE ${WINDOWS_OPTIONS} ${LINUX_OPTIONS} ${ANDROID_OPTIONS}) +elseif(VCPKG_TARGET_IS_LINUX) + set(OPTIONS_TO_ENABLE ${LINUX_OPTIONS}) + set(OPTIONS_TO_DISABLE ${WINDOWS_OPTIONS} ${MACOS_OPTIONS} ${ANDROID_OPTIONS}) +elseif(VCPKG_TARGET_IS_ANDROID) + set(OPTIONS_TO_ENABLE ${ANDROID_OPTIONS}) + set(OPTIONS_TO_DISABLE ${WINDOWS_OPTIONS} ${MACOS_OPTIONS} ${LINUX_OPTIONS}) +endif() + +foreach(_option IN LISTS OPTIONS_TO_ENABLE) + list(APPEND ENABLED_OPTIONS "-D${_option}:BOOL=ON") +endforeach() + +foreach(_option IN LISTS OPTIONS_TO_DISABLE IGNORED_OPTIONS) + list(APPEND DISABLED_OPTIONS "-D${_option}:BOOL=OFF") +endforeach() + +vcpkg_find_acquire_program(PKGCONFIG) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DVCPKG_HOST_TRIPLET=${HOST_TRIPLET}" + ${FEATURE_OPTIONS} + ${ENABLED_OPTIONS} + ${DISABLED_OPTIONS} + "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}" + MAYBE_UNUSED_VARIABLES + ${OPTIONS_TO_DISABLE} + VCPKG_BUILD_MAKE_TABLES + enable-coverage + enable-framework + enable-ubsan +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/fluidsynth) +vcpkg_fixup_pkgconfig() + +set(tools fluidsynth) +if("buildtools" IN_LIST FEATURES) + list(APPEND tools make_tables) +endif() +vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/share/man") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + diff --git a/vcpkg-overlay-ports/fluidsynth/usage b/vcpkg-overlay-ports/fluidsynth/usage new file mode 100644 index 0000000..ea5f1ea --- /dev/null +++ b/vcpkg-overlay-ports/fluidsynth/usage @@ -0,0 +1,10 @@ +fluidsynth provides CMake targets: + + find_package(FluidSynth CONFIG REQUIRED) + target_link_libraries(main PRIVATE FluidSynth::libfluidsynth) + add_custom_command(OUTPUT result COMMAND FluidSynth::q ARGS ...) + +fluidsynth provides pkg-config modules: + + # Software SoundFont synth + fluidsynth diff --git a/vcpkg-overlay-ports/fluidsynth/vcpkg.json b/vcpkg-overlay-ports/fluidsynth/vcpkg.json new file mode 100644 index 0000000..57e9275 --- /dev/null +++ b/vcpkg-overlay-ports/fluidsynth/vcpkg.json @@ -0,0 +1,54 @@ +{ + "name": "fluidsynth", + "version": "2.4.6", + "port-version": 1, + "description": "FluidSynth reads and handles MIDI events from the MIDI input device. It is the software analogue of a MIDI synthesizer. FluidSynth can also play midifiles using a Soundfont.", + "homepage": "https://github.com/FluidSynth/fluidsynth", + "license": "LGPL-2.1-or-later", + "supports": "!xbox", + "dependencies": [ + { + "name": "fluidsynth", + "host": true, + "default-features": false, + "features": [ + "buildtools" + ] + }, + { + "name": "glib", + "platform": "!linux" + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "buildtools": { + "description": "Build tools gentables" + }, + "pulseaudio": { + "description": "Build with PulseAudio support", + "dependencies": [ + "pulseaudio" + ] + }, + "sndfile": { + "description": "Enable rendering to file and SF3 support", + "dependencies": [ + { + "name": "libsndfile", + "default-features": false, + "features": [ + "external-libs" + ] + } + ] + } + } +} diff --git a/vcpkg-overlay-triplets/arm64-linux.cmake b/vcpkg-overlay-triplets/arm64-linux.cmake new file mode 100644 index 0000000..ab3b146 --- /dev/null +++ b/vcpkg-overlay-triplets/arm64-linux.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) + +if(PORT MATCHES fluidsynth) + set(VCPKG_LIBRARY_LINKAGE dynamic) + set(VCPKG_FIXUP_ELF_RPATH ON) + set(VCPKG_LINKER_FLAGS -Bsymbolic) +endif() diff --git a/vcpkg-overlay-triplets/arm64-osx.cmake b/vcpkg-overlay-triplets/arm64-osx.cmake new file mode 100644 index 0000000..c106b2b --- /dev/null +++ b/vcpkg-overlay-triplets/arm64-osx.cmake @@ -0,0 +1,14 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES arm64) +set(VCPKG_OSX_DEPLOYMENT_TARGET 13) + +set(VCPKG_CXX_FLAGS_RELEASE -g) +set(VCPKG_C_FLAGS_RELEASE -g) + +if(PORT MATCHES fluidsynth) + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() diff --git a/vcpkg-overlay-triplets/arm64-windows.cmake b/vcpkg-overlay-triplets/arm64-windows.cmake new file mode 100644 index 0000000..6be13c3 --- /dev/null +++ b/vcpkg-overlay-triplets/arm64-windows.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +if(PORT MATCHES fluidsynth|angle) + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() diff --git a/vcpkg-overlay-triplets/x64-linux.cmake b/vcpkg-overlay-triplets/x64-linux.cmake new file mode 100644 index 0000000..edb5034 --- /dev/null +++ b/vcpkg-overlay-triplets/x64-linux.cmake @@ -0,0 +1,13 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) + +if(PORT MATCHES fluidsynth) + set(VCPKG_LIBRARY_LINKAGE dynamic) + set(VCPKG_FIXUP_ELF_RPATH ON) + + set(VCPKG_CXX_FLAGS -Wl,-Bsymbolic) + set(VCPKG_C_FLAGS -Wl,-Bsymbolic) +endif() diff --git a/vcpkg-overlay-triplets/x64-osx.cmake b/vcpkg-overlay-triplets/x64-osx.cmake new file mode 100644 index 0000000..8bf829b --- /dev/null +++ b/vcpkg-overlay-triplets/x64-osx.cmake @@ -0,0 +1,14 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) +set(VCPKG_OSX_DEPLOYMENT_TARGET 13) + +set(VCPKG_CXX_FLAGS_RELEASE -g) +set(VCPKG_C_FLAGS_RELEASE -g) + +if(PORT MATCHES fluidsynth) + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() diff --git a/vcpkg-overlay-triplets/x64-windows.cmake b/vcpkg-overlay-triplets/x64-windows.cmake new file mode 100644 index 0000000..d3deaac --- /dev/null +++ b/vcpkg-overlay-triplets/x64-windows.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +if(PORT MATCHES fluidsynth|angle) + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..4c689f1 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,11 @@ +{ + "dependencies": [ + { + "name": "fluidsynth" + }, + { + "name": "angle", + "platform": "windows" + } + ] +} 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 diff --git a/zstd b/zstd index eadb6c8..f8745da 160000 --- a/zstd +++ b/zstd @@ -1 +1 @@ -Subproject commit eadb6c874f9d0c9e90c835f8b0181da802361e4c +Subproject commit f8745da6ff1ad1e7bab384bd1f9d742439278e99