Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Config Implementation #1028

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

#include <iostream>

#include "include/config.h"
#include "include/config_legacy.h"

int main()
{
pew::eos::config::EOSConfig eos_config;
if(try_get_eos_config(eos_config))
pew::eos::config_legacy::EOSConfig eos_config;
if(pew::eos::config_legacy::try_get_eos_config(eos_config))
{
std::cout << "EOSConfig was read successfully.";
}
Expand Down
21 changes: 19 additions & 2 deletions lib/NativeCode/DynamicLibraryLoaderHelper/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
<Project>
<PropertyGroup>
<!-- Define a property with the SolutionDir path but with backslashes replaced by forward slashes -->
<!--
Across different contexts and different conditions WITHIN THIS PROJECT,
"Win32" and "x86" are used somewhat interchangeably. For the purposes of
the native component of the plugin, Win32 is considered to be x86 and
should be placed in the corresponding directory along with other x86
binaries.

Therefore NormalizedPlatform is introduced here to appropriately
translate.
-->
<NormalizedPlatform Condition="'$(PlatformTarget)' == 'x86' or '$(PlatformTarget)' == 'Win32'">x86</NormalizedPlatform>
<NormalizedPlatform Condition="'$(PlatformTarget)' == 'x64'">x64</NormalizedPlatform>
<NormalizedPlatform Condition="'$(Platform)' == 'x86' or '$(Platform)' == 'Win32'">x86</NormalizedPlatform>
<NormalizedPlatform Condition="'$(Platform)' == 'x64'">x64</NormalizedPlatform>

<!--
Define a property with the SolutionDir path but with backslashes replaced
by forward slashes
-->
<SolutionDirForwardSlashes>$(SolutionDir.Replace('\', '/'))</SolutionDirForwardSlashes>
<UnityStreamingAssetsDirectory>$(SolutionDirForwardSlashes)../../../Assets/StreamingAssets/</UnityStreamingAssetsDirectory>
<OutputUnityAssetsDirectory>$(SolutionDirForwardSlashes)../../../Assets/Plugins/Windows/$(Platform)/</OutputUnityAssetsDirectory>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>copy $(SolutionDir)$(ProjectName)-$(Platform).dll.meta $(OutputUnityAssetsDirectory)</Command>
<Command>xcopy "$(TargetDir)*" "$(OutputUnityAssetsDirectory)" /E /I /Y</Command>
<!-- Copy the meta file stored in the solution directory, since it's values have been properly set in such a way that Unity interacts with the DLL in the intended manner. -->
<Command>copy $(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta $(OutputUnityAssetsDirectory) /Y</Command>
<!-- Copy just the output .dll file into the appropriate assets directory alongside the aforementioned .dll.meta file.-->
<Command>copy "$(TargetDir)$(ProjectName)-$(NormalizedPlatform).dll" "$(OutputUnityAssetsDirectory)" /Y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<!-- Source Files -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@
<OverlayDllName>EOSOVH-Win32-Shipping.dll</OverlayDllName>
<SteamApiDll>steam_api.dll</SteamApiDll>
</PropertyGroup>

<PropertyGroup>
<!--
Indicates where within the Unity project folder structure the
GfxPluginNativeRender-*.dll file should be placed.
-->
<OutputUnityAssetsDirectory>$(SolutionDir)..\..\..\Assets\Plugins\Windows\$(NormalizedPlatform)\</OutputUnityAssetsDirectory>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,47 @@
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";_DEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>PEW_EOS_EXPORT;OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";_DEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";NDEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>PEW_EOS_EXPORT;OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";NDEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>copy $(SolutionDir)$(ProjectName)-$(Platform).dll.meta $(OutputUnityAssetsDirectory)</Command>
<Command>xcopy "$(TargetDir)*" "$(OutputUnityAssetsDirectory)" /E /I /Y</Command>
<!-- Copy the meta file stored in the solution directory, since it's values have been properly set in such a way that Unity interacts with the DLL in the intended manner. -->
<Command>copy $(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta $(OutputUnityAssetsDirectory) /Y</Command>
<!-- Copy just the output .dll file into the appropriate assets directory alongside the aforementioned .dll.meta file.-->
<Command>copy "$(TargetDir)$(ProjectName)-$(NormalizedPlatform).dll" "$(OutputUnityAssetsDirectory)" /Y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<!-- Source Files -->
<ItemGroup>
<ClInclude Include="include\config.h" />
<ClInclude Include="include\config_legacy.h" />
<ClInclude Include="include\eos_helpers.h" />
<ClInclude Include="include\eos_library_helpers.h" />
<ClInclude Include="include\eos_minimum_includes.h" />
<ClInclude Include="include\io_helpers.h" />
<ClInclude Include="include\json.h" />
<ClInclude Include="include\json_helpers.h" />
<ClInclude Include="include\logging.h" />
<ClInclude Include="include\PEW_EOS_Defines.h" />
<ClInclude Include="include\string_helpers.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="src\config.cpp" />
<ClCompile Include="src\config_legacy.cpp" />
<ClCompile Include="src\dllmain.cpp" />
<ClCompile Include="src\eos_helpers.cpp" />
<ClCompile Include="src\eos_library_helpers.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="include\config.h">
<ClInclude Include="include\config_legacy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\eos_helpers.h">
Expand All @@ -43,10 +43,13 @@
<ClInclude Include="include\string_helpers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\PEW_EOS_Defines.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="src\config.cpp">
<ClCompile Include="src\config_legacy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\dllmain.cpp">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef PEW_EOS_DEFINES_H
#define PEW_EOS_DEFINES_H

/*
* Copyright (c) 2021 PlayEveryWare
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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.
*/
#pragma once

// Define PEW_EOS_EXPORT for exporting/importing symbols
#ifdef _WIN32
// PEW_EOS_EXPORT is defined *only* in the pre-processing scripting directives
// for GfxPluginNativeRender's build process. When PEW_EOS_EXPORT is defined,
// using the PEW_EOS_API macro in class or struct definitions will affect the
// export of those objects. However, when other projects reference any of the
// files within this project - the PEW_EOS_EXPORT define will not be defined,
// and (as is appropriate for the context in which another project is
// referencing this one) the macro will specify that the struct or class should
// be *imported*, not *exported*.
// This is standard practice for C++ DLL projects.
#ifdef PEW_EOS_EXPORT
// Specify export
#define PEW_EOS_API __declspec(dllexport)
#else
// Specify import
#define PEW_EOS_API __declspec(dllimport)
#endif
#else
#define PEW_EOS_API // Empty for non-Windows platforms
#endif

/**
* \brief Use this macro on the signature of a method that is to be exposed to
* callers external to the dll. Used exclusively for static methods.
* \param return_value Syntax to affect the exposure of the method to callers
* external to the DLL.
*/
#define PEW_EOS_API_FUNC(return_value) extern "C" PEW_EOS_API return_value __stdcall

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct json_value_s;
#define CONFIG_API __declspec(dllimport)
#endif

namespace pew::eos::config
namespace pew::eos::config_legacy
{
/**
* \brief
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#pragma once
#include "PEW_EOS_Defines.h"

namespace std
{
Expand All @@ -34,7 +35,7 @@ namespace std

namespace pew::eos
{
namespace config
namespace config_legacy
{
struct EOSConfig;
}
Expand All @@ -46,7 +47,7 @@ namespace pew::eos
*
* @return A pointer to the EOS platform interface handle.
*/
DLL_EXPORT(void*) EOS_GetPlatformInterface();
PEW_EOS_API_FUNC(void*) EOS_GetPlatformInterface();

/**
* @brief Sets the log level for the EOS SDK based on the configuration file.
Expand Down Expand Up @@ -75,7 +76,7 @@ namespace pew::eos
*
* @param eos_config The EOS configuration settings.
*/
void eos_init(const config::EOSConfig eos_config);
void eos_init(const config_legacy::EOSConfig eos_config);

/**
* @brief Creates an EOS platform using the specified configuration.
Expand All @@ -85,6 +86,6 @@ namespace pew::eos
*
* @param eos_config The configuration object containing EOS platform settings.
*/
void eos_create(config::EOSConfig eos_config);
void eos_create(config_legacy::EOSConfig eos_config);
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include <string>
#include <eos_logging.h>

/**
#include "PEW_EOS_Defines.h"

/**
* \brief Forward declarations
*/
enum class EOS_ELogLevel;
Expand Down Expand Up @@ -55,7 +57,7 @@ namespace pew::eos::logging
*
* @param log_flush_function The function to call for each log message in the buffer.
*/
DLL_EXPORT(void) global_log_flush_with_function(log_flush_function_t log_flush_function);
PEW_EOS_API_FUNC(void) global_log_flush_with_function(log_flush_function_t log_flush_function);

/**
* @brief Converts a log level string to its corresponding EOS log level enumeration.
Expand Down Expand Up @@ -103,7 +105,7 @@ namespace pew::eos::logging
*
* @param message The log message provided by the EOS SDK.
*/
EXTERN_C void EOS_CALL eos_log_callback(const EOS_LogMessage* message);
PEW_EOS_API_FUNC(void) EOS_CALL eos_log_callback(const EOS_LogMessage* message);

/**
* @brief Opens a log file for writing.
Expand Down Expand Up @@ -136,6 +138,19 @@ namespace pew::eos::logging
*/
void log_warn(const char* log_string);

/**
* @brief Logs a warning message.
*
* Records a warning message with a "WARNING" header and, if enabled,
* displays it in a dialog box.
*
* @param log_string The warning message to log.
*/
inline void log_warn(const std::string& log_string)
{
return log_warn(log_string.c_str());
}

/**
* @brief Logs an informational message.
*
Expand All @@ -145,6 +160,18 @@ namespace pew::eos::logging
*/
void log_inform(const char* log_string);

/**
* @brief Logs an informational message.
*
* Records an informational message with an "INFORM" header.
*
* @param log_string The informational message to log.
*/
inline void log_inform(const std::string& log_string)
{
return log_inform(log_string.c_str());
}

/**
* @brief Logs an error message.
*
Expand All @@ -153,5 +180,17 @@ namespace pew::eos::logging
* @param log_string The error message to log.
*/
void log_error(const char* log_string);

/**
* @brief Logs an error message.
*
* Records an error message with an "ERROR" header.
*
* @param log_string The error message to log.
*/
inline void log_error(const std::string& log_string)
{
return log_error(log_string.c_str());
}
}
#endif
2 changes: 0 additions & 2 deletions lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@

#define RESTRICT __restrict

#define DLL_EXPORT(return_value) extern "C" __declspec(dllexport) return_value __stdcall

#endif //PCH_H
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/

#include <pch.h>
#include "config.h"
#include "config_legacy.h"
#include "eos_library_helpers.h"
#include "io_helpers.h"
#include "json_helpers.h"
#include "logging.h"

using namespace pew::eos::config;
using namespace pew::eos::config_legacy;
using namespace pew::eos::json_helpers;

/**
Expand Down Expand Up @@ -168,7 +168,7 @@ EOSConfig eos_config_from_json_value(json_value_s* config_json)
return eos_config;
}

namespace pew::eos::config
namespace pew::eos::config_legacy
{
/**
* \brief Function that gets the config as a JSON string.
Expand Down
Loading