WwiseSoundEngine_2022_1_OptionalModule.Build.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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_0_OR_LATER
  20. using EpicGames.Core;
  21. #else
  22. using Tools.DotNETCommon;
  23. #endif
  24. public struct WwiseSoundEngine_2022_1
  25. {
  26. private static List<string> AkLibs = new List<string>
  27. {
  28. "AkSoundEngine",
  29. "AkMemoryMgr",
  30. "AkStreamMgr",
  31. "AkMusicEngine",
  32. "AkSpatialAudio",
  33. "AkAudioInputSource",
  34. "AkVorbisDecoder",
  35. "AkMeterFX", // AkMeter does not have a dedicated DLL
  36. };
  37. public static void Apply(WwiseSoundEngine SE, ReadOnlyTargetRules Target)
  38. {
  39. var VersionNumber = "2022_1";
  40. var ModuleName = "WwiseSoundEngine_" + VersionNumber;
  41. var ModuleDirectory = Path.Combine(SE.ModuleDirectory, "../" + ModuleName);
  42. if (!WwiseSoundEngineVersion.IsSoundEngineVersionSupported(SE.PluginDirectory, ModuleName))
  43. {
  44. // We are skipping this version since this Wwise Sound Engine is for a particular version only.
  45. return;
  46. }
  47. Log.TraceInformation("Using Wwise SoundEngine {0} interface", VersionNumber);
  48. SE.PublicDefinitions.AddRange(WwiseSoundEngineVersion.GetVersionDefinesFromClassName(ModuleName));
  49. // If packaging as an Engine plugin, the UBT expects to already have a precompiled plugin available
  50. // This can be set to true so long as plugin was already precompiled
  51. SE.bUsePrecompiled = false;
  52. SE.bPrecompile = false;
  53. string ThirdPartyFolder = Path.Combine(SE.ModuleDirectory, "../../ThirdParty");
  54. var WwiseUEPlatformInstance = WwiseUEPlatform.GetWwiseUEPlatformInstance(Target, VersionNumber, ThirdPartyFolder);
  55. SE.PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
  56. SE.bAllowConfidentialPlatformDefines = true;
  57. SE.AddSoundEngineDirectory("WwiseSoundEngine_" + VersionNumber, WwiseUEPlatformInstance.IsWwiseTargetSupported());
  58. SE.AddVersionHeaders("WwiseSoundEngine_" + VersionNumber, WwiseUEPlatformInstance.IsWwiseTargetSupported());
  59. foreach (var Platform in GetAvailablePlatforms(ModuleDirectory))
  60. {
  61. SE.ExternalDependencies.Add(string.Format("{0}/WwiseUEPlatform_{1}_{2}.Build.cs", ModuleDirectory, VersionNumber, Platform));
  62. }
  63. if (Target.bBuildEditor)
  64. {
  65. foreach (var Platform in GetAvailablePlatforms(ModuleDirectory))
  66. {
  67. SE.PublicDefinitions.Add("AK_PLATFORM_" + Platform.ToUpper());
  68. }
  69. }
  70. SE.PublicIncludePaths.Add(Path.Combine(ThirdPartyFolder, "include"));
  71. SE.PublicDefinitions.Add("AK_UNREAL_MAX_CONCURRENT_IO=32");
  72. SE.PublicDefinitions.Add("AK_UNREAL_IO_GRANULARITY=32768");
  73. if (Target.Configuration == UnrealTargetConfiguration.Shipping)
  74. {
  75. SE.PublicDefinitions.Add("AK_OPTIMIZED");
  76. }
  77. if (Target.Configuration != UnrealTargetConfiguration.Shipping && WwiseUEPlatformInstance.SupportsCommunication)
  78. {
  79. AkLibs.Add("CommunicationCentral");
  80. SE.PublicDefinitions.Add("AK_ENABLE_COMMUNICATION=1");
  81. }
  82. else
  83. {
  84. SE.PublicDefinitions.Add("AK_ENABLE_COMMUNICATION=0");
  85. }
  86. if (WwiseUEPlatformInstance.SupportsAkAutobahn)
  87. {
  88. AkLibs.Add("AkAutobahn");
  89. SE.PublicDefinitions.Add("AK_SUPPORT_WAAPI=1");
  90. }
  91. else
  92. {
  93. SE.PublicDefinitions.Add("AK_SUPPORT_WAAPI=0");
  94. }
  95. if (WwiseUEPlatformInstance.SupportsOpus)
  96. {
  97. AkLibs.Add("AkOpusDecoder");
  98. SE.PublicDefinitions.Add("AK_SUPPORT_OPUS=1");
  99. }
  100. else
  101. {
  102. SE.PublicDefinitions.Add("AK_SUPPORT_OPUS=0");
  103. }
  104. if (WwiseUEPlatformInstance.SupportsDeviceMemory)
  105. {
  106. SE.PublicDefinitions.Add("AK_SUPPORT_DEVICE_MEMORY=1");
  107. }
  108. else
  109. {
  110. SE.PublicDefinitions.Add("AK_SUPPORT_DEVICE_MEMORY=0");
  111. }
  112. // Platform-specific dependencies
  113. SE.PublicDefinitions.AddRange(WwiseUEPlatformInstance.GetPublicDefinitions());
  114. SE.PublicDefinitions.Add(string.Format("AK_CONFIGURATION=\"{0}\"", WwiseUEPlatformInstance.AkConfigurationDir));
  115. if (WwiseUEPlatformInstance.IsWwiseTargetSupported())
  116. {
  117. SE.PublicSystemLibraries.AddRange(WwiseUEPlatformInstance.GetPublicSystemLibraries());
  118. AkLibs.AddRange(WwiseUEPlatformInstance.GetAdditionalWwiseLibs());
  119. var AdditionalProperty = WwiseUEPlatformInstance.GetAdditionalPropertyForReceipt(ModuleDirectory);
  120. if (AdditionalProperty != null)
  121. {
  122. SE.AdditionalPropertiesForReceipt.Add(AdditionalProperty.Item1, AdditionalProperty.Item2);
  123. }
  124. SE.PublicFrameworks.AddRange(WwiseUEPlatformInstance.GetPublicFrameworks());
  125. SE.PublicDelayLoadDLLs.AddRange(WwiseUEPlatformInstance.GetPublicDelayLoadDLLs());
  126. foreach (var RuntimeDependency in WwiseUEPlatformInstance.GetRuntimeDependencies())
  127. {
  128. SE.RuntimeDependencies.Add(RuntimeDependency);
  129. }
  130. SE.PublicAdditionalLibraries.AddRange(WwiseUEPlatformInstance.GetSanitizedAkLibList(AkLibs));
  131. }
  132. }
  133. private static List<string> GetAvailablePlatforms(string ModuleDir)
  134. {
  135. var FoundPlatforms = new List<string>();
  136. const string StartPattern = "WwiseUEPlatform_";
  137. const string EndPattern = ".Build.cs";
  138. foreach (var BuildCsFile in System.IO.Directory.GetFiles(ModuleDir, "*" + EndPattern))
  139. {
  140. if (BuildCsFile.Contains(StartPattern) && BuildCsFile.EndsWith(EndPattern))
  141. {
  142. var Platform = BuildCsFile.Remove(BuildCsFile.Length - EndPattern.Length).Split('_').Last();
  143. FoundPlatforms.Add(Platform);
  144. }
  145. }
  146. return FoundPlatforms;
  147. }
  148. }