mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 23:48:08 -05:00
Run codegen on configure and move it to bindings (#484)
This commit is contained in:
parent
0731f44e68
commit
2e20cccf22
5 changed files with 20 additions and 101 deletions
100
CMakeLists.txt
100
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})
|
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_BIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||||
set(GEODE_LOADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/loader)
|
set(GEODE_LOADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/loader)
|
||||||
set(GEODE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
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})
|
set(temp $ENV{GEODE_BINDINGS_REPO_PATH})
|
||||||
# this is so stupid i hate windows paths
|
# this is so stupid i hate windows paths
|
||||||
string(REPLACE "\\" "/" GEODE_BINDINGS_REPO_PATH ${temp})
|
string(REPLACE "\\" "/" GEODE_BINDINGS_REPO_PATH ${temp})
|
||||||
|
add_subdirectory(${GEODE_BINDINGS_REPO_PATH} bindings)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT GEODE_BINDINGS_REPO_PATH)
|
if (NOT GEODE_BINDINGS_REPO_PATH)
|
||||||
message(STATUS
|
message(STATUS
|
||||||
"No override path for bindings provided, using CPM to clone default. "
|
"No override path for bindings provided, using CPM to clone default. "
|
||||||
"If you would like to use a separate clone of the bindings repo "
|
"If you would like to use a separate clone of the bindings repo "
|
||||||
"(for example in order to be able to efficiently change and "
|
"(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)."
|
"cloned the repository (system environment variables are supported)."
|
||||||
)
|
)
|
||||||
CPMAddPackage("gh:geode-sdk/bindings#main")
|
CPMAddPackage("gh:geode-sdk/bindings#main")
|
||||||
set(GEODE_BINDINGS_REPO_PATH ${GeodeBindings_SOURCE_DIR})
|
set(GEODE_BINDINGS_REPO_PATH bindings_SOURCE_DIR)
|
||||||
else()
|
else()
|
||||||
message(STATUS "Using ${GEODE_BINDINGS_REPO_PATH} for bindings repo")
|
message(STATUS "Using ${GEODE_BINDINGS_REPO_PATH} for bindings repo")
|
||||||
endif()
|
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 <SOURCE_DIR> -B <BINARY_DIR>
|
|
||||||
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIGURATION>
|
|
||||||
INSTALL_COMMAND ${CMAKE_COMMAND} --install <BINARY_DIR> --config $<CONFIGURATION>
|
|
||||||
)
|
|
||||||
|
|
||||||
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)
|
if (NOT GEODE_DISABLE_PRECOMPILED_HEADERS)
|
||||||
target_precompile_headers(GeodeCodegenSources INTERFACE
|
target_precompile_headers(GeodeBindings INTERFACE
|
||||||
"${GEODE_LOADER_PATH}/include/Geode/Bindings.hpp"
|
"${GEODE_LOADER_PATH}/include/Geode/Bindings.hpp"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} INTERFACE
|
target_include_directories(GeodeBindings PUBLIC
|
||||||
${GEODE_CODEGEN_PATH}
|
|
||||||
${GEODE_LOADER_PATH}/include
|
${GEODE_LOADER_PATH}/include
|
||||||
${GEODE_LOADER_PATH}/include/Geode/cocos/include
|
${GEODE_LOADER_PATH}/include/Geode/cocos/include
|
||||||
${GEODE_LOADER_PATH}/include/Geode/cocos/extensions
|
${GEODE_LOADER_PATH}/include/Geode/cocos/extensions
|
||||||
${GEODE_LOADER_PATH}/include/Geode/fmod
|
${GEODE_LOADER_PATH}/include/Geode/fmod
|
||||||
)
|
)
|
||||||
target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link)
|
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 ghc_filesystem fmt TulipHookInclude GeodeCodegenSources mat-json GeodeFilesystemImpl)
|
target_link_libraries(${PROJECT_NAME} INTERFACE GeodeBindings)
|
||||||
|
|
||||||
|
|
||||||
if (NOT EXISTS ${GEODE_BIN_PATH})
|
if (NOT EXISTS ${GEODE_BIN_PATH})
|
||||||
file(MAKE_DIRECTORY ${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})
|
set(GEODE_PLATFORM_BIN_PATH ${GEODE_BIN_PATH}/${PROJECT_VERSION}/${GEODE_PLATFORM_BINARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if (PROJECT_IS_TOP_LEVEL)
|
if (PROJECT_IS_TOP_LEVEL)
|
||||||
add_subdirectory(loader)
|
add_subdirectory(loader)
|
||||||
target_link_libraries(${PROJECT_NAME} INTERFACE geode-loader)
|
target_link_libraries(${PROJECT_NAME} INTERFACE geode-loader)
|
||||||
|
|
|
@ -34,7 +34,7 @@ exclude = [
|
||||||
|
|
||||||
[[sources]]
|
[[sources]]
|
||||||
name = "Bindings"
|
name = "Bindings"
|
||||||
dir = "build-docs/codegenned"
|
dir = "build-docs/bindings/bindings"
|
||||||
include = [
|
include = [
|
||||||
"Geode/binding/*.hpp"
|
"Geode/binding/*.hpp"
|
||||||
]
|
]
|
||||||
|
@ -55,13 +55,7 @@ config-args = [
|
||||||
"-DCMAKE_CXX_FLAGS=-m32",
|
"-DCMAKE_CXX_FLAGS=-m32",
|
||||||
"-DWIN32=On"
|
"-DWIN32=On"
|
||||||
]
|
]
|
||||||
|
|
||||||
# We want to build codegen in order to get the bindings
|
|
||||||
build = true
|
|
||||||
build-dir = "build-docs"
|
build-dir = "build-docs"
|
||||||
build-args = [
|
|
||||||
"--target", "CodegenRun"
|
|
||||||
]
|
|
||||||
|
|
||||||
# The file we use to get all the include paths and such
|
# The file we use to get all the include paths and such
|
||||||
infer-args-from = "loader/src/load.cpp"
|
infer-args-from = "loader/src/load.cpp"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "DefaultInclude.hpp"
|
|
||||||
|
|
||||||
using TodoReturn = void;
|
using TodoReturn = void;
|
||||||
|
|
||||||
// thanks pie
|
// thanks pie
|
||||||
|
|
|
@ -39,7 +39,10 @@
|
||||||
#include "../include/CCProtocols.h"
|
#include "../include/CCProtocols.h"
|
||||||
#include "Layout.hpp"
|
#include "Layout.hpp"
|
||||||
#include "../../loader/Event.hpp"
|
#include "../../loader/Event.hpp"
|
||||||
|
|
||||||
|
#ifndef GEODE_IS_MEMBER_TEST
|
||||||
#include <matjson.hpp>
|
#include <matjson.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -845,7 +848,9 @@ private:
|
||||||
friend class geode::modifier::FieldContainer;
|
friend class geode::modifier::FieldContainer;
|
||||||
|
|
||||||
GEODE_DLL geode::modifier::FieldContainer* getFieldContainer();
|
GEODE_DLL geode::modifier::FieldContainer* getFieldContainer();
|
||||||
|
#ifndef GEODE_IS_MEMBER_TEST
|
||||||
GEODE_DLL std::optional<matjson::Value> getAttributeInternal(std::string const& attribute);
|
GEODE_DLL std::optional<matjson::Value> getAttributeInternal(std::string const& attribute);
|
||||||
|
#endif
|
||||||
GEODE_DLL void addEventListenerInternal(
|
GEODE_DLL void addEventListenerInternal(
|
||||||
std::string const& id,
|
std::string const& id,
|
||||||
geode::EventListenerProtocol* protocol
|
geode::EventListenerProtocol* protocol
|
||||||
|
@ -923,6 +928,7 @@ public:
|
||||||
*/
|
*/
|
||||||
GEODE_DLL bool hasAncestor(CCNode* ancestor);
|
GEODE_DLL bool hasAncestor(CCNode* ancestor);
|
||||||
|
|
||||||
|
#ifndef GEODE_IS_MEMBER_TEST
|
||||||
/**
|
/**
|
||||||
* Set an attribute on a node. Attributes are a system added by Geode,
|
* 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
|
* where a node may have any sort of extra data associated with it. Used
|
||||||
|
@ -952,6 +958,7 @@ public:
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Layout for this node. Used to automatically position children,
|
* Set the Layout for this node. Used to automatically position children,
|
||||||
|
@ -1778,6 +1785,7 @@ protected:
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
#ifndef GEODE_IS_MEMBER_TEST
|
||||||
namespace geode {
|
namespace geode {
|
||||||
struct GEODE_DLL AttributeSetEvent : public Event {
|
struct GEODE_DLL AttributeSetEvent : public Event {
|
||||||
cocos2d::CCNode* node;
|
cocos2d::CCNode* node;
|
||||||
|
@ -1800,5 +1808,6 @@ namespace geode {
|
||||||
AttributeSetFilter(std::string const& id);
|
AttributeSetFilter(std::string const& id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __PLATFORM_CCNODE_H__
|
#endif // __PLATFORM_CCNODE_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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#ifndef GEODE_IS_MEMBER_TEST
|
||||||
#ifndef __SUPPORT_ZIPUTILS_H__
|
#ifndef __SUPPORT_ZIPUTILS_H__
|
||||||
#define __SUPPORT_ZIPUTILS_H__
|
#define __SUPPORT_ZIPUTILS_H__
|
||||||
|
|
||||||
|
@ -272,3 +273,4 @@ namespace cocos2d
|
||||||
} // end of namespace cocos2d
|
} // end of namespace cocos2d
|
||||||
#endif // __SUPPORT_ZIPUTILS_H__
|
#endif // __SUPPORT_ZIPUTILS_H__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue