From 706e7c50691d52681d7bb05d7563d871d9e429ac Mon Sep 17 00:00:00 2001 From: David Chavez Date: Tue, 14 May 2024 02:55:43 +0200 Subject: [PATCH] Add Initializers for Structs - Fix issue with Apple Clang (#31) Fixes #30 also adds CI --- .github/workflows/validate.yml | 59 ++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ CMakeLists.txt | 1 - include/recomp_port.h | 13 ++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..85723cb --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,59 @@ +name: validate +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + type: [ Debug, Release ] + os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] # macOS 13 is intel and macOS 14 is arm + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ runner.os }}-N64Recomp-ccache + - name: Install Windows Dependencies + if: runner.os == 'Windows' + run: | + choco install ninja + Remove-Item -Path "C:\ProgramData\Chocolatey\bin\ccache.exe" -Force -ErrorAction SilentlyContinue + - name: Install Linux Dependencies + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y ninja-build + - name: Install macOS Dependencies + if: runner.os == 'macOS' + run: | + brew install ninja + - name: Configure Developer Command Prompt + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + - name: Build N64Recomp (Unix) + if: runner.os != 'Windows' + run: |- + # enable ccache + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S . -B cmake-build + cmake --build cmake-build --config Debug --target N64Recomp -j 8 + - name: Build N64Recomp (Windows) + if: runner.os == 'Windows' + run: |- + # enable ccache + set $env:PATH="$env:USERPROFILE/.cargo/bin;$env:PATH" + + cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S . -B cmake-build + cmake --build cmake-build --config Debug --target N64Recomp -j 8 diff --git a/.gitignore b/.gitignore index 594dcb7..08f2896 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ test/RT64 # Runtime files imgui.ini rt64.log +.idea +cmake-build* diff --git a/CMakeLists.txt b/CMakeLists.txt index 7eab156..4c06943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.20) -project(Zelda64Recompiled) set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/include/recomp_port.h b/include/recomp_port.h index 0140d2f..9c4b11b 100644 --- a/include/recomp_port.h +++ b/include/recomp_port.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,8 @@ namespace RecompPort { struct FunctionSize { std::string func_name; uint32_t size_bytes; + + FunctionSize(const std::string& func_name, uint32_t size_bytes) : func_name(func_name), size_bytes(size_bytes) {} }; struct ManualFunction { @@ -49,6 +52,8 @@ namespace RecompPort { std::string section_name; uint32_t vram; uint32_t size; + + ManualFunction(const std::string& func_name, std::string section_name, uint32_t vram, uint32_t size) : func_name(func_name), section_name(std::move(section_name)), vram(vram), size(size) {} }; struct Config { @@ -82,11 +87,16 @@ namespace RecompPort { uint32_t addu_vram; uint32_t jr_vram; std::vector entries; + + JumpTable(uint32_t vram, uint32_t addend_reg, uint32_t rom, uint32_t lw_vram, uint32_t addu_vram, uint32_t jr_vram, std::vector&& entries) + : vram(vram), addend_reg(addend_reg), rom(rom), lw_vram(lw_vram), addu_vram(addu_vram), jr_vram(jr_vram), entries(std::move(entries)) {} }; struct AbsoluteJump { uint32_t jump_target; uint32_t instruction_vram; + + AbsoluteJump(uint32_t jump_target, uint32_t instruction_vram) : jump_target(jump_target), instruction_vram(instruction_vram) {} }; struct Function { @@ -98,6 +108,9 @@ namespace RecompPort { bool ignored; bool reimplemented; bool stubbed; + + Function(uint32_t vram, uint32_t rom, std::vector words, std::string name, ELFIO::Elf_Half section_index, bool ignored = false, bool reimplemented = false, bool stubbed = false) + : vram(vram), rom(rom), words(std::move(words)), name(std::move(name)), section_index(section_index), ignored(ignored), reimplemented(reimplemented), stubbed(stubbed) {} }; enum class RelocType : uint8_t {