From 478f70e900649460f77d75b8a5ef117fdfe41622 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Wed, 8 Feb 2023 17:37:37 +0300 Subject: [PATCH] fix filesystem pch breaking the impl --- CMakeLists.txt | 29 ++++++++++++++---------- FilesystemImpl.cpp | 4 ++++ loader/CMakeLists.txt | 1 + loader/hash/hash.hpp | 2 +- loader/include/Geode/loader/ModInfo.hpp | 3 ++- loader/launcher/mac/Bootstrapper.cpp | 2 +- loader/launcher/windows/Bootstrapper.cpp | 2 +- loader/src/loader/ModInfo.cpp | 11 ++++++++- loader/src/main.cpp | 2 +- 9 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 FilesystemImpl.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 65075a92..74774539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,23 @@ include(cmake/GeodeFile.cmake) include(cmake/Platform.cmake) include(cmake/CPM.cmake) +CPMAddPackage("gh:geode-sdk/json#2b76460") +CPMAddPackage("gh:fmtlib/fmt#9.1.0") +CPMAddPackage("gh:gulrak/filesystem#3e5b930") + +# Tulip hook (hooking) +if (PROJECT_IS_TOP_LEVEL AND NOT GEODE_BUILDING_DOCS) + set(TULIP_LINK_SOURCE ON) +endif() +CPMAddPackage("gh:geode-sdk/TulipHook#76984a4") + + target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp) +# Filesystem implementation in a separate target because i couldnt disable pch +add_library(GeodeFilesystemImpl ${CMAKE_CURRENT_SOURCE_DIR}/FilesystemImpl.cpp) +target_link_libraries(GeodeFilesystemImpl PUBLIC ghc_filesystem) + include(ExternalProject) set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen) ExternalProject_Add(CodegenProject @@ -103,7 +118,7 @@ endif() add_library(GeodeCodegenSources ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp ${GEODE_CODEGEN_PATH}/Geode/GeneratedAddress.cpp) target_link_directories(GeodeCodegenSources PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link) -target_link_libraries(GeodeCodegenSources PRIVATE ghc_filesystem fmt TulipHookInclude) +target_link_libraries(GeodeCodegenSources PRIVATE ghc_filesystem GeodeFilesystemImpl fmt TulipHookInclude) target_include_directories(GeodeCodegenSources PRIVATE ${GEODE_CODEGEN_PATH} ${GEODE_LOADER_PATH}/include @@ -127,17 +142,7 @@ target_include_directories(${PROJECT_NAME} INTERFACE ) target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link) -CPMAddPackage("gh:geode-sdk/json#2b76460") -CPMAddPackage("gh:fmtlib/fmt#9.1.0") -CPMAddPackage("gh:gulrak/filesystem#3e5b930") - -# Tulip hook (hooking) -if (PROJECT_IS_TOP_LEVEL AND NOT GEODE_BUILDING_DOCS) - set(TULIP_LINK_SOURCE ON) -endif() -CPMAddPackage("gh:geode-sdk/TulipHook#76984a4") - -target_link_libraries(${PROJECT_NAME} INTERFACE ghc_filesystem fmt TulipHookInclude GeodeCodegenSources mat-json) +target_link_libraries(${PROJECT_NAME} INTERFACE ghc_filesystem fmt TulipHookInclude GeodeCodegenSources mat-json GeodeFilesystemImpl) if (NOT EXISTS ${GEODE_BIN_PATH}) diff --git a/FilesystemImpl.cpp b/FilesystemImpl.cpp new file mode 100644 index 00000000..58cdc9b4 --- /dev/null +++ b/FilesystemImpl.cpp @@ -0,0 +1,4 @@ +// filesystem implementation +#undef GHC_FILESYSTEM_H +#include + diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 7b1b519a..a6d93936 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -40,6 +40,7 @@ file(GLOB OBJC_SOURCES ) set_source_files_properties(${OBJC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + # Add platform sources if (WIN32) diff --git a/loader/hash/hash.hpp b/loader/hash/hash.hpp index 67b2e9bc..05f01593 100644 --- a/loader/hash/hash.hpp +++ b/loader/hash/hash.hpp @@ -6,7 +6,7 @@ #include "picosha3.h" #include "picosha2.h" #include -#include +#include static std::string calculateSHA3_256(ghc::filesystem::path const& path) { std::vector s(picosha3::bits_to_bytes(256)); diff --git a/loader/include/Geode/loader/ModInfo.hpp b/loader/include/Geode/loader/ModInfo.hpp index d2278c7a..7d6f0d23 100644 --- a/loader/include/Geode/loader/ModInfo.hpp +++ b/loader/include/Geode/loader/ModInfo.hpp @@ -159,7 +159,8 @@ namespace geode { /** * Whether this mod is an API or not */ - bool isAPI = false; + bool& isAPI(); + bool const& isAPI() const; /** * Create ModInfo from an unzipped .geode package */ diff --git a/loader/launcher/mac/Bootstrapper.cpp b/loader/launcher/mac/Bootstrapper.cpp index 9c97eafd..0fbf8642 100644 --- a/loader/launcher/mac/Bootstrapper.cpp +++ b/loader/launcher/mac/Bootstrapper.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/loader/launcher/windows/Bootstrapper.cpp b/loader/launcher/windows/Bootstrapper.cpp index 02ccdd88..84b75896 100644 --- a/loader/launcher/windows/Bootstrapper.cpp +++ b/loader/launcher/windows/Bootstrapper.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include void showError(std::string const& error) { MessageBoxA(nullptr, error.c_str(), "Error Loading Geode", MB_ICONERROR); diff --git a/loader/src/loader/ModInfo.cpp b/loader/src/loader/ModInfo.cpp index 99b8138e..0529b8f8 100644 --- a/loader/src/loader/ModInfo.cpp +++ b/loader/src/loader/ModInfo.cpp @@ -40,6 +40,7 @@ public: bool m_supportsDisabling = true; bool m_supportsUnloading = false; bool m_needsEarlyLoad = false; + bool m_isAPI = false; std::shared_ptr m_rawJSON; @@ -96,7 +97,8 @@ Result ModInfo::Impl::createFromSchemaV010(ModJson const& rawJson) { root.has("unloadable").into(impl->m_supportsUnloading); root.has("early-load").into(impl->m_needsEarlyLoad); if (root.has("api")) { - impl->isAPI = true; + // TODO: figure out what got wiped with merge + // impl->isAPI = true; } for (auto& dep : root.has("dependencies").iterate()) { @@ -432,6 +434,13 @@ bool const& ModInfo::needsEarlyLoad() const { return m_impl->m_needsEarlyLoad; } +bool& ModInfo::isAPI() { + return m_impl->m_isAPI; +} +bool const& ModInfo::isAPI() const { + return m_impl->m_isAPI; +} + Result ModInfo::createFromGeodeZip(utils::file::Unzip& zip) { return Impl::createFromGeodeZip(zip); } diff --git a/loader/src/main.cpp b/loader/src/main.cpp index 8b45c933..71fd07aa 100644 --- a/loader/src/main.cpp +++ b/loader/src/main.cpp @@ -8,7 +8,7 @@ #include #include #include -#include + #include USE_GEODE_NAMESPACE();