diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..8496b8d7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,106 @@ +name: Tests + +on: [push, pull_request] + +jobs: + test: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: Linux x86_64 + os: ubuntu-latest + preset: linux-static-dev + + - name: Linux aarch64 + os: ubuntu-24.04-arm + preset: arm64-linux-static-dev + + - name: Linux x86 + os: ubuntu-latest + preset: x86-linux-static-dev + apt-extra: gcc-multilib g++-multilib + + - name: macOS arm64 + os: macos-26 + preset: arm64-osx-static-dev + + - name: Windows x86_64 + os: windows-latest + preset: win-static-dev + msvc-arch: amd64 + + - name: Windows arm64 + os: [windows-11-arm] + preset: arm64-win-static-dev + msvc-arch: arm64 + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + # Initialise submodules manually so we can rewrite SSH URLs to + # HTTPS first — the .gitmodules file uses git@ URLs which require + # an SSH key that is not available on hosted runners. + submodules: false + + - name: Use HTTPS for submodule URLs + run: git config --global url."https://github.com/".insteadOf "git@github.com:" + + - name: Initialise submodules + run: git submodule update --init --recursive + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update -q + sudo apt-get install -y ninja-build ${{ matrix.apt-extra }} + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: brew install ninja + + # Exposes cl.exe, link.exe and ninja to subsequent steps. + # arch must match the target: arm64 selects the native ARM64 toolchain + # (no cross-compilation); amd64 selects the standard x64 toolchain. + - name: Set up MSVC environment + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.msvc-arch }} + + - name: Bootstrap vcpkg (Unix) + if: runner.os != 'Windows' + run: ./externals/vcpkg/bootstrap-vcpkg.sh -disableMetrics + + - name: Bootstrap vcpkg (Windows) + if: runner.os == 'Windows' + shell: cmd + run: .\externals\vcpkg\bootstrap-vcpkg.bat -disableMetrics + + # Cache the installed packages so re-runs don't rebuild everything from + # source. The key covers the triplet (via preset name), the dependency + # manifest and any custom triplet files. + - name: Cache vcpkg packages + uses: actions/cache@v5 + with: + path: build/vcpkg_installed + key: vcpkg-${{ matrix.preset }}-${{ hashFiles('vcpkg.json', 'vcpkg_triplets/**') }} + restore-keys: vcpkg-${{ matrix.preset }}- + + # clang-tidy is not installed on hosted runners; disable it so the + # build preset's CMAKE_CXX_CLANG_TIDY setting does not break configure. + - name: Configure + run: cmake --preset ${{ matrix.preset }} -DCMAKE_CXX_CLANG_TIDY= + + - name: Build + run: cmake --build --preset ${{ matrix.preset }} + + # Catch2WithMain makes the executable its own test runner; invoke it + # directly. shell: bash is used on all platforms so the path syntax is + # consistent (Git Bash on Windows resolves Test → Test.exe automatically). + - name: Test + shell: bash + run: ./build/test/Test diff --git a/.gitmodules b/.gitmodules index e69de29b..716c7496 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "externals/vcpkg"] + path = externals/vcpkg + url = git@github.com:microsoft/vcpkg.git diff --git a/CMakePresets.json b/CMakePresets.json index dbfa85f1..5e69d472 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -138,6 +138,195 @@ "lhs": "${hostSystemName}", "rhs": "Windows" } + }, + { + "name": "arm64-linux-static", + "inherits": [ + "base-default", + "base-linux-arm64", + "project-base", + "build-type-release" + ], + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "arm64-linux-static" + } + } + }, + { + "name": "arm64-linux-static-dev", + "inherits": [ + "base-default", + "base-linux-arm64", + "base-dev", + "build-type-debug" + ], + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "arm64-linux-static" + } + } + }, + { + "name": "arm64-osx-static", + "inherits": [ + "base-default", + "base-osx-arm64", + "project-base", + "build-type-release" + ], + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "arm64-osx-static-dev", + "inherits": [ + "base-default", + "base-osx-arm64", + "base-dev", + "build-type-debug" + ], + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "arm64-win-static", + "inherits": [ + "base-default", + "base-win-arm64", + "project-base", + "build-type-release" + ], + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "arm64-win-static-dev", + "inherits": [ + "base-default", + "base-win-arm64", + "base-dev", + "build-type-debug" + ], + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + } + ], + "buildPresets": [ + { + "name": "linux-static", + "inherits": [ + "base-default" + ], + "configurePreset": "linux-static" + }, + { + "name": "linux-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "linux-static-dev" + }, + { + "name": "x86-linux-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "x86-linux-static-dev" + }, + { + "name": "osx-static", + "inherits": [ + "base-default" + ], + "configurePreset": "osx-static" + }, + { + "name": "osx-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "osx-static-dev" + }, + { + "name": "win-static", + "inherits": [ + "base-default" + ], + "configurePreset": "win-static" + }, + { + "name": "win-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "win-static-dev" + }, + { + "name": "arm64-linux-static", + "inherits": [ + "base-default" + ], + "configurePreset": "arm64-linux-static" + }, + { + "name": "arm64-linux-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "arm64-linux-static-dev" + }, + { + "name": "arm64-osx-static", + "inherits": [ + "base-default" + ], + "configurePreset": "arm64-osx-static" + }, + { + "name": "arm64-osx-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "arm64-osx-static-dev" + }, + { + "name": "arm64-win-static", + "inherits": [ + "base-default" + ], + "configurePreset": "arm64-win-static" + }, + { + "name": "arm64-win-static-dev", + "inherits": [ + "base-default" + ], + "configurePreset": "arm64-win-static-dev" } ] } diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json index c1b2e80a..11944d16 100644 --- a/CMakePresetsBase.json +++ b/CMakePresetsBase.json @@ -1,156 +1,190 @@ { - "version": 6, - "cmakeMinimumRequired": { - "major": 3, - "minor": 28 - }, - "configurePresets": [ - { - "name": "base-default", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/", - "installDir": "${sourceDir}/install/", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": { - "type": "BOOL", - "value": "ON" - }, - "CPACK_PACKAGE_DIRECTORY": { - "type": "PATH", - "value": "${sourceDir}/packages" - }, - "CMAKE_TOOLCHAIN_FILE": { - "type": "PATH", - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - }, - "VCPKG_OVERLAY_TRIPLETS": { - "type": "PATH", - "value": "${sourceDir}/vcpkg_triplets" - } - } - }, - { - "name": "build-type-release", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Release" - } - } - }, - { - "name": "build-type-debug", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Debug" - } - } - }, - { - "name": "nix-compiler-options", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_FLAGS": { - "type": "STRING", - "value": "-Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wshadow -Wold-style-cast -Wunused -Werror" - } - } - }, - { - "name": "base-win", - "hidden": true, - "description": "Base Windows", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - }, - "cacheVariables": { - "VCPKG_TARGET_TRIPLET": { - "type": "STRING", - "value": "x64-windows-static" - }, - "CMAKE_MSVC_RUNTIME_LIBRARY": { - "type": "STRING", - "value": "MultiThreaded$<$:Debug>" - } - } - }, - { - "name": "base-linux", - "hidden": true, - "description": "Base Linux", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "inherits": [ - "nix-compiler-options" - ] - }, - { - "name": "base-osx", - "hidden": true, - "description": "Base OSX", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "inherits": [ - "nix-compiler-options" - ], - "cacheVariables": { - "VCPKG_TARGET_TRIPLET": { - "type": "STRING", - "value": "x64-osx" - } - } - }, - { - "name": "base-dev", - "hidden": true, - "description": "Base for dev/CI setup", - "cacheVariables": { - "CMAKE_CXX_CLANG_TIDY": { - "type": "STRING", - "value": "clang-tidy;--config-file=${sourceDir}/.clang-tidy" - }, - "CMAKE_MESSAGE_LOG_LEVEL": { - "type": "STRING", - "value": "VERBOSE" - }, - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Debug" - } - } - } - ], - "buildPresets": [ - { - "name": "base-default", - "hidden": true, - "jobs": 10 - } - ], - "testPresets": [ - { - "name": "base-default", - "hidden": true, - "execution": { - "jobs": 10 - }, - "output": { - "outputOnFailure": true - } - } - ] + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 28 + }, + "configurePresets": [ + { + "name": "base-default", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/", + "installDir": "${sourceDir}/install/", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": { + "type": "BOOL", + "value": "ON" + }, + "CPACK_PACKAGE_DIRECTORY": { + "type": "PATH", + "value": "${sourceDir}/packages" + }, + "CMAKE_TOOLCHAIN_FILE": { + "type": "PATH", + "value": "${sourceDir}/externals/vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + "VCPKG_OVERLAY_TRIPLETS": { + "type": "PATH", + "value": "${sourceDir}/vcpkg_triplets" + } + } + }, + { + "name": "build-type-release", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Release" + } + } + }, + { + "name": "build-type-debug", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Debug" + } + } + }, + { + "name": "nix-compiler-options", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": { + "type": "STRING", + "value": "-Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wshadow -Wold-style-cast -Wunused -Werror" + } + } + }, + { + "name": "base-win", + "hidden": true, + "description": "Base Windows", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "x64-windows-static" + }, + "CMAKE_MSVC_RUNTIME_LIBRARY": { + "type": "STRING", + "value": "MultiThreaded$<$:Debug>" + } + } + }, + { + "name": "base-win-arm64", + "hidden": true, + "description": "Base Windows ARM64", + "inherits": [ + "base-win" + ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "arm64-windows-static" + } + } + }, + { + "name": "base-linux", + "hidden": true, + "description": "Base Linux", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "inherits": [ + "nix-compiler-options" + ] + }, + { + "name": "base-linux-arm64", + "hidden": true, + "description": "Base Linux ARM64", + "inherits": [ + "base-linux" + ] + }, + { + "name": "base-osx", + "hidden": true, + "description": "Base OSX", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + }, + "inherits": [ + "nix-compiler-options" + ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "x64-osx" + } + } + }, + { + "name": "base-osx-arm64", + "hidden": true, + "description": "Base OSX ARM64", + "inherits": [ + "base-osx" + ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "arm64-osx" + } + } + }, + { + "name": "base-dev", + "hidden": true, + "description": "Base for dev/CI setup", + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": { + "type": "STRING", + "value": "clang-tidy;--config-file=${sourceDir}/.clang-tidy" + }, + "CMAKE_MESSAGE_LOG_LEVEL": { + "type": "STRING", + "value": "VERBOSE" + }, + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Debug" + } + } + } + ], + "buildPresets": [ + { + "name": "base-default", + "hidden": true, + "jobs": 10 + } + ], + "testPresets": [ + { + "name": "base-default", + "hidden": true, + "execution": { + "jobs": 10 + }, + "output": { + "outputOnFailure": true + } + } + ] } - - diff --git a/externals/vcpkg b/externals/vcpkg new file mode 160000 index 00000000..a7eda31d --- /dev/null +++ b/externals/vcpkg @@ -0,0 +1 @@ +Subproject commit a7eda31dc16994fcaa8587982eb833a8695f1b6f diff --git a/src/LoutLogger.cpp b/src/LoutLogger.cpp index 12b4b72d..4f7dd110 100644 --- a/src/LoutLogger.cpp +++ b/src/LoutLogger.cpp @@ -131,8 +131,8 @@ namespace lout // // ////////////////////////////////////////////////////////////////////////// -#if !__x86_64__ || __APPLE__ - // Don't compile this on 64 bit platforms since it is the same as uint64_t +#if !(__x86_64__ || __aarch64__) || __APPLE__ + // Don't compile this on 64-bit LP64 platforms (x86_64/aarch64) since unsigned long == uint64_t there LoutLogger& LoutLogger::operator<<(unsigned long value) { myItems.push_back(std::make_shared(std::to_string(value))); diff --git a/src/LoutLogger.h b/src/LoutLogger.h index 5d4a06d1..146f176e 100644 --- a/src/LoutLogger.h +++ b/src/LoutLogger.h @@ -7,6 +7,7 @@ #include "Flush.h" #include "item/ILogItem.h" #include "loglevel/ILogLevel.h" +#include #include #include #include @@ -53,8 +54,8 @@ namespace lout LoutLogger& operator<<(uint64_t value); -#if !__x86_64__ || __APPLE__ - // Don't compile this on 64 bit platforms since it is the same as uint64_t +#if !(__x86_64__ || __aarch64__) || __APPLE__ + // Don't compile this on 64-bit LP64 platforms (x86_64/aarch64) since unsigned long == uint64_t there LoutLogger& operator<<(unsigned long value); #endif diff --git a/src/output/IOutput.h b/src/output/IOutput.h index fa47f183..4c1b6c0e 100644 --- a/src/output/IOutput.h +++ b/src/output/IOutput.h @@ -7,6 +7,7 @@ #include "formatting/IFormatter.h" #include "loglevel/ILogLevel.h" #include "loglevel/defaultLevels.h" +#include #include #include diff --git a/vcpkg_triplets/arm64-linux-static.cmake b/vcpkg_triplets/arm64-linux-static.cmake new file mode 100644 index 00000000..fd35df2d --- /dev/null +++ b/vcpkg_triplets/arm64-linux-static.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) diff --git a/vcpkg_triplets/arm64-windows-static.cmake b/vcpkg_triplets/arm64-windows-static.cmake new file mode 100644 index 00000000..671e1006 --- /dev/null +++ b/vcpkg_triplets/arm64-windows-static.cmake @@ -0,0 +1,4 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_PROCESSOR ARM64)