From b804e06f7df0075b8b98a50c2be20e6db2068ea0 Mon Sep 17 00:00:00 2001 From: GhostofCookie Date: Wed, 23 Jul 2025 15:07:26 -0400 Subject: [PATCH] FIx bad export of module static member and cleanup arch and platform defines. --- include/flow/core/Core.hpp | 28 ++++++++++++++++++++++------ include/flow/core/Module.hpp | 2 +- src/Module.cpp | 23 ++++------------------- tests/CMakeLists.txt | 2 +- tests/test_module/CMakeLists.txt | 2 +- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/flow/core/Core.hpp b/include/flow/core/Core.hpp index 5294133..1fca34d 100644 --- a/include/flow/core/Core.hpp +++ b/include/flow/core/Core.hpp @@ -4,21 +4,27 @@ #pragma once #if defined(_WIN32) -#define FLOW_WINDOWS +#define FLOW_WINDOWS "windows"; +#define FLOW_PLATFORM FLOW_WINDOWS #elif defined(__APPLE__) -#define FLOW_APPLE +#define FLOW_APPLE "macos"; +#define FLOW_PLATFORM FLOW_APPLE #elif defined(__linux__) -#define FLOW_LINUX +#define FLOW_LINUX "linux"; +#define FLOW_PLATFORM FLOW_LINUX #else #error "Platform unsupported" #endif #if defined(__x86_64__) || defined(_M_X64) || defined(__amd64__) -#define FLOW_X86_64 +#define FLOW_X86_64 "x86_64"; +#define FLOW_ARCH FLOW_X86_64 #elif defined(__i386__) || defined(_M_IX86) -#define FLOW_X86 +#define FLOW_X86 "x86"; +#define FLOW_ARCH FLOW_X86 #elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) -#define FLOW_ARM +#define FLOW_ARM "arm64"; +#define FLOW_ARCH FLOW_ARM #else #error "Architecture unsupported" #endif @@ -29,6 +35,16 @@ #define FLOW_CORE_CALL #endif +#ifdef FLOW_WINDOWS +#ifdef FLOW_CORE_EXPORT +#define FLOW_CORE_API __declspec(dllexport) +#else +#define FLOW_CORE_API __declspec(dllimport) +#endif +#else +#define FLOW_CORE_API +#endif + // clang-format off #define FLOW_NAMESPACE_BEGIN namespace flow { #define FLOW_SUBNAMESPACE_BEGIN(nested) namespace flow { namespace nested { diff --git a/include/flow/core/Module.hpp b/include/flow/core/Module.hpp index a094f16..69f5bba 100644 --- a/include/flow/core/Module.hpp +++ b/include/flow/core/Module.hpp @@ -124,7 +124,7 @@ class Module /** * @brief The file extension for module metadata files. */ - static const std::string FileExtension; + static const std::string FLOW_CORE_API FileExtension; private: std::unique_ptr _handle; diff --git a/src/Module.cpp b/src/Module.cpp index 78d7c92..94b3d29 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -24,6 +24,8 @@ FLOW_NAMESPACE_BEGIN using namespace zipper; +const std::string Module::FileExtension = "fmod"; + struct formatted_error : public std::runtime_error { template @@ -45,25 +47,8 @@ struct invalid_argument : public formatted_error NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ModuleMetaData, Name, Version, Author, Description); -const std::string Module::FileExtension = "fmod"; - -#ifdef FLOW_WINDOWS -constexpr const char* platform = "windows"; -#elif defined(FLOW_APPLE) -constexpr const char* platform = "macos"; -#else -constexpr const char* platform = "linux"; -#endif - -#ifdef FLOW_X86_64 -constexpr const char* architecture = "x86_64"; -#elif defined(FLOW_X86) -constexpr const char* architecture = "x86"; -#elif defined(FLOW_ARM) -constexpr const char* architecture = "arm64"; -#else -#error "Unsupported architecture" -#endif +constexpr const char* platform = FLOW_PLATFORM; +constexpr const char* architecture = FLOW_ARCH; #ifdef FLOW_WINDOWS constexpr const char* library_extension = ".dll"; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 18f8fcb..a6a0d73 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,7 +32,7 @@ if(MSVC) endif() target_link_libraries(${TEST_EXE} - flow-core + flow-core::flow-core GTest::gtest_main ) diff --git a/tests/test_module/CMakeLists.txt b/tests/test_module/CMakeLists.txt index 16ac805..44f4a98 100644 --- a/tests/test_module/CMakeLists.txt +++ b/tests/test_module/CMakeLists.txt @@ -19,7 +19,7 @@ endif() add_dependencies(${PROJECT_NAME} flow-core) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(${PROJECT_NAME} PUBLIC flow-core) +target_link_libraries(${PROJECT_NAME} PUBLIC flow-core::flow-core) include(${CMAKE_SOURCE_DIR}/cmake/FlowModule.cmake) CreateFlowModule(${PROJECT_NAME})