/* * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK) #include #include #include #include #include #endif namespace AWSNativeSDKInit { namespace Platform { #if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK) void CustomizeSDKOptions(Aws::SDKOptions& options); void CustomizeShutdown(); void CopyCaCertBundle(); #endif } const char* const InitializationManager::initializationManagerTag = "AWSNativeSDKInitializer"; AZ::EnvironmentVariable InitializationManager::s_initManager = nullptr; InitializationManager::InitializationManager() { InitializeAwsApiInternal(); } InitializationManager::~InitializationManager() { ShutdownAwsApiInternal(); } void InitializationManager::InitAwsApi() { s_initManager = AZ::Environment::CreateVariable(initializationManagerTag); Platform::CopyCaCertBundle(); } void InitializationManager::Shutdown() { s_initManager = nullptr; } bool InitializationManager::IsInitialized() { return s_initManager.IsConstructed(); } void InitializationManager::InitializeAwsApiInternal() { #if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK) Aws::Utils::Logging::LogLevel logLevel; #ifdef _DEBUG logLevel = Aws::Utils::Logging::LogLevel::Warn; #else logLevel = Aws::Utils::Logging::LogLevel::Warn; #endif m_awsSDKOptions.loggingOptions.logLevel = logLevel; m_awsSDKOptions.loggingOptions.logger_create_fn = [logLevel]() { return Aws::MakeShared("AWS", logLevel); }; m_awsSDKOptions.memoryManagementOptions.memoryManager = &m_memoryManager; Platform::CustomizeSDKOptions(m_awsSDKOptions); Aws::InitAPI(m_awsSDKOptions); #endif // #if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK) } void InitializationManager::ShutdownAwsApiInternal() { #if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK) Aws::ShutdownAPI(m_awsSDKOptions); Platform::CustomizeShutdown(); #endif // #if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK) } }