/******************************************************************************* The content of this file includes portions of the proprietary AUDIOKINETIC Wwise Technology released in source code form as part of the game integration package. The content of this file may not be used without valid licenses to the AUDIOKINETIC Wwise Technology. Note that the use of the game engine is subject to the Unreal(R) Engine End User License Agreement at https://www.unrealengine.com/en-US/eula/unreal License Usage Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use this file in accordance with the end user license agreement provided with the software or, alternatively, in accordance with the terms contained in a written agreement between you and Audiokinetic Inc. Copyright (c) 2023 Audiokinetic Inc. *******************************************************************************/ using UnrealBuildTool; using System; using System.IO; using System.Collections.Generic; // Platform-specific files implement this interface, returning their particular dependencies, defines, etc. public abstract class WwiseUEPlatform { protected ReadOnlyTargetRules Target; protected string ThirdPartyFolder; public WwiseUEPlatform(ReadOnlyTargetRules in_Target, string in_ThirdPartyFolder) { Target = in_Target; ThirdPartyFolder = in_ThirdPartyFolder; } public bool IsWwiseTargetSupported() { var platformPath = Path.Combine(ThirdPartyFolder, AkPlatformLibDir); var hasPlatform = Directory.Exists(platformPath); var supportedTargetType = Target.Type != TargetRules.TargetType.Server && Target.Type != TargetRules.TargetType.Program; return hasPlatform && supportedTargetType; } public static WwiseUEPlatform GetWwiseUEPlatformInstance(ReadOnlyTargetRules Target, string VersionNumber, string ThirdPartyFolder) { var WwiseUEPlatformType = System.Type.GetType( VersionNumber == "Null" ? "WwiseUEPlatform_Null" : "WwiseUEPlatform_" + VersionNumber + "_" + Target.Platform.ToString()); if (WwiseUEPlatformType == null) { throw new BuildException("Wwise does not support platform " + Target.Platform.ToString() + " on " + VersionNumber); } var PlatformInstance = Activator.CreateInstance(WwiseUEPlatformType, Target, ThirdPartyFolder) as WwiseUEPlatform; if (PlatformInstance == null) { throw new BuildException("Wwise could not instantiate platform " + Target.Platform.ToString() + " on " + VersionNumber); } return PlatformInstance; } protected static List GetAllLibrariesInFolder(string LibFolder, string Extension, bool RemoveLibPrefix = true, bool GetFullPath = false) { List ret = null; var FoundLibs = Directory.GetFiles(LibFolder, "*."+Extension); if (GetFullPath) { ret = new List(FoundLibs); } else { ret = new List(); foreach (var Library in FoundLibs) { var LibName = Path.GetFileNameWithoutExtension(Library); if (RemoveLibPrefix && LibName.StartsWith("lib")) { LibName = LibName.Remove(0, 3); } ret.Add(LibName); } } return ret; } public virtual string AkConfigurationDir { get { switch (Target.Configuration) { case UnrealTargetConfiguration.Debug: var akConfiguration = Target.bDebugBuildsActuallyUseDebugCRT ? "Debug" : "Profile"; return akConfiguration; case UnrealTargetConfiguration.Development: case UnrealTargetConfiguration.Test: case UnrealTargetConfiguration.DebugGame: return "Profile"; default: return "Release"; } } } public abstract string GetLibraryFullPath(string LibName, string LibPath); public abstract bool SupportsAkAutobahn { get; } public abstract bool SupportsCommunication { get; } public abstract bool SupportsDeviceMemory { get; } public abstract string AkPlatformLibDir { get; } public abstract string DynamicLibExtension { get; } public virtual bool SupportsOpus { get { return true; } } public virtual List GetPublicLibraryPaths() { return new List { Path.Combine(ThirdPartyFolder, AkPlatformLibDir, AkConfigurationDir, "lib") }; } public virtual List GetRuntimeDependencies() { return GetAllLibrariesInFolder(Path.Combine(ThirdPartyFolder, AkPlatformLibDir, AkConfigurationDir, "bin"), DynamicLibExtension, false, true); } public abstract List GetAdditionalWwiseLibs(); public abstract List GetPublicSystemLibraries(); public abstract List GetPublicDelayLoadDLLs(); public abstract List GetPublicDefinitions(); public abstract Tuple GetAdditionalPropertyForReceipt(string ModuleDirectory); public abstract List GetPublicFrameworks(); public virtual List GetSanitizedAkLibList(List AkLibs) { List SanitizedLibs = new List(); foreach(var lib in AkLibs) { foreach(var libPath in GetPublicLibraryPaths()) { SanitizedLibs.Add(GetLibraryFullPath(lib, libPath)); } } return SanitizedLibs; } }