diff --git a/CMakeLists.txt b/CMakeLists.txt index b194a85c..c76c4a3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_CONFIGURE_DEPENDS VERSION target_compile_definitions(${PROJECT_NAME} INTERFACE -DPROJECT_NAME=${CMAKE_PROJECT_NAME}) -set(GEODE_CODEGEN_PATH ${CMAKE_CURRENT_BINARY_DIR}/codegenned) set(GEODE_BIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(GEODE_LOADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/loader) set(GEODE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) @@ -143,10 +142,11 @@ if (DEFINED ENV{GEODE_BINDINGS_REPO_PATH}) set(temp $ENV{GEODE_BINDINGS_REPO_PATH}) # this is so stupid i hate windows paths string(REPLACE "\\" "/" GEODE_BINDINGS_REPO_PATH ${temp}) + add_subdirectory(${GEODE_BINDINGS_REPO_PATH} bindings) endif() if (NOT GEODE_BINDINGS_REPO_PATH) - message(STATUS + message(STATUS "No override path for bindings provided, using CPM to clone default. " "If you would like to use a separate clone of the bindings repo " "(for example in order to be able to efficiently change and " @@ -154,109 +154,26 @@ if (NOT GEODE_BINDINGS_REPO_PATH) "cloned the repository (system environment variables are supported)." ) CPMAddPackage("gh:geode-sdk/bindings#main") - set(GEODE_BINDINGS_REPO_PATH ${GeodeBindings_SOURCE_DIR}) + set(GEODE_BINDINGS_REPO_PATH bindings_SOURCE_DIR) else() message(STATUS "Using ${GEODE_BINDINGS_REPO_PATH} for bindings repo") endif() -include(ExternalProject) -set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen) -ExternalProject_Add(CodegenProject - BUILD_ALWAYS ON - SOURCE_DIR ${GEODE_BINDINGS_REPO_PATH} - # manually set configure command as to not inherit generator used by geode, - # this should hopefully fix generator cache mismatch between different projects, however - # it causes a warning to be shown every time. if you know a better solution please tell us ok thx - CONFIGURE_COMMAND ${CMAKE_COMMAND} ${GEODE_CODEGEN_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT} - -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -S -B - BUILD_COMMAND ${CMAKE_COMMAND} --build --config $ - INSTALL_COMMAND ${CMAKE_COMMAND} --install --config $ -) - -if (NOT GEODE_BINDINGS_PATH) - set(GEODE_BINDINGS_PATH ${GEODE_BINDINGS_REPO_PATH}/bindings/${GEODE_GD_VERSION}) -endif() - -file(GLOB CODEGEN_DEPENDS CONFIGURE_DEPENDS - ${GEODE_BINDINGS_PATH}/*.bro - ${GEODE_BINDINGS_REPO_PATH}/codegen/src/*.cpp - ${GEODE_BINDINGS_REPO_PATH}/codegen/src/*.hpp -) - - -file(GLOB CODEGEN_OUTPUTS CONFIGURE_DEPENDS - ${GEODE_CODEGEN_PATH}/Geode/binding/*.hpp -) - -add_custom_command( - DEPENDS ${CODEGEN_DEPENDS} - DEPENDS CodegenProject - COMMAND ${GEODE_CODEGEN_BINARY_OUT}/Codegen ${GEODE_TARGET_PLATFORM} ${GEODE_BINDINGS_PATH} ${GEODE_CODEGEN_PATH} - COMMAND echo codegen > ${GEODE_CODEGEN_PATH}/.stamp - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Run Codegen" - OUTPUT ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp ${GEODE_CODEGEN_PATH}/Geode/GeneratedAddress.cpp ${GEODE_CODEGEN_PATH}/.stamp ${CODEGEN_OUTPUTS} -) - -add_custom_target(CodegenRun - DEPENDS ${GEODE_CODEGEN_PATH}/.stamp -) - -add_dependencies(${PROJECT_NAME} CodegenRun) - -# Hacky way to supress the not generated error -if (NOT EXISTS ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp) - file(MAKE_DIRECTORY ${GEODE_CODEGEN_PATH}) - file(MAKE_DIRECTORY ${GEODE_CODEGEN_PATH}/Geode) - file(TOUCH ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp) -endif() - -if (NOT EXISTS ${GEODE_CODEGEN_PATH}/Geode/GeneratedAddress.cpp) - file(MAKE_DIRECTORY ${GEODE_CODEGEN_PATH}) - file(MAKE_DIRECTORY ${GEODE_CODEGEN_PATH}/Geode) - file(TOUCH ${GEODE_CODEGEN_PATH}/Geode/GeneratedAddress.cpp) -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 GeodeFilesystemImpl fmt TulipHookInclude mat-json) -target_include_directories(GeodeCodegenSources PRIVATE - ${GEODE_CODEGEN_PATH} - ${GEODE_LOADER_PATH}/include - ${GEODE_LOADER_PATH}/include/Geode/cocos/include - ${GEODE_LOADER_PATH}/include/Geode/cocos/extensions - ${GEODE_LOADER_PATH}/include/Geode/fmod -) -set_target_properties(GeodeCodegenSources PROPERTIES CXX_VISIBILITY_PRESET hidden) -target_compile_features(GeodeCodegenSources PUBLIC cxx_std_20) - -if (APPLE) - target_compile_options(GeodeCodegenSources PUBLIC -ffunction-sections -fdata-sections) - target_link_options(GeodeCodegenSources PUBLIC -dead_strip) -elseif(ANDROID) - target_compile_options(GeodeCodegenSources PUBLIC -ffunction-sections -fdata-sections) - target_link_options(GeodeCodegenSources PUBLIC -Wl,--gc-sections) -endif() - if (NOT GEODE_DISABLE_PRECOMPILED_HEADERS) - target_precompile_headers(GeodeCodegenSources INTERFACE + target_precompile_headers(GeodeBindings INTERFACE "${GEODE_LOADER_PATH}/include/Geode/Bindings.hpp" ) endif() -target_include_directories(${PROJECT_NAME} INTERFACE - ${GEODE_CODEGEN_PATH} +target_include_directories(GeodeBindings PUBLIC ${GEODE_LOADER_PATH}/include ${GEODE_LOADER_PATH}/include/Geode/cocos/include ${GEODE_LOADER_PATH}/include/Geode/cocos/extensions ${GEODE_LOADER_PATH}/include/Geode/fmod ) -target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link) - -target_link_libraries(${PROJECT_NAME} INTERFACE ghc_filesystem fmt TulipHookInclude GeodeCodegenSources mat-json GeodeFilesystemImpl) - +target_link_directories(GeodeBindings PUBLIC ${GEODE_LOADER_PATH}/include/link) +target_link_libraries(GeodeBindings PUBLIC ghc_filesystem fmt TulipHookInclude mat-json GeodeFilesystemImpl) +target_link_libraries(${PROJECT_NAME} INTERFACE GeodeBindings) if (NOT EXISTS ${GEODE_BIN_PATH}) file(MAKE_DIRECTORY ${GEODE_BIN_PATH}) @@ -272,7 +189,6 @@ else() set(GEODE_PLATFORM_BIN_PATH ${GEODE_BIN_PATH}/${PROJECT_VERSION}/${GEODE_PLATFORM_BINARY}) endif() - if (PROJECT_IS_TOP_LEVEL) add_subdirectory(loader) target_link_libraries(${PROJECT_NAME} INTERFACE geode-loader) diff --git a/flash.toml b/flash.toml index f0208308..55ce1ec5 100644 --- a/flash.toml +++ b/flash.toml @@ -34,7 +34,7 @@ exclude = [ [[sources]] name = "Bindings" -dir = "build-docs/codegenned" +dir = "build-docs/bindings/bindings" include = [ "Geode/binding/*.hpp" ] @@ -55,13 +55,7 @@ config-args = [ "-DCMAKE_CXX_FLAGS=-m32", "-DWIN32=On" ] - -# We want to build codegen in order to get the bindings -build = true build-dir = "build-docs" -build-args = [ - "--target", "CodegenRun" -] # The file we use to get all the include paths and such infer-args-from = "loader/src/load.cpp" diff --git a/loader/include/Geode/Enums.hpp b/loader/include/Geode/Enums.hpp index 2549627d..bb5f3276 100644 --- a/loader/include/Geode/Enums.hpp +++ b/loader/include/Geode/Enums.hpp @@ -1,7 +1,5 @@ #pragma once -#include "DefaultInclude.hpp" - using TodoReturn = void; // thanks pie diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index ce22271e..68b3559e 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -39,7 +39,10 @@ #include "../include/CCProtocols.h" #include "Layout.hpp" #include "../../loader/Event.hpp" + +#ifndef GEODE_IS_MEMBER_TEST #include +#endif NS_CC_BEGIN @@ -845,7 +848,9 @@ private: friend class geode::modifier::FieldContainer; GEODE_DLL geode::modifier::FieldContainer* getFieldContainer(); +#ifndef GEODE_IS_MEMBER_TEST GEODE_DLL std::optional getAttributeInternal(std::string const& attribute); +#endif GEODE_DLL void addEventListenerInternal( std::string const& id, geode::EventListenerProtocol* protocol @@ -923,6 +928,7 @@ public: */ GEODE_DLL bool hasAncestor(CCNode* ancestor); +#ifndef GEODE_IS_MEMBER_TEST /** * Set an attribute on a node. Attributes are a system added by Geode, * where a node may have any sort of extra data associated with it. Used @@ -952,6 +958,7 @@ public: } return std::nullopt; } +#endif /** * Set the Layout for this node. Used to automatically position children, @@ -1778,6 +1785,7 @@ protected: NS_CC_END +#ifndef GEODE_IS_MEMBER_TEST namespace geode { struct GEODE_DLL AttributeSetEvent : public Event { cocos2d::CCNode* node; @@ -1800,5 +1808,6 @@ namespace geode { AttributeSetFilter(std::string const& id); }; } +#endif #endif // __PLATFORM_CCNODE_H__ diff --git a/loader/include/Geode/cocos/support/zip_support/ZipUtils.h b/loader/include/Geode/cocos/support/zip_support/ZipUtils.h index cc5b8d71..7f614dd9 100644 --- a/loader/include/Geode/cocos/support/zip_support/ZipUtils.h +++ b/loader/include/Geode/cocos/support/zip_support/ZipUtils.h @@ -21,6 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#ifndef GEODE_IS_MEMBER_TEST #ifndef __SUPPORT_ZIPUTILS_H__ #define __SUPPORT_ZIPUTILS_H__ @@ -272,3 +273,4 @@ namespace cocos2d } // end of namespace cocos2d #endif // __SUPPORT_ZIPUTILS_H__ +#endif