From 486f5ab751bd4b751eb907adb45aecd8610fe9b1 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Sat, 31 Dec 2022 00:50:12 +0200 Subject: [PATCH] add stuff for docs genning and fix issues for it --- CMakeLists.txt | 1 + cmake/GeodeFile.cmake | 13 +++- flash.toml | 55 ++++++++++++++++ loader/CMakeLists.txt | 22 ++++--- .../third_party/win32/pthread/pthread.h | 2 +- loader/include/Geode/loader/Dispatch.hpp | 62 ++++++++++--------- loader/include/Geode/loader/ModInfo.hpp | 1 + loader/include/Geode/meta/membercall.hpp | 4 +- 8 files changed, 115 insertions(+), 45 deletions(-) create mode 100644 flash.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index d1960146..d6a68f71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen) ExternalProject_Add(CodegenProject SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/codegen CMAKE_CACHE_ARGS "-DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT}" + CMAKE_ARGS ${GEODE_CODEGEN_CMAKE_ARGS} ) add_custom_command( diff --git a/cmake/GeodeFile.cmake b/cmake/GeodeFile.cmake index df668558..8f89472b 100644 --- a/cmake/GeodeFile.cmake +++ b/cmake/GeodeFile.cmake @@ -132,9 +132,18 @@ function(package_geode_resources_now proname src dest header_dest) if (GEODE_DISABLE_CLI_CALLS) message(WARNING "package_geode_resources_now called, but GEODE_DISABLE_CLI_CALLS - is set to true - Ignoring it as this function requires CLI calls - in order to work" + is set to true - Faking output result in case you only wish to + analyze the project statically, do not expect built project to + function properly" ) + set(HEADER_FILE + "#include \n\n" + "static const std::unordered_map " + "LOADER_RESOURCE_HASHES {};\n" + ) + file(WRITE ${header_dest} ${HEADER_FILE}) + message(STATUS "Wrote fake resource hashes to ${header_dest}") + return() endif() if(GEODE_CLI STREQUAL "GEODE_CLI-NOTFOUND") diff --git a/flash.toml b/flash.toml new file mode 100644 index 00000000..5c5348b1 --- /dev/null +++ b/flash.toml @@ -0,0 +1,55 @@ + +# Configuration file for the Flash C++ documentation generator. +# https://github.com/hjfod/flash + +[project] +name = "Geode" +version = "v1.0.0-beta" +repository = "https://github.com/geode-sdk/geode" + +[docs] +include = [ + "loader/include/Geode/**/*.hpp", + "loader/include/Geode/**/*.h", + "build/codegenned/Geode/binding/*.hpp" +] +exclude = [ + "loader/include/Geode/modify/Comparer.hpp", + "loader/include/Geode/platform/*.hpp", + "loader/include/Geode/c++stl/*.hpp", + # All of the relevant cocos headers are included through Geode headers + "loader/include/Geode/cocos/**/*.h" +] +tree = "https://github.com/geode-sdk/geode/tree/main" + +# Root folders to show in the navigation browser + +[[browser.roots]] +path = "loader/include/Geode" +include-prefix = "Geode" +name = "Geode" + +[[browser.roots]] +path = "build/codegenned/Geode/binding" +include-prefix = "Geode/binding" +name = "Bindings" + +[cmake] +config-args = [ + "-G", "Ninja", + "-DCMAKE_CXX_COMPILER=Clang", + "-DCMAKE_C_COMPILER=Clang", + "-DGEODE_DISABLE_CLI_CALLS=On", + "-DGEODE_PLATFORM_NAME=Win32", + "-DCMAKE_EXPORT_COMPILE_COMMANDS=On", + "-DGEODE_DISABLE_PRECOMPILED_HEADERS=On", + "-DGEODE_CODEGEN_CMAKE_ARGS=-DCMAKE_CXX_COMPILER=Clang;-DCMAKE_C_COMPILER=Clang", + "-DCMAKE_C_FLAGS=-m32", + "-DCMAKE_CXX_FLAGS=-m32", + "-DWIN32=On" +] +build = true +build-args = [ + "--target", "CodegenRun" +] +infer-args-from = "loader/src/main.cpp" diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 06ac8305..a5d5651c 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -139,16 +139,18 @@ add_subdirectory(lilac) target_link_libraries(${PROJECT_NAME} md4c z lilac_hook geode-sdk re2) # Use precompiled headers for faster builds -target_precompile_headers(${PROJECT_NAME} PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/DefaultInclude.hpp" - # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Loader.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/UI.hpp" - # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Modify.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/include/cocos2d.h" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/extensions/cocos-ext.h" -) +if (NOT GEODE_DISABLE_PRECOMPILED_HEADERS) + target_precompile_headers(${PROJECT_NAME} PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/DefaultInclude.hpp" + # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Loader.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/UI.hpp" + # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Modify.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/include/cocos2d.h" + "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/extensions/cocos-ext.h" + ) +endif() # Create launcher if (APPLE) diff --git a/loader/include/Geode/cocos/platform/third_party/win32/pthread/pthread.h b/loader/include/Geode/cocos/platform/third_party/win32/pthread/pthread.h index 304bbf42..9fde63a5 100644 --- a/loader/include/Geode/cocos/platform/third_party/win32/pthread/pthread.h +++ b/loader/include/Geode/cocos/platform/third_party/win32/pthread/pthread.h @@ -285,7 +285,7 @@ enum { # endif #endif -#include <../pthread/sched.h> +#include "sched.h" /* * To avoid including windows.h we define only those things that we diff --git a/loader/include/Geode/loader/Dispatch.hpp b/loader/include/Geode/loader/Dispatch.hpp index 9503e862..c020c49f 100644 --- a/loader/include/Geode/loader/Dispatch.hpp +++ b/loader/include/Geode/loader/Dispatch.hpp @@ -9,40 +9,42 @@ namespace geode { // Mod interoperability - template - class DispatchEvent : public Event { - std::string m_selector; - std::tuple m_args; + // todo: update to new event system - public: - DispatchEvent(std::string const& name, Args... args) : - m_selector(name), m_args(std::make_tuple(args...)) {} + // template + // class DispatchEvent : public Event { + // std::string m_selector; + // std::tuple m_args; - std::string const& selector() { - return m_selector; - } - }; + // public: + // DispatchEvent(std::string const& name, Args... args) : + // m_selector(name), m_args(std::make_tuple(args...)) {} - template - class DispatchHandler : public EventHandler> { - std::string m_selector; - std::function m_callback; + // std::string const& selector() { + // return m_selector; + // } + // }; - DispatchHandler(std::string const& name, std::function callback) : - m_selector(name), m_callback(callback) {} + // template + // class DispatchHandler : public EventHandler> { + // std::string m_selector; + // std::function m_callback; - public: - bool handle(DispatchEvent* ev) { - if (ev->name() == m_selector) { - std::apply(m_callback, ev->m_args); - } - return true; - } + // DispatchHandler(std::string const& name, std::function callback) : + // m_selector(name), m_callback(callback) {} - static DispatchHandler* create( - std::string const& name, std::function callback - ) { - return new DispatchHandler(name, callback); - } - }; + // public: + // bool handle(DispatchEvent* ev) { + // if (ev->name() == m_selector) { + // std::apply(m_callback, ev->m_args); + // } + // return true; + // } + + // static DispatchHandler* create( + // std::string const& name, std::function callback + // ) { + // return new DispatchHandler(name, callback); + // } + // }; } \ No newline at end of file diff --git a/loader/include/Geode/loader/ModInfo.hpp b/loader/include/Geode/loader/ModInfo.hpp index 3a7810fb..a333f365 100644 --- a/loader/include/Geode/loader/ModInfo.hpp +++ b/loader/include/Geode/loader/ModInfo.hpp @@ -4,6 +4,7 @@ #include "../external/json/json.hpp" #include "../utils/VersionInfo.hpp" #include "../utils/Result.hpp" +#include "Setting.hpp" namespace geode { namespace utils::file { diff --git a/loader/include/Geode/meta/membercall.hpp b/loader/include/Geode/meta/membercall.hpp index 6a70a241..04bccff0 100644 --- a/loader/include/Geode/meta/membercall.hpp +++ b/loader/include/Geode/meta/membercall.hpp @@ -199,10 +199,10 @@ namespace geode::core::meta::x86 { using Sequences = typename Membercall::Sequences; // Where all the logic is actually implemented. - template + template class Impl { static_assert( - always_false, + always_false, "Please report a bug to the Geode developers! This should never be reached.\n" "SFINAE didn't reach the right overload!" );