fix filesystem pch breaking the impl

This commit is contained in:
altalk23 2023-02-08 17:37:37 +03:00
parent 4bf6344def
commit 478f70e900
9 changed files with 38 additions and 18 deletions

View file

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

4
FilesystemImpl.cpp Normal file
View file

@ -0,0 +1,4 @@
// filesystem implementation
#undef GHC_FILESYSTEM_H
#include <ghc/fs_impl.hpp>

View file

@ -40,6 +40,7 @@ file(GLOB OBJC_SOURCES
)
set_source_files_properties(${OBJC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
# Add platform sources
if (WIN32)

View file

@ -6,7 +6,7 @@
#include "picosha3.h"
#include "picosha2.h"
#include <vector>
#include <ghc/fs_fwd.hpp>
#include <ghc/filesystem.hpp>
static std::string calculateSHA3_256(ghc::filesystem::path const& path) {
std::vector<uint8_t> s(picosha3::bits_to_bytes(256));

View file

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

View file

@ -1,4 +1,4 @@
#include <ghc/fs_fwd.hpp>
#include <ghc/filesystem.hpp>
#include <mach-o/dyld.h>
#include <unistd.h>
#include <dlfcn.h>

View file

@ -1,6 +1,6 @@
#include <Windows.h>
#include <iostream>
#include <ghc/fs_fwd.hpp>
#include <ghc/filesystem.hpp>
void showError(std::string const& error) {
MessageBoxA(nullptr, error.c_str(), "Error Loading Geode", MB_ICONERROR);

View file

@ -40,6 +40,7 @@ public:
bool m_supportsDisabling = true;
bool m_supportsUnloading = false;
bool m_needsEarlyLoad = false;
bool m_isAPI = false;
std::shared_ptr<ModJson> m_rawJSON;
@ -96,7 +97,8 @@ Result<ModInfo> 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> ModInfo::createFromGeodeZip(utils::file::Unzip& zip) {
return Impl::createFromGeodeZip(zip);
}

View file

@ -8,7 +8,7 @@
#include <Geode/loader/SettingEvent.hpp>
#include <Geode/loader/ModJsonTest.hpp>
#include <Geode/utils/JsonValidation.hpp>
#include <ghc/fs_impl.hpp>
#include <array>
USE_GEODE_NAMESPACE();