From 216e73b61fc951cf8aa12a351aa6e3749cc38aa3 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Thu, 22 Dec 2022 18:12:59 -0500 Subject: [PATCH] CI: Add a macOS Github runner (#2064) --- .github/workflows/build-matrix.yaml | 8 +++ .github/workflows/linux-build-clang.yaml | 2 +- .github/workflows/linux-build-gcc.yaml | 2 +- .github/workflows/macos-build-clang.yaml | 76 ++++++++++++++++++++++ .github/workflows/windows-build-clang.yaml | 2 +- .github/workflows/windows-build-msvc.yaml | 2 +- CMakeLists.txt | 1 + CMakePresets.json | 16 +++++ README.md | 2 +- common/goos/Interpreter.cpp | 2 +- common/nrepl/ReplServer.cpp | 2 +- common/util/crc32.cpp | 4 +- decompiler/extractor/main.cpp | 4 +- decompiler/main.cpp | 2 +- decompiler/util/DecompilerTypeSystem.h | 2 +- game/main.cpp | 2 +- game/system/Deci2Server.cpp | 4 +- game/system/IOP_Kernel.cpp | 2 +- test/test_main.cpp | 2 +- tools/dgo_packer.cpp | 2 +- tools/dgo_unpacker.cpp | 2 +- tools/level_tools/level_dump/main.cpp | 2 +- 22 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/macos-build-clang.yaml diff --git a/.github/workflows/build-matrix.yaml b/.github/workflows/build-matrix.yaml index ed78b1f66f..d86eba372f 100644 --- a/.github/workflows/build-matrix.yaml +++ b/.github/workflows/build-matrix.yaml @@ -42,3 +42,11 @@ jobs: cmakePreset: "Release-linux-gcc" cachePrefix: "" secrets: inherit + + # MacOS + build_macos_clang: + name: "🍎 MacOS" + uses: ./.github/workflows/macos-build-clang.yaml + with: + cmakePreset: "Release-macos-clang" + cachePrefix: "" diff --git a/.github/workflows/linux-build-clang.yaml b/.github/workflows/linux-build-clang.yaml index 163fdefbc7..10dee0dd1b 100644 --- a/.github/workflows/linux-build-clang.yaml +++ b/.github/workflows/linux-build-clang.yaml @@ -50,7 +50,7 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache - name: Build Project - run: cmake --build build -j$((`nproc`+1)) + run: cmake --build build --parallel $((`nproc`)) - name: Run Tests env: diff --git a/.github/workflows/linux-build-gcc.yaml b/.github/workflows/linux-build-gcc.yaml index ce47ca9609..1d37cbe153 100644 --- a/.github/workflows/linux-build-gcc.yaml +++ b/.github/workflows/linux-build-gcc.yaml @@ -51,7 +51,7 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache - name: Build Project - run: cmake --build build -j$((`nproc`+1)) -- -w dupbuild=warn + run: cmake --build build --parallel $((`nproc`)) -- -w dupbuild=warn - name: Run Tests - With Coverage working-directory: ./build diff --git a/.github/workflows/macos-build-clang.yaml b/.github/workflows/macos-build-clang.yaml new file mode 100644 index 0000000000..6d34e41eab --- /dev/null +++ b/.github/workflows/macos-build-clang.yaml @@ -0,0 +1,76 @@ +name: MacOS Build Clang + +on: + workflow_call: + inputs: + cmakePreset: + required: true + type: string + cachePrefix: + required: true + type: string + +jobs: + build: + name: Clang + runs-on: macos-12 + timeout-minutes: 120 + + env: # overrides: https://github.com/mbitsnbites/buildcache/blob/master/doc/configuration.md + BUILDCACHE_MAX_CACHE_SIZE: 1000000000 # 1gb + BUILDCACHE_COMPRESS_FORMAT: ZSTD + BUILDCACHE_COMPRESS_LEVEL: 19 + BUILDCACHE_DIRECT_MODE: true + BUILDCACHE_LOG_FILE: ${{ github.workspace }}/buildcache.log + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Install Package Dependencies + run: brew install cmake nasm ninja + + - name: Setup Buildcache + uses: mikehardy/buildcache-action@v2.1.0 + with: + cache_key: macos-12-${{ inputs.cachePrefix }}-${{ inputs.cmakePreset }} + buildcache_tag: v0.28.1 + + - name: CMake Generation + env: + CC: clang + CXX: clang++ + run: | + cmake -B build --preset=${{ inputs.cmakePreset }} \ + -DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/buildcache/bin/buildcache + + # Disabled for now, not all build targets are valid + # - name: Build Project + # run: cmake --build build --parallel $((`sysctl -n hw.logicalcpu`)) + + # Temporary, selectively build those that work + - name: Build Working Targets + run: | + cmake --build build --target extractor --parallel $((`sysctl -n hw.logicalcpu`)) && \ + cmake --build build --target offline-test --parallel $((`sysctl -n hw.logicalcpu`)) && \ + cmake --build build --target decompiler --parallel $((`sysctl -n hw.logicalcpu`)) && \ + cmake --build build --target lsp --parallel $((`sysctl -n hw.logicalcpu`)) && \ + cmake --build build --target goalc --parallel $((`sysctl -n hw.logicalcpu`)) + + - name: Run Tests + continue-on-error: true # until macOS is stable + env: + GTEST_OUTPUT: "xml:opengoal-test-report.xml" + run: ./test.sh + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: opengoal-macos-${{ inputs.cachePrefix }} + if-no-files-found: error + path: | + ./build/goalc/goalc + ./build/decompiler/extractor + ./build/game/gk + ./build/lsp/lsp diff --git a/.github/workflows/windows-build-clang.yaml b/.github/workflows/windows-build-clang.yaml index 7b934c05c1..fcfec40b91 100644 --- a/.github/workflows/windows-build-clang.yaml +++ b/.github/workflows/windows-build-clang.yaml @@ -44,7 +44,7 @@ jobs: - name: Build Project shell: cmd - run: cmake --build build -j 2 + run: cmake --build build --parallel %NUMBER_OF_PROCESSORS% - name: Run Tests timeout-minutes: 10 diff --git a/.github/workflows/windows-build-msvc.yaml b/.github/workflows/windows-build-msvc.yaml index 60c09fb165..4d0cfefe60 100644 --- a/.github/workflows/windows-build-msvc.yaml +++ b/.github/workflows/windows-build-msvc.yaml @@ -45,7 +45,7 @@ jobs: shell: cmd run: | set CL=/MP - cmake --build build -j 2 + cmake --build build --parallel %NUMBER_OF_PROCESSORS% - name: Run Tests timeout-minutes: 10 diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c3caf097..ef4266035b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") message(STATUS "AppleClang detected - Setting Defaults") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + -march=native \ -Wall \ -Winit-self \ -ggdb \ diff --git a/CMakePresets.json b/CMakePresets.json index 509d757aea..10e00011b2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -57,6 +57,16 @@ "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install/${presetName}" } }, + { + "name": "base-macos-release", + "hidden": true, + "inherits": "base", + "binaryDir": "${sourceDir}/build/Release/bin", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install/${presetName}" + } + }, { "name": "base-clang", "hidden": true, @@ -127,6 +137,12 @@ "description": "Build with Clang as Release without Debug Symbols", "inherits": ["base-linux-release", "base-clang"] }, + { + "name": "Release-macos-clang", + "displayName": "MacOS Release (clang)", + "description": "Build with Clang as Release without Debug Symbols", + "inherits": ["base-macos-release", "base-clang"] + }, { "name": "Release-linux-clang-asan", "displayName": "Linux Release (clang-asan)", diff --git a/README.md b/README.md index fcb5c55882..dfb47fff56 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

Documentation Badge - Linux and Windows Build + Linux and Windows Build Codacy Badge Codacy Badge Discord diff --git a/common/goos/Interpreter.cpp b/common/goos/Interpreter.cpp index 03a3597d4d..bc1b927347 100644 --- a/common/goos/Interpreter.cpp +++ b/common/goos/Interpreter.cpp @@ -9,9 +9,9 @@ #include "ParseHelpers.h" +#include "common/log/log.h" #include "common/util/FileUtil.h" #include "common/util/unicode_util.h" -#include #include "third-party/fmt/core.h" diff --git a/common/nrepl/ReplServer.cpp b/common/nrepl/ReplServer.cpp index 1d709802ba..c274bf694a 100644 --- a/common/nrepl/ReplServer.cpp +++ b/common/nrepl/ReplServer.cpp @@ -2,7 +2,7 @@ #include "ReplServer.h" #include "common/cross_sockets/XSocket.h" -#include +#include "common/versions.h" #include "third-party/fmt/core.h" diff --git a/common/util/crc32.cpp b/common/util/crc32.cpp index 001039b1b0..91b5206cd9 100644 --- a/common/util/crc32.cpp +++ b/common/util/crc32.cpp @@ -2,7 +2,7 @@ #include -#ifdef __APPLE__ +#ifdef __arm__ #include u32 crc32(const u8* data, size_t size) { u32 result = 0xffffffff; @@ -39,4 +39,4 @@ u32 crc32(const u8* data, size_t size) { } return ~result; } -#endif \ No newline at end of file +#endif diff --git a/decompiler/extractor/main.cpp b/decompiler/extractor/main.cpp index 5528b02a2a..1dd17bee1a 100644 --- a/decompiler/extractor/main.cpp +++ b/decompiler/extractor/main.cpp @@ -8,7 +8,7 @@ #include "common/util/FileUtil.h" #include "common/util/json_util.h" #include "common/util/read_iso_file.h" -#include +#include "common/util/unicode_util.h" #include "decompiler/Disasm/OpcodeInfo.h" #include "decompiler/ObjectFile/ObjectFileDB.h" @@ -71,7 +71,7 @@ std::tuple, ExtractorErrorCode> validate( return {std::nullopt, ExtractorErrorCode::VALIDATION_ELF_MISSING_FROM_DB}; } - auto version_info = meta_entry->second; + auto& version_info = meta_entry->second; // Print out some information lg::info("Detected Game Metadata:"); lg::info("\tDetected - {}", version_info.canonical_name); diff --git a/decompiler/main.cpp b/decompiler/main.cpp index 9f35529b7f..ea451c47c2 100644 --- a/decompiler/main.cpp +++ b/decompiler/main.cpp @@ -9,8 +9,8 @@ #include "common/util/Timer.h" #include "common/util/diff.h" #include "common/util/os.h" +#include "common/util/unicode_util.h" #include "common/versions.h" -#include #include "ObjectFile/ObjectFileDB.h" #include "decompiler/data/TextureDB.h" diff --git a/decompiler/util/DecompilerTypeSystem.h b/decompiler/util/DecompilerTypeSystem.h index 18f567b2bc..ee78a2434f 100644 --- a/decompiler/util/DecompilerTypeSystem.h +++ b/decompiler/util/DecompilerTypeSystem.h @@ -1,8 +1,8 @@ #pragma once #include "common/goos/Reader.h" +#include "common/goos/TextDB.h" #include "common/type_system/TypeSystem.h" -#include #include "decompiler/Disasm/Register.h" diff --git a/game/main.cpp b/game/main.cpp index 1abc6ceb2b..f01efae6c6 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -12,8 +12,8 @@ #include "common/log/log.h" #include "common/util/FileUtil.h" #include "common/util/os.h" +#include "common/util/unicode_util.h" #include "common/versions.h" -#include #include "game/discord.h" diff --git a/game/system/Deci2Server.cpp b/game/system/Deci2Server.cpp index c5a2acf56e..2fca1a5885 100644 --- a/game/system/Deci2Server.cpp +++ b/game/system/Deci2Server.cpp @@ -9,8 +9,8 @@ #include "common/cross_sockets/XSocket.h" #include "common/versions.h" -#include -#include +#include "common/listener_common.h" +#include "common/util/Assert.h" #include "third-party/fmt/core.h" diff --git a/game/system/IOP_Kernel.cpp b/game/system/IOP_Kernel.cpp index dff2826451..c4fa84d207 100644 --- a/game/system/IOP_Kernel.cpp +++ b/game/system/IOP_Kernel.cpp @@ -3,7 +3,7 @@ #include #include "common/util/Assert.h" -#include +#include "common/util/FileUtil.h" #include "game/sce/iop.h" diff --git a/test/test_main.cpp b/test/test_main.cpp index 5d124e4d04..e80e8faf9f 100644 --- a/test/test_main.cpp +++ b/test/test_main.cpp @@ -3,7 +3,7 @@ #include "common/log/log.h" #include "common/util/FileUtil.h" #include "common/util/os.h" -#include +#include "common/util/unicode_util.h" #include "gtest/gtest.h" diff --git a/tools/dgo_packer.cpp b/tools/dgo_packer.cpp index e75953a7b1..6275e959ca 100644 --- a/tools/dgo_packer.cpp +++ b/tools/dgo_packer.cpp @@ -2,8 +2,8 @@ #include "common/util/BinaryWriter.h" #include "common/util/FileUtil.h" +#include "common/util/unicode_util.h" #include "common/versions.h" -#include #include "third-party/json.hpp" diff --git a/tools/dgo_unpacker.cpp b/tools/dgo_unpacker.cpp index 89fcb229ae..ff8b45ae46 100644 --- a/tools/dgo_unpacker.cpp +++ b/tools/dgo_unpacker.cpp @@ -3,8 +3,8 @@ #include "common/util/DgoReader.h" #include "common/util/FileUtil.h" +#include "common/util/unicode_util.h" #include "common/versions.h" -#include namespace { int run(int argc, char** argv) { diff --git a/tools/level_tools/level_dump/main.cpp b/tools/level_tools/level_dump/main.cpp index cbd663fd96..10abde565f 100644 --- a/tools/level_tools/level_dump/main.cpp +++ b/tools/level_tools/level_dump/main.cpp @@ -1,7 +1,7 @@ #include "common/util/Assert.h" #include "common/util/DgoReader.h" #include "common/util/FileUtil.h" -#include +#include "common/util/unicode_util.h" #include "decompiler/ObjectFile/LinkedObjectFile.h" #include "decompiler/ObjectFile/LinkedObjectFileCreation.h"