From 42a7718f71b105b227d05ac925de7d767e082654 Mon Sep 17 00:00:00 2001 From: dcvz Date: Tue, 14 May 2024 15:12:00 +0200 Subject: [PATCH 1/5] Simplify CMake + add a few more building instructions --- CMakeLists.txt | 59 +++++++++----------------------------------------- README.md | 13 ++++++++++- 2 files changed, 22 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c06943..46cf21a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,51 +10,18 @@ add_subdirectory(lib/fmt) # Rabbitizer project(rabbitizer) -add_library(rabbitizer STATIC) -target_sources(rabbitizer PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrId.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrIdType.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR3000GTE.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerRegistersTracker.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerConfig.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerVersion.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/Utils.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrCategory.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrIdType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrSuffix.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegister.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegisterDescriptor.c") +file(GLOB_RECURSE RABBITIZER_SOURCES + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/*.cpp" + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/*.c" +) -target_include_directories(rabbitizer PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/tables") +add_library(rabbitizer STATIC ${RABBITIZER_SOURCES}) + +target_include_directories(rabbitizer PRIVATE "${CMAKE_SOURCE_DIR}/lib/rabbitizer/tables") +target_include_directories(rabbitizer PUBLIC + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include") # N64 recompiler project(N64Recomp) @@ -67,10 +34,7 @@ target_sources(N64Recomp PRIVATE ${CMAKE_SOURCE_DIR}/src/recompilation.cpp) target_include_directories(N64Recomp PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include" "${CMAKE_SOURCE_DIR}/lib/ELFIO" - "${CMAKE_SOURCE_DIR}/lib/fmt/include" "${CMAKE_SOURCE_DIR}/lib/toml11" "${CMAKE_SOURCE_DIR}/include") @@ -81,9 +45,6 @@ project(RSPRecomp) add_executable(RSPRecomp) target_include_directories(RSPRecomp PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include" - "${CMAKE_SOURCE_DIR}/lib/fmt/include" "${CMAKE_SOURCE_DIR}/lib/toml11" "${CMAKE_SOURCE_DIR}/include") diff --git a/README.md b/README.md index 57911ac..a0e7f35 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,18 @@ RSP microcode can also be recompiled with this tool. Currently there is no suppo * Ability to recompile into a dynamic language (such as Lua) to be able to load code at runtime for mod support ## Building -This project can be built with CMake 3.20 or above and a C++ compiler that supports C++20. This repo uses git submodules, so be sure to clone recursively (`git clone --recurse-submodules`) or initialize submodules recursively after cloning (`git submodule update --init --recursive`). From there, building is identical to any other cmake project, e.g. run `cmake` in the target build folder and point it at the root of this repo, then run `cmake --build .` from that target folder. +This project can be built with CMake 3.20 or above and a C++ compiler that supports C++20. This repo uses git submodules, so be sure to clone recursively (`git clone --recurse-submodules`) or initialize submodules recursively after cloning (`git submodule update --init --recursive`). + +From there, building is identical to any other cmake project, e.g. run `cmake` in the target build folder and point it at the root of this repo, then run `cmake --build .` from that target folder. You can also use different generators if you'd like to work in different IDE's like Xcode or Visual Studio by using the generator flag: +```bash +# generates into a folder called `build-cmake` +# open the generated Xcode project in that folder +cmake -H. -Bbuild-cmake -GXcode + +# generates into a folder called `build-cmake` +# open the generated Visual Studio 2022 solution in that folder +cmake -S . -B "build-cmake" -G "Visual Studio 17 2022" +``` ## Libraries Used * [rabbitizer](https://github.com/Decompollaborate/rabbitizer) for instruction decoding/analysis From 0325461afb99c828cca1cd16eba6ff5497360bd8 Mon Sep 17 00:00:00 2001 From: dcvz Date: Tue, 14 May 2024 15:17:46 +0200 Subject: [PATCH 2/5] Be more explicit with the cplusplus path --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46cf21a..d0bdab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ add_subdirectory(lib/fmt) project(rabbitizer) file(GLOB_RECURSE RABBITIZER_SOURCES - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/*.cpp" + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/*.cpp" "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/*.c" ) From ef2e47166722dbdc9323bec33da5d42e210b3f03 Mon Sep 17 00:00:00 2001 From: dcvz Date: Tue, 14 May 2024 17:18:27 +0200 Subject: [PATCH 3/5] Only one project define --- CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0bdab3..a0c6107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +project(N64Recomp) cmake_minimum_required(VERSION 3.20) set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) @@ -9,8 +10,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) add_subdirectory(lib/fmt) # Rabbitizer -project(rabbitizer) - file(GLOB_RECURSE RABBITIZER_SOURCES "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/*.cpp" "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/*.c" @@ -24,7 +23,6 @@ target_include_directories(rabbitizer PUBLIC "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include") # N64 recompiler -project(N64Recomp) add_executable(N64Recomp) target_sources(N64Recomp PRIVATE @@ -41,7 +39,6 @@ target_include_directories(N64Recomp PRIVATE target_link_libraries(N64Recomp fmt rabbitizer) # RSP recompiler -project(RSPRecomp) add_executable(RSPRecomp) target_include_directories(RSPRecomp PRIVATE From 1467b3ed8666ab4678ad78464956cac2e87c8cbb Mon Sep 17 00:00:00 2001 From: dcvz Date: Sun, 19 May 2024 16:44:53 +0200 Subject: [PATCH 4/5] rebase fixes --- CMakeLists.txt | 2 ++ lib/fmt | 2 +- lib/toml11 | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) delete mode 160000 lib/toml11 diff --git a/CMakeLists.txt b/CMakeLists.txt index 78934e3..45f0ee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_CXX_EXTENSIONS OFF) # set(CMAKE_CXX_VISIBILITY_PRESET hidden) # Rabbitizer +add_library(rabbitizer STATIC) + target_sources(rabbitizer PRIVATE "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp" "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp" diff --git a/lib/fmt b/lib/fmt index d2e89c8..8e72804 160000 --- a/lib/fmt +++ b/lib/fmt @@ -1 +1 @@ -Subproject commit d2e89c8b080394e996d449371267365c223ca76b +Subproject commit 8e728044f673774160f43b44a07c6b185352310f diff --git a/lib/toml11 b/lib/toml11 deleted file mode 160000 index d47fe78..0000000 --- a/lib/toml11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d47fe788bcb08c9d0d2a73954a0dfaf512964fdc From 552d5efde21a3a1edf536aa9965ebdc856c6df4a Mon Sep 17 00:00:00 2001 From: dcvz Date: Sun, 19 May 2024 16:48:27 +0200 Subject: [PATCH 5/5] Incorporate suggestions from @VelocityRa --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a0e7f35..f0bf84e 100644 --- a/README.md +++ b/README.md @@ -52,15 +52,24 @@ RSP microcode can also be recompiled with this tool. Currently there is no suppo ## Building This project can be built with CMake 3.20 or above and a C++ compiler that supports C++20. This repo uses git submodules, so be sure to clone recursively (`git clone --recurse-submodules`) or initialize submodules recursively after cloning (`git submodule update --init --recursive`). -From there, building is identical to any other cmake project, e.g. run `cmake` in the target build folder and point it at the root of this repo, then run `cmake --build .` from that target folder. You can also use different generators if you'd like to work in different IDE's like Xcode or Visual Studio by using the generator flag: +From there, building is identical to any other CMake project, e.g: + +1) Configure with `cmake -S . -B build` to create a `build` directory +2) Build with `cmake --build build` + +You can also use different generators if you'd like to work in different IDEs. + +Xcode: ```bash # generates into a folder called `build-cmake` # open the generated Xcode project in that folder -cmake -H. -Bbuild-cmake -GXcode - +cmake -H . -B build-cmake -G Xcode +``` +Visual Studio: +```bash # generates into a folder called `build-cmake` # open the generated Visual Studio 2022 solution in that folder -cmake -S . -B "build-cmake" -G "Visual Studio 17 2022" +cmake -S . -B build-cmake -G "Visual Studio 17 2022" ``` ## Libraries Used