AutoSDKPath

AutoSDKPath

#Overview

name: AutoSDKPath

The value of this variable can be defined or overridden in .ini config files. 8 .ini config files referencing this setting variable.

It is referenced in 13 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of AutoSDKPath is to specify the path to the Software Development Kit (SDK) for a specific platform in Unreal Engine 5. This variable is used primarily in the target platform management system to locate, validate, and set up the necessary SDK environment for various platforms supported by Unreal Engine.

AutoSDKPath is mainly utilized by the TargetPlatform module, which is responsible for managing platform-specific configurations and build processes. This variable is crucial for the engine’s ability to support multiple platforms and ensure that the correct SDK is used for each target platform during development and build processes.

The value of this variable is typically set in platform-specific configuration files, particularly in the data-driven platform information system. It’s loaded from INI files as seen in the LoadDDPIIniSettings function in the DataDrivenPlatformInfoRegistry.cpp file.

AutoSDKPath interacts with several other variables and systems within Unreal Engine, including:

  1. The SetupAndValidateAutoSDK function, which uses this path to verify and set up the SDK environment.
  2. The InitializeSinglePlatform function, which takes this path as a parameter when initializing platform-specific modules.
  3. The UpdateAfterSDKInstall function, which uses this path to re-initialize platform setups after SDK updates.

Developers should be aware of the following when using this variable:

  1. The path should be correctly set for each platform in the appropriate configuration files.
  2. Changes to the SDK location may require updates to this variable.
  3. The engine uses this path to set up environment variables and validate the SDK installation.

Best practices when using AutoSDKPath include:

  1. Ensure the path is always up-to-date and points to the correct SDK version for each platform.
  2. Use relative paths when possible to maintain portability across different development environments.
  3. Regularly validate the SDK setup using the engine’s built-in validation tools.
  4. When distributing projects or engine builds, ensure that the AutoSDKPath is correctly configured for all target platforms.

By properly managing the AutoSDKPath, developers can ensure smooth cross-platform development and build processes in Unreal Engine 5.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/DataDrivenPlatformInfo.ini:16, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Config/IOS/DataDrivenPlatformInfo.ini:16, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Config/Linux/DataDrivenPlatformInfo.ini:17, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Config/LinuxArm64/DataDrivenPlatformInfo.ini:20, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Config/Mac/DataDrivenPlatformInfo.ini:17, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Config/TVOS/DataDrivenPlatformInfo.ini:10, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Config/Windows/DataDrivenPlatformInfo.ini:23, section: [DataDrivenPlatformInfo]

Location: <Workspace>/Engine/Platforms/VisionOS/Config/DataDrivenPlatformInfo.ini:10, section: [DataDrivenPlatformInfo]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:215

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     FTargetPlatformManagerModule

Source code excerpt:

			for (auto Pair: FDataDrivenPlatformInfoRegistry::GetAllPlatformInfos())
			{
				if (Pair.Value.AutoSDKPath.Len() > 0)
			{
					SetupAndValidateAutoSDK(Pair.Value.AutoSDKPath);
				}
			}
		}
#endif

		TextureFormatManager = FModuleManager::LoadModulePtr<ITextureFormatManagerModule>("TextureFormat");

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:762

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool InitializeSinglePlatform

Source code excerpt:



	bool InitializeSinglePlatform(FName PlatformName, const FString& AutoSDKPath)
	{
		TRACE_CPUPROFILER_EVENT_SCOPE(FTargetPlatformManagerModule::InitializeSinglePlatform);

		// try the incoming name as a module name, or as a platform name
		FName PlatformModuleName = PlatformName;
		//@todo Custom TargetPlatforms

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:817

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool InitializeSinglePlatform

Source code excerpt:

			// this setup will become faster after TTP 341897 is complete.
		RETRY_SETUPANDVALIDATE:
			if (AutoSDKPath == TEXT("") || SetupAndValidateAutoSDK(AutoSDKPath))
			{

				if (ModuleControls != nullptr)
				{
					TArray<ITargetPlatformControls*> TargetPlatformControls = ModuleControls->GetTargetPlatformControls(PlatformSettingsModuleName);
					for (ITargetPlatformControls* Platform : TargetPlatformControls)

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:912

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     void DiscoverAvailablePlatforms

Source code excerpt:

			if (Info.bEnabledForUse)
			{
				InitializeSinglePlatform(PlatformName, Info.AutoSDKPath);
			}
		}

		TArray<FString> CustomTargetPlatformModules;
		GConfig->GetArray(TEXT("CustomTargetPlatforms"), TEXT("ModuleName"), CustomTargetPlatformModules, GEditorIni);
		for (const FString& ModuleName : CustomTargetPlatformModules)

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:936

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool SetupAndValidateAutoSDK

Source code excerpt:

	}

	bool SetupAndValidateAutoSDK(const FString& AutoSDKPath)
	{
		TRACE_CPUPROFILER_EVENT_SCOPE(FTargetPlatformManagerModule::SetupAndValidateAutoSDK);

#if AUTOSDKS_ENABLED
		bool bValidSDK = false;
		if (AutoSDKPath.Len() > 0)
		{		
			FName PlatformFName(*AutoSDKPath);

			// cache result of the last setup attempt to avoid calling UBT all the time.
			bool* bPreviousSetupSuccessful = PlatformsSetup.Find(PlatformFName);
			if (bPreviousSetupSuccessful)
			{
				bValidSDK = *bPreviousSetupSuccessful;

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:954

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool SetupAndValidateAutoSDK

Source code excerpt:

			else
			{
				bValidSDK = SetupEnvironmentFromAutoSDK(AutoSDKPath);
				PlatformsSetup.Add(PlatformFName, bValidSDK);
			}
		}
		else
		{
			// if a platform has no AutoSDKPath, then just assume the SDK is installed, we have no basis for determining it.
			bValidSDK = true;
		}
		return bValidSDK;
#else
		return true;
#endif // AUTOSDKS_ENABLED
	}
	
	bool SetupEnvironmentFromAutoSDK(const FString& AutoSDKPath)
	{
		TRACE_CPUPROFILER_EVENT_SCOPE(FTargetPlatformManagerModule::SetupEnvironmentFromAutoSDK);

#if AUTOSDKS_ENABLED
		
		if (!UE::AutoSDK::IsAutoSDKsEnabled())

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:990

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool SetupEnvironmentFromAutoSDK

Source code excerpt:

		FString SDKPath = FPlatformMisc::GetEnvironmentVariable(*SDKRootEnvFar);

		FString TargetSDKRoot = FPaths::Combine(*SDKPath, *HostPlatform, *AutoSDKPath);
		static const FString SDKInstallManifestFileName(TEXT("CurrentlyInstalled.txt"));
		FString SDKInstallManifestFilePath = FPaths::Combine(*TargetSDKRoot, *SDKInstallManifestFileName);

		// If we are using a manual install, then it is valid for there to be no OutputEnvVars file.
		TUniquePtr<FArchive> InstallManifestFile(IFileManager::Get().CreateFileReader(*SDKInstallManifestFilePath));
		if (InstallManifestFile)

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:1015

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool SetupEnvironmentFromAutoSDK

Source code excerpt:

			if (FileLines.Num() != 2 && FileLines.Num() != 3)
			{
				UE_LOG(LogTargetPlatformManager, Warning, TEXT("Malformed install manifest file for Platform %s"), *AutoSDKPath);
				return false;
			}

			static const FString ManualSDKString(TEXT("ManualSDK"));
			if (FileLines[1].Compare(ManualSDKString, ESearchCase::IgnoreCase) == 0)
			{
				UE_LOG(LogTargetPlatformManager, Verbose, TEXT("Platform %s has manual sdk install"), *AutoSDKPath);				
				return true;
			}
		}
		else
		{	
			UE_LOG(LogTargetPlatformManager, Log, TEXT("Install manifest file for Platform %s not found.  Platform not set up."), *AutoSDKPath);			
			return false;			
		}		

		static const FString SDKEnvironmentVarsFile(TEXT("OutputEnvVars.txt"));
		FString EnvVarFileName = FPaths::Combine(*TargetSDKRoot, *SDKEnvironmentVarsFile);		

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:1148

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool SetupEnvironmentFromAutoSDK

Source code excerpt:

		else
		{
			UE_LOG(LogTargetPlatformManager, Warning, TEXT("OutputEnvVars.txt not found for platform: '%s'"), *AutoSDKPath);			
			return false;
		}

		UE_LOG(LogTargetPlatformManager, Verbose, TEXT("Platform %s has auto sdk install"), *AutoSDKPath);		
		return true;
#else
		return true;
#endif
	}

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:1267

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool UpdateAfterSDKInstall

Source code excerpt:


#if AUTOSDKS_ENABLED
		FString AutoSDKPath = Info.AutoSDKPath;
		FName AutoSDKName(*AutoSDKPath);
		if (AutoSDKName != NAME_None)
		{
			// make sure we can re-do the AutoSDK setup
			PlatformsSetup.Remove(AutoSDKName);
		}
#endif

#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Private/TargetPlatformManagerModule.cpp:1286

Scope (from outer to inner):

file
class        class FTargetPlatformManagerModule : public ITargetPlatformManagerModule
function     bool UpdateAfterSDKInstall

Source code excerpt:

			if (Info.bEnabledForUse)
			{
				bTPInitialized = InitializeSinglePlatform(PlatformName, Info.AutoSDKPath);
			}
		}
		else
		{
#if AUTOSDKS_ENABLED
			if (AutoSDKName != NAME_None)
			{
				// setup AutoSDK, and then re-initialize the TP
				SetupAndValidateAutoSDK(AutoSDKPath);
			}
#endif

			bTPInitialized = TargetPlatform->InitializeHostPlatform();
		}

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Misc/DataDrivenPlatformInfoRegistry.cpp:365

Scope (from outer to inner):

file
function     static void LoadDDPIIniSettings

Source code excerpt:

#if DDPI_HAS_EXTENDED_PLATFORMINFO_DATA

	DDPIGetString(IniFile, TEXT("AutoSDKPath"), Info.AutoSDKPath);
	DDPIGetString(IniFile, TEXT("TutorialPath"), Info.SDKTutorial);
	DDPIGetName(IniFile, TEXT("PlatformGroupName"), Info.PlatformGroupName);
	DDPIGetName(IniFile, TEXT("PlatformSubMenu"), Info.PlatformSubMenu);


	DDPIGetString(IniFile, TEXT("NormalIconPath"), Info.IconPaths.NormalPath);

#Loc: <Workspace>/Engine/Source/Runtime/Core/Public/Misc/DataDrivenPlatformInfoRegistry.h:189

Scope: file

Source code excerpt:


	/** Path under CarefullyRedist for the SDK.  FString so case sensitive platforms don't get messed up by a pre-existing FName of a different casing. */
	FString AutoSDKPath;

	/** Tutorial path for tutorial to install SDK */
	FString SDKTutorial;

	/** An identifier to group similar platforms together, such as "Mobile" and "Console". Used for Per-Platform Override Properties. */
	FName PlatformGroupName;