WwiseSoundEngine_2022_1_OptionalModule.Build.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. using UnrealBuildTool;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Collections.Generic;
  19. #if UE_5_3_OR_LATER
  20. using Microsoft.Extensions.Logging;
  21. #elif UE_5_0_OR_LATER
  22. using EpicGames.Core;
  23. #else
  24. using Tools.DotNETCommon;
  25. #endif
  26. public struct WwiseSoundEngine_2022_1
  27. {
  28. private static List<string> AkLibs = new List<string>
  29. {
  30. "AkSoundEngine",
  31. "AkMemoryMgr",
  32. "AkStreamMgr",
  33. "AkMusicEngine",
  34. "AkSpatialAudio",
  35. "AkAudioInputSource",
  36. "AkVorbisDecoder",
  37. "AkMeterFX", // AkMeter does not have a dedicated DLL
  38. };
  39. public static void Apply(WwiseSoundEngine SE, ReadOnlyTargetRules Target, bool Latest = false)
  40. {
  41. #if UE_5_3_OR_LATER
  42. ILogger Logger = Target.Logger;
  43. #endif
  44. var VersionNumber = "2022_1";
  45. var ModuleName = "WwiseSoundEngine_" + VersionNumber;
  46. var ModuleDirectory = Path.Combine(SE.ModuleDirectory, "../" + ModuleName);
  47. if (!WwiseSoundEngineVersion.IsSoundEngineVersionSupported(SE.PluginDirectory, ModuleName))
  48. {
  49. // We are skipping this version since this Wwise Sound Engine is for a particular version only.
  50. return;
  51. }
  52. SE.PublicDefinitions.AddRange(WwiseSoundEngineVersion.GetVersionDefinesFromClassName(ModuleName));
  53. // If packaging as an Engine plugin, the UBT expects to already have a precompiled plugin available
  54. // This can be set to true so long as plugin was already precompiled
  55. SE.bUsePrecompiled = false;
  56. SE.bPrecompile = false;
  57. string ThirdPartyFolder = Path.Combine(SE.ModuleDirectory, "../../ThirdParty");
  58. var WwiseUEPlatformInstance = WwiseUEPlatform.GetWwiseUEPlatformInstance(Target, VersionNumber, ThirdPartyFolder);
  59. SE.PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
  60. SE.bAllowConfidentialPlatformDefines = true;
  61. if (!Latest)
  62. {
  63. #if UE_5_3_OR_LATER
  64. Logger.LogInformation("Using Wwise SoundEngine {VersionNumber} [{ConfigurationDir}]", VersionNumber, WwiseUEPlatformInstance.WwiseConfigurationDir);
  65. #else
  66. Log.TraceInformation("Using Wwise SoundEngine {0} [{1}]", VersionNumber, WwiseUEPlatformInstance.WwiseConfigurationDir);
  67. #endif
  68. }
  69. var IsWwiseTargetSupported = WwiseUEPlatformInstance.IsWwiseTargetSupported();
  70. SE.AddSoundEngineDirectory("WwiseSoundEngine_" + VersionNumber, IsWwiseTargetSupported);
  71. SE.AddVersionHeaders("WwiseSoundEngine_" + VersionNumber, IsWwiseTargetSupported);
  72. foreach (var Platform in GetAvailablePlatforms(ModuleDirectory))
  73. {
  74. SE.ExternalDependencies.Add(string.Format("{0}/WwiseUEPlatform_{1}_{2}.Build.cs", ModuleDirectory, VersionNumber, Platform));
  75. }
  76. if (Target.bBuildEditor)
  77. {
  78. foreach (var Platform in GetAvailablePlatforms(ModuleDirectory))
  79. {
  80. SE.PublicDefinitions.Add("AK_PLATFORM_" + Platform.ToUpper());
  81. }
  82. }
  83. SE.PublicIncludePaths.Add(Path.Combine(ThirdPartyFolder, "include"));
  84. SE.PublicDefinitions.Add("AK_UNREAL_MAX_CONCURRENT_IO=32");
  85. SE.PublicDefinitions.Add("AK_UNREAL_IO_GRANULARITY=32768");
  86. if (Target.Configuration == UnrealTargetConfiguration.Shipping || !IsWwiseTargetSupported)
  87. {
  88. SE.PublicDefinitions.Add("AK_OPTIMIZED");
  89. }
  90. else
  91. {
  92. SE.PublicDefinitions.Add("AK_ENABLE_ASSERTS");
  93. }
  94. if (Target.Configuration != UnrealTargetConfiguration.Shipping && WwiseUEPlatformInstance.SupportsCommunication)
  95. {
  96. AkLibs.Add("CommunicationCentral");
  97. SE.PublicDefinitions.Add("AK_ENABLE_COMMUNICATION=1");
  98. }
  99. else
  100. {
  101. SE.PublicDefinitions.Add("AK_ENABLE_COMMUNICATION=0");
  102. }
  103. if (WwiseUEPlatformInstance.SupportsAkAutobahn)
  104. {
  105. AkLibs.Add("AkAutobahn");
  106. SE.PublicDefinitions.Add("AK_SUPPORT_WAAPI=1");
  107. }
  108. else
  109. {
  110. SE.PublicDefinitions.Add("AK_SUPPORT_WAAPI=0");
  111. }
  112. if (WwiseUEPlatformInstance.SupportsOpus)
  113. {
  114. AkLibs.Add("AkOpusDecoder");
  115. SE.PublicDefinitions.Add("AK_SUPPORT_OPUS=1");
  116. }
  117. else
  118. {
  119. SE.PublicDefinitions.Add("AK_SUPPORT_OPUS=0");
  120. }
  121. if (WwiseUEPlatformInstance.SupportsDeviceMemory)
  122. {
  123. SE.PublicDefinitions.Add("AK_SUPPORT_DEVICE_MEMORY=1");
  124. }
  125. else
  126. {
  127. SE.PublicDefinitions.Add("AK_SUPPORT_DEVICE_MEMORY=0");
  128. }
  129. // Platform-specific dependencies
  130. SE.PublicDefinitions.AddRange(WwiseUEPlatformInstance.GetPublicDefinitions());
  131. SE.PublicDefinitions.Add(string.Format("WWISE_CONFIGURATION_DIR=\"{0}\"", WwiseUEPlatformInstance.WwiseConfigurationDir));
  132. SE.PublicDefinitions.Add(string.Format("WWISE_DSP_DIR=\"{0}\"", WwiseUEPlatformInstance.WwiseDspDir));
  133. if (IsWwiseTargetSupported)
  134. {
  135. SE.PublicSystemLibraries.AddRange(WwiseUEPlatformInstance.GetPublicSystemLibraries());
  136. AkLibs.AddRange(WwiseUEPlatformInstance.GetAdditionalWwiseLibs());
  137. var AdditionalProperty = WwiseUEPlatformInstance.GetAdditionalPropertyForReceipt(ModuleDirectory);
  138. if (AdditionalProperty != null)
  139. {
  140. SE.AdditionalPropertiesForReceipt.Add(AdditionalProperty.Item1, AdditionalProperty.Item2);
  141. }
  142. SE.PublicFrameworks.AddRange(WwiseUEPlatformInstance.GetPublicFrameworks());
  143. SE.PublicDelayLoadDLLs.AddRange(WwiseUEPlatformInstance.GetPublicDelayLoadDLLs());
  144. foreach (var RuntimeDependency in WwiseUEPlatformInstance.GetRuntimeDependencies())
  145. {
  146. SE.RuntimeDependencies.Add(RuntimeDependency);
  147. }
  148. SE.PublicAdditionalLibraries.AddRange(WwiseUEPlatformInstance.GetSanitizedAkLibList(AkLibs));
  149. }
  150. }
  151. private static List<string> GetAvailablePlatforms(string ModuleDir)
  152. {
  153. var FoundPlatforms = new List<string>();
  154. const string StartPattern = "WwiseUEPlatform_";
  155. const string EndPattern = ".Build.cs";
  156. foreach (var BuildCsFile in System.IO.Directory.GetFiles(ModuleDir, "*" + EndPattern))
  157. {
  158. if (BuildCsFile.Contains(StartPattern) && BuildCsFile.EndsWith(EndPattern))
  159. {
  160. var Platform = BuildCsFile.Remove(BuildCsFile.Length - EndPattern.Length).Split('_').Last();
  161. FoundPlatforms.Add(Platform);
  162. }
  163. }
  164. return FoundPlatforms;
  165. }
  166. }