Cleanup: Remove cry load dll functions (#5295)
* Removes VTUNE profiler hooks from Cry Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Remove cry load dll functions Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * removes unused restricted section Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM) || defined(AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS)
|
||||
#undef AZ_RESTRICTED_SECTION
|
||||
#define SYSTEMINIT_CPP_SECTION_1 1
|
||||
#define SYSTEMINIT_CPP_SECTION_2 2
|
||||
#define SYSTEMINIT_CPP_SECTION_3 3
|
||||
#define SYSTEMINIT_CPP_SECTION_4 4
|
||||
@@ -168,30 +167,6 @@ void CryEngineSignalHandler(int signal)
|
||||
|
||||
#define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(WIN32) || defined(LINUX) || defined(APPLE)
|
||||
# define DLL_INITFUNC_RENDERER "PackageRenderConstructor"
|
||||
# define DLL_INITFUNC_SOUND "CreateSoundSystem"
|
||||
# define DLL_INITFUNC_FONT "CreateCryFontInterface"
|
||||
# define DLL_INITFUNC_3DENGINE "CreateCry3DEngine"
|
||||
# define DLL_INITFUNC_UI "CreateLyShineInterface"
|
||||
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#elif defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_1
|
||||
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
|
||||
#endif
|
||||
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
|
||||
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#else
|
||||
# define DLL_INITFUNC_RENDERER (LPCSTR)1
|
||||
# define DLL_INITFUNC_RENDERER (LPCSTR)1
|
||||
# define DLL_INITFUNC_SOUND (LPCSTR)1
|
||||
# define DLL_INITFUNC_PHYSIC (LPCSTR)1
|
||||
# define DLL_INITFUNC_FONT (LPCSTR)1
|
||||
# define DLL_INITFUNC_3DENGINE (LPCSTR)1
|
||||
# define DLL_INITFUNC_UI (LPCSTR)1
|
||||
#endif
|
||||
|
||||
#define AZ_TRACE_SYSTEM_WINDOW AZ::Debug::Trace::GetDefaultSystemWindow()
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -285,96 +260,6 @@ static void CmdCrashTest(IConsoleCmdArgs* pArgs)
|
||||
}
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct SysSpecOverrideSink
|
||||
: public ILoadConfigurationEntrySink
|
||||
{
|
||||
virtual void OnLoadConfigurationEntry(const char* szKey, const char* szValue, const char* szGroup)
|
||||
{
|
||||
ICVar* pCvar = gEnv->pConsole->GetCVar(szKey);
|
||||
|
||||
if (pCvar)
|
||||
{
|
||||
const bool wasNotInConfig = ((pCvar->GetFlags() & VF_WASINCONFIG) == 0);
|
||||
bool applyCvar = wasNotInConfig;
|
||||
if (applyCvar == false)
|
||||
{
|
||||
// Special handling for sys_spec_full
|
||||
if (azstricmp(szKey, "sys_spec_full") == 0)
|
||||
{
|
||||
// If it is set to 0 then ignore this request to set to something else
|
||||
// If it is set to 0 then the user wants to changes system spec settings in system.cfg
|
||||
if (pCvar->GetIVal() != 0)
|
||||
{
|
||||
applyCvar = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This could bypass the restricted cvar checks that exist elsewhere depending on
|
||||
// the calling code so we also need check here before setting.
|
||||
bool isConst = pCvar->IsConstCVar();
|
||||
bool isCheat = ((pCvar->GetFlags() & (VF_CHEAT | VF_CHEAT_NOCHECK | VF_CHEAT_ALWAYS_CHECK)) != 0);
|
||||
bool isReadOnly = ((pCvar->GetFlags() & VF_READONLY) != 0);
|
||||
bool isDeprecated = ((pCvar->GetFlags() & VF_DEPRECATED) != 0);
|
||||
bool allowApplyCvar = true;
|
||||
|
||||
if ((isConst || isCheat || isReadOnly) || isDeprecated)
|
||||
{
|
||||
allowApplyCvar = !isDeprecated && (gEnv->pSystem->IsDevMode()) || (gEnv->IsEditor());
|
||||
}
|
||||
|
||||
if ((allowApplyCvar) || ALLOW_CONST_CVAR_MODIFICATIONS)
|
||||
{
|
||||
applyCvar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (applyCvar)
|
||||
{
|
||||
pCvar->Set(szValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
CryLogAlways("NOT VF_WASINCONFIG Ignoring cvar '%s' new value '%s' old value '%s' group '%s'", szKey, szValue, pCvar->GetString(), szGroup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CryLogAlways("Can't find cvar '%s' value '%s' group '%s'", szKey, szValue, szGroup);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(CONSOLE)
|
||||
struct SysSpecOverrideSinkConsole
|
||||
: public ILoadConfigurationEntrySink
|
||||
{
|
||||
virtual void OnLoadConfigurationEntry(const char* szKey, const char* szValue, const char* szGroup)
|
||||
{
|
||||
// Ignore platform-specific cvars that should just be executed on the console
|
||||
if (azstricmp(szGroup, "Platform") == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ICVar* pCvar = gEnv->pConsole->GetCVar(szKey);
|
||||
if (pCvar)
|
||||
{
|
||||
pCvar->Set(szValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the cvar doesn't exist, calling this function only saves the value in case it's registered later where
|
||||
// at that point it will be set from the stored value. This is required because otherwise registering the
|
||||
// cvar bypasses any callbacks and uses values directly from the cvar group files.
|
||||
gEnv->pConsole->LoadConfigVar(szKey, szValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
static ESystemConfigPlatform GetDevicePlatform()
|
||||
{
|
||||
#if defined(AZ_PLATFORM_WINDOWS) || defined(AZ_PLATFORM_LINUX)
|
||||
@@ -398,98 +283,6 @@ static ESystemConfigPlatform GetDevicePlatform()
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(AZ_MONOLITHIC_BUILD)
|
||||
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> CSystem::LoadDynamiclibrary(const char* dllName) const
|
||||
{
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> handle = AZ::DynamicModuleHandle::Create(dllName);
|
||||
|
||||
bool libraryLoaded = handle->Load(false);
|
||||
// We need to inject the environment first thing so that allocators are available immediately
|
||||
InjectEnvironmentFunction injectEnv = handle->GetFunction<InjectEnvironmentFunction>(INJECT_ENVIRONMENT_FUNCTION);
|
||||
if (injectEnv)
|
||||
{
|
||||
auto env = AZ::Environment::GetInstance();
|
||||
injectEnv(env);
|
||||
}
|
||||
|
||||
if (!libraryLoaded)
|
||||
{
|
||||
handle.release();
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> CSystem::LoadDLL(const char* dllName)
|
||||
{
|
||||
AZ_TracePrintf(AZ_TRACE_SYSTEM_WINDOW, "Loading DLL: %s", dllName);
|
||||
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> handle = LoadDynamiclibrary(dllName);
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
#if defined(LINUX) || defined(APPLE)
|
||||
AZ_Assert(false, "Error loading dylib: %s, error : %s\n", dllName, dlerror());
|
||||
#else
|
||||
AZ_Assert(false, "Error loading dll: %s, error code %d", dllName, GetLastError());
|
||||
#endif
|
||||
return handle;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
// TODO:DLL #endif //#if defined(AZ_HAS_DLL_SUPPORT) && !defined(AZ_MONOLITHIC_BUILD)
|
||||
#endif //if !defined(AZ_MONOLITHIC_BUILD)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::LoadEngineDLLs()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::UnloadDLL(const char* dllName)
|
||||
{
|
||||
bool isSuccess = false;
|
||||
|
||||
AZ::Crc32 key(dllName);
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> empty;
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle>& hModule = stl::find_in_map_ref(m_moduleDLLHandles, key, empty);
|
||||
if ((hModule) && (hModule->IsLoaded()))
|
||||
{
|
||||
DetachEnvironmentFunction detachEnv = hModule->GetFunction<DetachEnvironmentFunction>(DETACH_ENVIRONMENT_FUNCTION);
|
||||
if (detachEnv)
|
||||
{
|
||||
detachEnv();
|
||||
}
|
||||
|
||||
isSuccess = hModule->Unload();
|
||||
hModule.release();
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSystem::ShutdownModuleLibraries()
|
||||
{
|
||||
#if !defined(AZ_MONOLITHIC_BUILD)
|
||||
for (auto iterator = m_moduleDLLHandles.begin(); iterator != m_moduleDLLHandles.end(); ++iterator)
|
||||
{
|
||||
if (iterator->second->IsLoaded())
|
||||
{
|
||||
iterator->second->Unload();
|
||||
}
|
||||
iterator->second.release();
|
||||
}
|
||||
|
||||
m_moduleDLLHandles.clear();
|
||||
|
||||
#endif // !defined(AZ_MONOLITHIC_BUILD)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::InitConsole()
|
||||
|
||||
Reference in New Issue
Block a user