From cff03301ac3d7e04e957d9217edc69681f698724 Mon Sep 17 00:00:00 2001 From: Simone Coco Date: Wed, 21 Sep 2022 13:18:44 +0200 Subject: [PATCH] Single cmakelist, because I'm done maintaining an unstable shitty build system, one is easier --- .github/workflows/build.yml | 6 +- .gitmodules | 2 +- external/capstone | 1 + external/imgui/CMakeLists.txt | 2 +- external/parallel-rdp/CMakeLists.txt | 6 +- external/parallel-rdp/ParallelRDPWrapper.hpp | 1 - src/CMakeLists.txt | 59 ++++++++++++++------ src/frontend/CMakeLists.txt | 23 -------- src/frontend/imgui/CMakeLists.txt | 38 ------------- src/frontend/imgui/Window.cpp | 1 + src/frontend/imgui/Window.hpp | 2 +- src/main.cpp | 7 ++- src/n64/CMakeLists.txt | 22 -------- src/n64/Core.hpp | 2 +- src/n64/core/Audio.cpp | 6 +- src/n64/core/CMakeLists.txt | 56 ------------------- src/n64/core/Cpu.cpp | 3 +- src/n64/core/cpu/CMakeLists.txt | 22 -------- 18 files changed, 64 insertions(+), 195 deletions(-) create mode 160000 external/capstone delete mode 100644 src/frontend/CMakeLists.txt delete mode 100644 src/frontend/imgui/CMakeLists.txt delete mode 100644 src/n64/CMakeLists.txt delete mode 100644 src/n64/core/CMakeLists.txt delete mode 100644 src/n64/core/cpu/CMakeLists.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f66f172..bf51db96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,8 @@ jobs: - name: Collect artifacts run: | mkdir upload - cp -r build/{natsukashii,resources} upload + cp -r resources upload + cp build/natsukashii upload - name: Upload artifacts uses: actions/upload-artifact@v2 with: @@ -62,7 +63,8 @@ jobs: - name: Collect artifacts run: | mkdir upload - cp -r build/{natsukashii.exe,resources} upload + cp -r resources upload + cp build/natsukashii.exe upload - name: Upload artifacts uses: actions/upload-artifact@v2 with: diff --git a/.gitmodules b/.gitmodules index e3599ada..0be770c5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "external/capstone"] path = external/capstone - url = https://github.com/capstone-engine/capstone/ + url = https://github.com/capstone-engine/capstone [submodule "external/nativefiledialog-extended"] path = external/nativefiledialog-extended url = https://github.com/btzy/nativefiledialog-extended/ diff --git a/external/capstone b/external/capstone new file mode 160000 index 00000000..fee83fcc --- /dev/null +++ b/external/capstone @@ -0,0 +1 @@ +Subproject commit fee83fcc1ad096c22d4f2066ccb58ad1a76a9886 diff --git a/external/imgui/CMakeLists.txt b/external/imgui/CMakeLists.txt index 3e11133a..8ff38525 100644 --- a/external/imgui/CMakeLists.txt +++ b/external/imgui/CMakeLists.txt @@ -25,4 +25,4 @@ else() endif() target_include_directories(imgui PUBLIC ${SDL2_INCLUDE_DIRS} imgui imgui/backends) -target_link_libraries(imgui PUBLIC SDL2main SDL2 ${LIBRARIES} ) \ No newline at end of file +target_link_libraries(imgui PUBLIC ${SDL2_LIBRARIES} ${LIBRARIES}) \ No newline at end of file diff --git a/external/parallel-rdp/CMakeLists.txt b/external/parallel-rdp/CMakeLists.txt index d48b2ded..d44af950 100644 --- a/external/parallel-rdp/CMakeLists.txt +++ b/external/parallel-rdp/CMakeLists.txt @@ -3,6 +3,7 @@ project(parallel-rdp) file(GLOB_RECURSE parallel-rdp-cpp parallel-rdp-standalone/parallel-rdp/*.cpp) +find_package(PkgConfig REQUIRED) find_package(SDL2 REQUIRED) add_library(parallel-rdp @@ -51,6 +52,7 @@ add_library(parallel-rdp target_compile_definitions(parallel-rdp PUBLIC GRANITE_VULKAN_MT) target_include_directories(parallel-rdp PUBLIC + ${SDL2_INCLUDE_DIRS} parallel-rdp-standalone/parallel-rdp parallel-rdp-standalone/volk parallel-rdp-standalone/spirv-cross @@ -63,11 +65,11 @@ target_include_directories(parallel-rdp PUBLIC ../../src/n64/core/cpu/registers parallel-rdp-standalone .. + ../capstone/include ../../src/frontend ../../src/frontend/imgui ../../src/frontend/imgui/debugger ../../src - ../capstone/include ../imgui ../imgui/imgui ../imgui/imgui/backends @@ -81,7 +83,7 @@ else() set(LIBRARIES ) endif() -target_link_libraries(parallel-rdp SDL2main SDL2 ${LIBRARIES}) +target_link_libraries(parallel-rdp ${SDL2_LIBRARIES} ${LIBRARIES}) if(WIN32) target_compile_definitions(parallel-rdp PUBLIC VK_USE_PLATFORM_WIN32_KHR) diff --git a/external/parallel-rdp/ParallelRDPWrapper.hpp b/external/parallel-rdp/ParallelRDPWrapper.hpp index 3e526322..e1b1f702 100644 --- a/external/parallel-rdp/ParallelRDPWrapper.hpp +++ b/external/parallel-rdp/ParallelRDPWrapper.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include struct Window; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5777927..833c7e38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,27 +1,50 @@ cmake_minimum_required(VERSION 3.20) project(natsukashii) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED true) -#add_compile_definitions(VULKAN_DEBUG) -file(COPY ${CMAKE_SOURCE_DIR}/../resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -add_subdirectory(n64) -add_subdirectory(frontend) +file(GLOB_RECURSE CORE_SOURCES n64/*.cpp) +file(GLOB_RECURSE CORE_HEADERS n64/*.hpp) +file(GLOB_RECURSE FRONTEND_SOURCES frontend/*.cpp) +file(GLOB_RECURSE FRONTEND_HEADERS frontend/*.hpp) +find_package(SDL2 REQUIRED) find_package(fmt REQUIRED) +find_package(nlohmann_json REQUIRED) -add_executable(natsukashii main.cpp) +add_subdirectory(../external/capstone capstone) +add_subdirectory(../external/parallel-rdp prdp) +add_subdirectory(../external/imgui imgui) +add_subdirectory(../external/nativefiledialog-extended nfd) -if (CMAKE_BUILD_TYPE MATCHES Debug) - set(OPTIMIZATIONS -g -O0 - #-fsanitize=address -fsanitize=undefined - ) - #target_link_libraries(natsukashii PUBLIC -fsanitize=address -fsanitize=undefined) -elseif(CMAKE_BUILD_TYPE MATCHES Release) - set(OPTIMIZATIONS -O3) +add_executable(natsukashii + ${CORE_SOURCES} + ${CORE_HEADERS} + ${FRONTEND_SOURCES} + ${FRONTEND_HEADERS} + main.cpp +) + +target_include_directories(natsukashii PRIVATE + . + n64 + n64/core + n64/core/cpu/ + n64/core/cpu/registers + n64/core/mmio + n64/core/rsp + frontend + frontend/imgui + ../external + ../external/imgui/imgui + ../external/parallel-rdp/ + ../external/nativefiledialog-extended/src/include + ../external/capstone/include +) + +if(WIN32) + target_compile_options(natsukashii PRIVATE -mwindows) + set(LIBRARIES -static z stdc++ user32 gdi32 winmm Imm32 ole32 oleaut32 shell32 setupapi version uuid) +else() + set(LIBRARIES ) endif() -target_link_libraries(natsukashii PUBLIC frontend n64 fmt) -target_include_directories(natsukashii PUBLIC . ../external) -target_compile_options(natsukashii PUBLIC ${OPTIMIZATIONS}) +target_link_libraries(natsukashii PRIVATE ${SDL2_LIBRARIES} ${LIBRARIES} capstone-static nfd parallel-rdp imgui fmt::fmt nlohmann_json::nlohmann_json) \ No newline at end of file diff --git a/src/frontend/CMakeLists.txt b/src/frontend/CMakeLists.txt deleted file mode 100644 index c31ce6c2..00000000 --- a/src/frontend/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(frontend) - -add_subdirectory(imgui) - -add_library(frontend - App.hpp - App.cpp) - -target_include_directories(frontend PUBLIC - . - .. - ../../external - ../../external/capstone/include - ../../external/parallel-rdp - ../../external/parallel-rdp/parallel-rdp-standalone/vulkan - ../../external/parallel-rdp/parallel-rdp-standalone/util - ../../external/parallel-rdp/parallel-rdp-standalone/volk - ../n64 - ../n64/core - ../n64/core/cpu - ../n64/core/cpu/registers) -target_link_libraries(frontend PUBLIC frontend-imgui) diff --git a/src/frontend/imgui/CMakeLists.txt b/src/frontend/imgui/CMakeLists.txt deleted file mode 100644 index 9657192e..00000000 --- a/src/frontend/imgui/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(frontend-imgui) - -add_subdirectory(../../../external/imgui temp) -add_subdirectory(../../../external/nativefiledialog-extended temp1) -SET(NFD_PORTAL ON CACHE BOOL "Use dbus for native file dialog instead of gtk") - -find_package(SDL2 REQUIRED) -find_package(fmt REQUIRED) -find_package(nlohmann_json REQUIRED) - -add_library(frontend-imgui STATIC - Window.cpp - Window.hpp) - -target_include_directories(frontend-imgui PUBLIC - . - debugger - ../.. - ../../n64 - ../../n64/core - ../../n64/core/cpu - ../../n64/core/cpu/registers - ../../../external - ../../../external/capstone/include - ../../../external/parallel-rdp/parallel-rdp-standalone - ../../../external/parallel-rdp/parallel-rdp-standalone/vulkan - ../../../external/parallel-rdp/parallel-rdp-standalone/util - ../../../external/parallel-rdp/parallel-rdp-standalone/volk) - -if(WIN32) - target_compile_options(frontend-imgui PUBLIC -mwindows) - set(LIBRARIES -static z stdc++ user32 gdi32 winmm Imm32 ole32 oleaut32 shell32 setupapi version uuid) -else() - set(LIBRARIES ) -endif() - -target_link_libraries(frontend-imgui PUBLIC nlohmann_json::nlohmann_json SDL2main SDL2 ${LIBRARIES} imgui nfd fmt) \ No newline at end of file diff --git a/src/frontend/imgui/Window.cpp b/src/frontend/imgui/Window.cpp index bd81f9dd..c0c3ba1c 100644 --- a/src/frontend/imgui/Window.cpp +++ b/src/frontend/imgui/Window.cpp @@ -6,6 +6,7 @@ #include #include #include +#include VkInstance instance{}; using json = nlohmann::json; diff --git a/src/frontend/imgui/Window.hpp b/src/frontend/imgui/Window.hpp index 8223c9f5..f7b4218a 100644 --- a/src/frontend/imgui/Window.hpp +++ b/src/frontend/imgui/Window.hpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/main.cpp b/src/main.cpp index 0b09dc85..65d8e041 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,10 @@ -#define SDL_MAIN_HANDLED #include -int main(int argc, char* argv[]) { +#ifdef _WIN32 +#define main SDL_main +#endif + +int main(int argc, char** argv) { App* app = new App; if(argc > 1) { app->LoadROM(argv[1]); diff --git a/src/n64/CMakeLists.txt b/src/n64/CMakeLists.txt deleted file mode 100644 index 570817f1..00000000 --- a/src/n64/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(n64) - -add_subdirectory(core) - -find_package(fmt REQUIRED) -find_package(SDL2 REQUIRED) - -add_library(n64 - Core.cpp - Core.hpp - memory_regions.hpp) - -target_link_libraries(n64 PUBLIC core fmt SDL2main SDL2) -target_include_directories(n64 PUBLIC - . - .. - ../frontend/imgui/debugger - ../../external - ../../external/capstone/include - ../../external/imgui/imgui - ../../external/imgui/imgui/backends) diff --git a/src/n64/Core.hpp b/src/n64/Core.hpp index c123cfd9..a09b5568 100644 --- a/src/n64/Core.hpp +++ b/src/n64/Core.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include #include diff --git a/src/n64/core/Audio.cpp b/src/n64/core/Audio.cpp index 1e914809..8f83d1e4 100644 --- a/src/n64/core/Audio.cpp +++ b/src/n64/core/Audio.cpp @@ -1,6 +1,6 @@ -#include "Audio.hpp" -#include -#include "util.hpp" +#include +#include +#include namespace n64 { #define AUDIO_SAMPLE_RATE 48000 diff --git a/src/n64/core/CMakeLists.txt b/src/n64/core/CMakeLists.txt deleted file mode 100644 index 07dc5535..00000000 --- a/src/n64/core/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(core) - -add_subdirectory(cpu) - -add_subdirectory(../../../external/parallel-rdp temp) -add_subdirectory(../../../external/capstone temp1) - -find_package(fmt REQUIRED) -find_package(SDL2 REQUIRED) - -add_library(core - Cpu.hpp - Cpu.cpp - Mem.cpp - Mem.hpp - RDP.cpp - RDP.hpp - Audio.cpp - Audio.hpp - mmio/AI.cpp - mmio/AI.hpp - mmio/Interrupt.cpp - mmio/Interrupt.hpp - mmio/MI.cpp - mmio/MI.hpp - mmio/PI.cpp - mmio/PI.hpp - mmio/PIF.cpp - mmio/PIF.hpp - mmio/RI.cpp - mmio/RI.hpp - mmio/SI.cpp - mmio/SI.hpp - mmio/VI.cpp - mmio/VI.hpp - MMIO.cpp - MMIO.hpp - RSP.cpp - RSP.hpp - rsp/decode.cpp - rsp/instructions.cpp) - -target_include_directories(core PUBLIC - . - .. - ../.. - ../../frontend/imgui/debugger - ../../../external - ../../../external/capstone/include - ../../../external/imgui/imgui - ../../../external/imgui/imgui/debugger - ../../../external/imgui/imgui/backends - mmio) - -target_link_libraries(core PUBLIC capstone fmt cpu parallel-rdp) diff --git a/src/n64/core/Cpu.cpp b/src/n64/core/Cpu.cpp index 57e34dbd..d0db2c87 100644 --- a/src/n64/core/Cpu.cpp +++ b/src/n64/core/Cpu.cpp @@ -93,7 +93,6 @@ inline void Cpu::disassembly(u32 instr) const { cs_insn *insn; u8 code[4]; - //u32 temp = bswap_32(instr); memcpy(code, &instr, 4); count = cs_disasm(handle, code, 4, regs.pc, 0, &insn); @@ -117,7 +116,7 @@ void Cpu::Step(Mem& mem) { u32 instruction = mem.Read32(regs, regs.pc, regs.pc); - disassembly(instruction); + //disassembly(instruction); regs.oldPC = regs.pc; regs.pc = regs.nextPC; diff --git a/src/n64/core/cpu/CMakeLists.txt b/src/n64/core/cpu/CMakeLists.txt deleted file mode 100644 index 80633929..00000000 --- a/src/n64/core/cpu/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(cpu) - -add_library(cpu - decode.cpp - instructions.cpp - Registers.cpp - Registers.hpp - registers/Cop0.cpp - registers/Cop0.hpp - registers/cop0instructions.cpp - registers/Cop1.cpp - registers/Cop1.hpp - registers/cop1instructions.cpp) - -target_include_directories(cpu PUBLIC registers - . .. - ../../../../external - ../../../../external/capstone/include - ../../../../src - ../../ -)