Single cmakelist, because I'm done maintaining an unstable shitty build system, one is easier

This commit is contained in:
Simone Coco
2022-09-21 13:18:44 +02:00
committed by CocoSimone
parent d4c9399454
commit cff03301ac
18 changed files with 64 additions and 195 deletions

View File

@@ -26,7 +26,8 @@ jobs:
- name: Collect artifacts - name: Collect artifacts
run: | run: |
mkdir upload mkdir upload
cp -r build/{natsukashii,resources} upload cp -r resources upload
cp build/natsukashii upload
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
@@ -62,7 +63,8 @@ jobs:
- name: Collect artifacts - name: Collect artifacts
run: | run: |
mkdir upload mkdir upload
cp -r build/{natsukashii.exe,resources} upload cp -r resources upload
cp build/natsukashii.exe upload
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:

2
.gitmodules vendored
View File

@@ -1,6 +1,6 @@
[submodule "external/capstone"] [submodule "external/capstone"]
path = external/capstone path = external/capstone
url = https://github.com/capstone-engine/capstone/ url = https://github.com/capstone-engine/capstone
[submodule "external/nativefiledialog-extended"] [submodule "external/nativefiledialog-extended"]
path = external/nativefiledialog-extended path = external/nativefiledialog-extended
url = https://github.com/btzy/nativefiledialog-extended/ url = https://github.com/btzy/nativefiledialog-extended/

1
external/capstone vendored Submodule

Submodule external/capstone added at fee83fcc1a

View File

@@ -25,4 +25,4 @@ else()
endif() endif()
target_include_directories(imgui PUBLIC ${SDL2_INCLUDE_DIRS} imgui imgui/backends) target_include_directories(imgui PUBLIC ${SDL2_INCLUDE_DIRS} imgui imgui/backends)
target_link_libraries(imgui PUBLIC SDL2main SDL2 ${LIBRARIES} ) target_link_libraries(imgui PUBLIC ${SDL2_LIBRARIES} ${LIBRARIES})

View File

@@ -3,6 +3,7 @@ project(parallel-rdp)
file(GLOB_RECURSE parallel-rdp-cpp parallel-rdp-standalone/parallel-rdp/*.cpp) file(GLOB_RECURSE parallel-rdp-cpp parallel-rdp-standalone/parallel-rdp/*.cpp)
find_package(PkgConfig REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
add_library(parallel-rdp add_library(parallel-rdp
@@ -51,6 +52,7 @@ add_library(parallel-rdp
target_compile_definitions(parallel-rdp PUBLIC GRANITE_VULKAN_MT) target_compile_definitions(parallel-rdp PUBLIC GRANITE_VULKAN_MT)
target_include_directories(parallel-rdp PUBLIC target_include_directories(parallel-rdp PUBLIC
${SDL2_INCLUDE_DIRS}
parallel-rdp-standalone/parallel-rdp parallel-rdp-standalone/parallel-rdp
parallel-rdp-standalone/volk parallel-rdp-standalone/volk
parallel-rdp-standalone/spirv-cross parallel-rdp-standalone/spirv-cross
@@ -63,11 +65,11 @@ target_include_directories(parallel-rdp PUBLIC
../../src/n64/core/cpu/registers ../../src/n64/core/cpu/registers
parallel-rdp-standalone parallel-rdp-standalone
.. ..
../capstone/include
../../src/frontend ../../src/frontend
../../src/frontend/imgui ../../src/frontend/imgui
../../src/frontend/imgui/debugger ../../src/frontend/imgui/debugger
../../src ../../src
../capstone/include
../imgui ../imgui
../imgui/imgui ../imgui/imgui
../imgui/imgui/backends ../imgui/imgui/backends
@@ -81,7 +83,7 @@ else()
set(LIBRARIES ) set(LIBRARIES )
endif() endif()
target_link_libraries(parallel-rdp SDL2main SDL2 ${LIBRARIES}) target_link_libraries(parallel-rdp ${SDL2_LIBRARIES} ${LIBRARIES})
if(WIN32) if(WIN32)
target_compile_definitions(parallel-rdp PUBLIC VK_USE_PLATFORM_WIN32_KHR) target_compile_definitions(parallel-rdp PUBLIC VK_USE_PLATFORM_WIN32_KHR)

View File

@@ -1,7 +1,6 @@
#pragma once #pragma once
#include <Core.hpp> #include <Core.hpp>
#include <wsi.hpp> #include <wsi.hpp>
#include <SDL2/SDL.h>
#include <core/mmio/VI.hpp> #include <core/mmio/VI.hpp>
struct Window; struct Window;

View File

@@ -1,27 +1,50 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
project(natsukashii) project(natsukashii)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)
#add_compile_definitions(VULKAN_DEBUG) file(GLOB_RECURSE CORE_SOURCES n64/*.cpp)
file(COPY ${CMAKE_SOURCE_DIR}/../resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(GLOB_RECURSE CORE_HEADERS n64/*.hpp)
file(GLOB_RECURSE FRONTEND_SOURCES frontend/*.cpp)
add_subdirectory(n64) file(GLOB_RECURSE FRONTEND_HEADERS frontend/*.hpp)
add_subdirectory(frontend)
find_package(SDL2 REQUIRED)
find_package(fmt 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) add_executable(natsukashii
set(OPTIMIZATIONS -g -O0 ${CORE_SOURCES}
#-fsanitize=address -fsanitize=undefined ${CORE_HEADERS}
) ${FRONTEND_SOURCES}
#target_link_libraries(natsukashii PUBLIC -fsanitize=address -fsanitize=undefined) ${FRONTEND_HEADERS}
elseif(CMAKE_BUILD_TYPE MATCHES Release) main.cpp
set(OPTIMIZATIONS -O3) )
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() endif()
target_link_libraries(natsukashii PUBLIC frontend n64 fmt) target_link_libraries(natsukashii PRIVATE ${SDL2_LIBRARIES} ${LIBRARIES} capstone-static nfd parallel-rdp imgui fmt::fmt nlohmann_json::nlohmann_json)
target_include_directories(natsukashii PUBLIC . ../external)
target_compile_options(natsukashii PUBLIC ${OPTIMIZATIONS})

View File

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

View File

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

View File

@@ -6,6 +6,7 @@
#include <Audio.hpp> #include <Audio.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <filesystem> #include <filesystem>
#include <SDL.h>
VkInstance instance{}; VkInstance instance{};
using json = nlohmann::json; using json = nlohmann::json;

View File

@@ -3,7 +3,7 @@
#include <imgui.h> #include <imgui.h>
#include <imgui_impl_sdl.h> #include <imgui_impl_sdl.h>
#include <imgui_impl_vulkan.h> #include <imgui_impl_vulkan.h>
#include <SDL2/SDL_video.h> #include <SDL.h>
#include <Core.hpp> #include <Core.hpp>
#include <vector> #include <vector>

View File

@@ -1,7 +1,10 @@
#define SDL_MAIN_HANDLED
#include <frontend/App.hpp> #include <frontend/App.hpp>
int main(int argc, char* argv[]) { #ifdef _WIN32
#define main SDL_main
#endif
int main(int argc, char** argv) {
App* app = new App; App* app = new App;
if(argc > 1) { if(argc > 1) {
app->LoadROM(argv[1]); app->LoadROM(argv[1]);

View File

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

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> #include <SDL_events.h>
#include <Cpu.hpp> #include <Cpu.hpp>
#include <Mem.hpp> #include <Mem.hpp>
#include <string> #include <string>

View File

@@ -1,6 +1,6 @@
#include "Audio.hpp" #include <Audio.hpp>
#include <SDL2/SDL.h> #include <SDL_audio.h>
#include "util.hpp" #include <util.hpp>
namespace n64 { namespace n64 {
#define AUDIO_SAMPLE_RATE 48000 #define AUDIO_SAMPLE_RATE 48000

View File

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

View File

@@ -93,7 +93,6 @@ inline void Cpu::disassembly(u32 instr) const {
cs_insn *insn; cs_insn *insn;
u8 code[4]; u8 code[4];
//u32 temp = bswap_32(instr);
memcpy(code, &instr, 4); memcpy(code, &instr, 4);
count = cs_disasm(handle, code, 4, regs.pc, 0, &insn); 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); u32 instruction = mem.Read32(regs, regs.pc, regs.pc);
disassembly(instruction); //disassembly(instruction);
regs.oldPC = regs.pc; regs.oldPC = regs.pc;
regs.pc = regs.nextPC; regs.pc = regs.nextPC;

View File

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