From cba3aa0663d837c5bdf02e807ef5c71d0b264c5f Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Tue, 13 Sep 2022 21:08:13 +0800 Subject: [PATCH] Converted SHADE_Engine to a DLL project and exported common use classes --- SHADE.sln | 3 ++ SHADE_Application/SHADE_Application.vcxproj | 4 +-- SHADE_Application/premake5.lua | 3 +- SHADE_Engine/SHADE_Engine.vcxproj | 24 ++++++------- SHADE_Engine/premake5.lua | 5 +-- .../src/ECS_Base/Components/SHComponent.h | 3 +- SHADE_Engine/src/ECS_Base/Entity/SHEntity.h | 3 +- .../src/ECS_Base/System/SHComponentManager.h | 3 +- .../src/ECS_Base/System/SHEntityManager.h | 3 +- .../src/Graphics/Windowing/SHWindow.h | 3 +- SHADE_Engine/src/SH_API.h | 36 +++++++++++++++++++ SHADE_Engine/src/Tools/SHExceptionHandler.h | 4 ++- SHADE_Engine/src/Tools/SHLogger.h | 3 +- premake5.lua | 4 +-- 14 files changed, 75 insertions(+), 26 deletions(-) create mode 100644 SHADE_Engine/src/SH_API.h diff --git a/SHADE.sln b/SHADE.sln index ff6afa61..e0cb4ef9 100644 --- a/SHADE.sln +++ b/SHADE.sln @@ -2,6 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SHADE_Application", "SHADE_Application\SHADE_Application.vcxproj", "{BDC70008-29DE-FE9D-7255-8ABFDEAACF25}" + ProjectSection(ProjectDependencies) = postProject + {8EAD431C-7A4F-6EF2-630A-82464F4BF542} = {8EAD431C-7A4F-6EF2-630A-82464F4BF542} + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{53E47842-3FC8-3998-A828-34EB942B241A}" EndProject diff --git a/SHADE_Application/SHADE_Application.vcxproj b/SHADE_Application/SHADE_Application.vcxproj index 59d25053..20e738cc 100644 --- a/SHADE_Application/SHADE_Application.vcxproj +++ b/SHADE_Application/SHADE_Application.vcxproj @@ -60,7 +60,7 @@ SBpch.h Level4 _DEBUG;%(PreprocessorDefinitions) - ..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories) + ..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;include;%(AdditionalIncludeDirectories) EditAndContinue Disabled false @@ -80,7 +80,7 @@ SBpch.h Level4 _RELEASE;%(PreprocessorDefinitions) - ..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories) + ..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;include;%(AdditionalIncludeDirectories) Full true true diff --git a/SHADE_Application/premake5.lua b/SHADE_Application/premake5.lua index d7f47246..9eb3a41c 100644 --- a/SHADE_Application/premake5.lua +++ b/SHADE_Application/premake5.lua @@ -23,7 +23,8 @@ project "SHADE_Application" { "%{IncludeDir.spdlog}/include", "../SHADE_Engine/src", - "src" + "src", + "%{IncludeDir.dotnet}/include", } flags diff --git a/SHADE_Engine/SHADE_Engine.vcxproj b/SHADE_Engine/SHADE_Engine.vcxproj index 57c76f8e..9b4d09ae 100644 --- a/SHADE_Engine/SHADE_Engine.vcxproj +++ b/SHADE_Engine/SHADE_Engine.vcxproj @@ -19,13 +19,13 @@ - StaticLibrary + DynamicLibrary true Unicode v142 - StaticLibrary + DynamicLibrary false Unicode v142 @@ -41,23 +41,25 @@ + true ..\bin\Debug\ ..\bin_int\Debug\SHADE_Engine\ SHADE_Engine - .lib + .dll + false ..\bin\Release\ ..\bin_int\Release\SHADE_Engine\ SHADE_Engine - .lib + .dll Use SHpch.h Level4 - _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;_DEBUG;%(PreprocessorDefinitions) + _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;SH_API_EXPORT;_DEBUG;%(PreprocessorDefinitions) src;..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\ktx\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;%(AdditionalIncludeDirectories) EditAndContinue Disabled @@ -69,18 +71,17 @@ Windows true - - vulkan-1.lib;shaderc_shared.lib;assimp-vc142-mtd.lib;ktxd.lib;librttr_core_d.lib;%(AdditionalDependencies) libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\ktx\lib\Debug;..\Dependencies\ktx\lib\Release;%(AdditionalLibraryDirectories) - + ..\bin\Debug\SHADE_Engine.lib + Use SHpch.h Level4 - _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;_RELEASE;%(PreprocessorDefinitions) + _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;SH_API_EXPORT;_RELEASE;%(PreprocessorDefinitions) src;..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\ktx\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;%(AdditionalIncludeDirectories) Full true @@ -95,11 +96,10 @@ Windows true true - - vulkan-1.lib;shaderc_shared.lib;assimp-vc142-mt.lib;ktx.lib;librttr_core.lib;%(AdditionalDependencies) libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\ktx\lib\Debug;..\Dependencies\ktx\lib\Release;%(AdditionalLibraryDirectories) - + ..\bin\Release\SHADE_Engine.lib + diff --git a/SHADE_Engine/premake5.lua b/SHADE_Engine/premake5.lua index ddd9eaaa..681de634 100644 --- a/SHADE_Engine/premake5.lua +++ b/SHADE_Engine/premake5.lua @@ -1,5 +1,5 @@ project "SHADE_Engine" - kind "StaticLib" + kind "SharedLib" language "C++" cppdialect "C++latest" targetdir (outputdir) @@ -66,7 +66,8 @@ project "SHADE_Engine" "_LIB", "_GLFW_INCLUDE_NONE", "MSDFGEN_USE_CPP11", - "NOMINMAX" + "NOMINMAX", + "SH_API_EXPORT" } flags diff --git a/SHADE_Engine/src/ECS_Base/Components/SHComponent.h b/SHADE_Engine/src/ECS_Base/Components/SHComponent.h index c9c5e6f1..edd8436c 100644 --- a/SHADE_Engine/src/ECS_Base/Components/SHComponent.h +++ b/SHADE_Engine/src/ECS_Base/Components/SHComponent.h @@ -14,13 +14,14 @@ #include "SHpch.h" #include "../SHECSMacros.h" +#include "SH_API.h" namespace SHADE { class SHComponentManager; - class SHComponent + class SH_API SHComponent { friend SHComponentManager; diff --git a/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h b/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h index d499042c..685ba99a 100644 --- a/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h +++ b/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h @@ -15,6 +15,7 @@ #include "../Components/SHComponent.h" #include "../System/SHComponentManager.h" //#include "../../Scene/SHSceneNode.h" +#include "SH_API.h" @@ -23,7 +24,7 @@ namespace SHADE class SHComponentManager; class SHEntityManager; - class SHEntity + class SH_API SHEntity { public: diff --git a/SHADE_Engine/src/ECS_Base/System/SHComponentManager.h b/SHADE_Engine/src/ECS_Base/System/SHComponentManager.h index 2f6ff504..75db35d5 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHComponentManager.h +++ b/SHADE_Engine/src/ECS_Base/System/SHComponentManager.h @@ -19,13 +19,14 @@ #include "../Components/SHComponent.h" #include "../Components/SHComponentGroup.h" //#include "Scene/SHSceneNode.h" +#include "SH_API.h" #include namespace SHADE { - class SHComponentManager + class SH_API SHComponentManager { private: diff --git a/SHADE_Engine/src/ECS_Base/System/SHEntityManager.h b/SHADE_Engine/src/ECS_Base/System/SHEntityManager.h index 11e896d5..802ef75d 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHEntityManager.h +++ b/SHADE_Engine/src/ECS_Base/System/SHEntityManager.h @@ -22,11 +22,12 @@ #include "../Components/SHComponent.h" #include "../General/SHHandleGenerator.h" #include "../SHECSMacros.h" +#include "SH_API.h" namespace SHADE { - class SHEntityManager + class SH_API SHEntityManager { private: static std::vector> entityVec; diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.h b/SHADE_Engine/src/Graphics/Windowing/SHWindow.h index a70058a1..1e08dcb0 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.h +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.h @@ -5,6 +5,7 @@ #include #include #include "SHWindowMap.h" +#include "SH_API.h" namespace SHADE { @@ -67,7 +68,7 @@ namespace SHADE std::string icoPath = ""; }; - class SHWindow + class SH_API SHWindow { public: using SHVec2 = std::pair; diff --git a/SHADE_Engine/src/SH_API.h b/SHADE_Engine/src/SH_API.h new file mode 100644 index 00000000..64d1eebe --- /dev/null +++ b/SHADE_Engine/src/SH_API.h @@ -0,0 +1,36 @@ +/************************************************************************************//*! +\file SH_API.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Sep 13, 2022 +\brief Contains dllexport and dllimport macros for the SHADE Engine. + +Copyright (C) 2022 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once + +// Select the correct export system based on the compiler +#if defined SH_LIB +# define SH_API +#else +# if defined _WIN32 || defined __CYGWIN__ || defined _MSC_VER +# define SH_EXPORT __declspec(dllexport) +# define SH_IMPORT __declspec(dllimport) +# elif defined __GNUC__ && __GNUC__ >= 4 +# define SH_EXPORT __attribute__((visibility("default"))) +# define SH_IMPORT __attribute__((visibility("default"))) +# else /* Unsupported compiler */ +# define SH_EXPORT +# define SH_IMPORT +# endif + // Define the correct +# ifndef SH_API +# if defined SH_API_EXPORT +# define SH_API SH_EXPORT +# else +# define SH_API SH_IMPORT +# endif +# endif +#endif \ No newline at end of file diff --git a/SHADE_Engine/src/Tools/SHExceptionHandler.h b/SHADE_Engine/src/Tools/SHExceptionHandler.h index dd1d7596..32cda608 100644 --- a/SHADE_Engine/src/Tools/SHExceptionHandler.h +++ b/SHADE_Engine/src/Tools/SHExceptionHandler.h @@ -12,13 +12,15 @@ #include +#include "SH_API.h" + namespace SHADE { /*-----------------------------------------------------------------------------------*/ /* Type Definitions */ /*-----------------------------------------------------------------------------------*/ - class SHExceptionHandler + class SH_API SHExceptionHandler { public: /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Tools/SHLogger.h b/SHADE_Engine/src/Tools/SHLogger.h index ac5f9308..dfb7dffd 100644 --- a/SHADE_Engine/src/Tools/SHLogger.h +++ b/SHADE_Engine/src/Tools/SHLogger.h @@ -15,6 +15,7 @@ #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE #include +#include "SH_API.h" /*-------------------------------------------------------------------------------------*/ /* Macros */ @@ -27,7 +28,7 @@ namespace SHADE /* Type Definitions */ /*-----------------------------------------------------------------------------------*/ - class SHLogger + class SH_API SHLogger { public: /*---------------------------------------------------------------------------------*/ diff --git a/premake5.lua b/premake5.lua index afb72a33..e136702a 100644 --- a/premake5.lua +++ b/premake5.lua @@ -12,14 +12,14 @@ workspace "SHADE" flags { - "MultiProcessorCompile" + "MultiProcessorCompile" } outputdir = "%{wks.location}/bin/%{cfg.buildcfg}" interdir = "%{wks.location}/bin_int" - include "SHADE_Application" include "SHADE_Engine" + include "SHADE_Application" group "Dependencies" include "Dependencies/msdf"