Add Initializers for Structs - Fix issue with Apple Clang (#31)

Fixes #30 also adds CI
This commit is contained in:
David Chavez 2024-05-14 02:55:43 +02:00 committed by GitHub
parent d7b223fde5
commit 706e7c5069
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 74 additions and 1 deletions

59
.github/workflows/validate.yml vendored Normal file
View file

@ -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

2
.gitignore vendored
View file

@ -50,3 +50,5 @@ test/RT64
# Runtime files
imgui.ini
rt64.log
.idea
cmake-build*

View file

@ -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)

View file

@ -4,6 +4,7 @@
#include <span>
#include <string_view>
#include <cstdint>
#include <utility>
#include <vector>
#include <unordered_map>
#include <span>
@ -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<uint32_t> 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<uint32_t>&& 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<uint32_t> 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 {