WwiseUEPlatform.Build.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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;
  17. using System.IO;
  18. using System.Collections.Generic;
  19. // Platform-specific files implement this interface, returning their particular dependencies, defines, etc.
  20. public abstract class WwiseUEPlatform
  21. {
  22. protected ReadOnlyTargetRules Target;
  23. protected string ThirdPartyFolder;
  24. public WwiseUEPlatform(ReadOnlyTargetRules in_Target, string in_ThirdPartyFolder)
  25. {
  26. Target = in_Target;
  27. ThirdPartyFolder = in_ThirdPartyFolder;
  28. }
  29. public bool IsWwiseTargetSupported()
  30. {
  31. var platformPath = Path.Combine(ThirdPartyFolder, AkPlatformLibDir);
  32. var hasPlatform = Directory.Exists(platformPath);
  33. var supportedTargetType = Target.Type != TargetRules.TargetType.Server && Target.Type != TargetRules.TargetType.Program;
  34. return hasPlatform && supportedTargetType;
  35. }
  36. public static WwiseUEPlatform GetWwiseUEPlatformInstance(ReadOnlyTargetRules Target, string VersionNumber, string ThirdPartyFolder)
  37. {
  38. var WwiseUEPlatformType = System.Type.GetType(
  39. VersionNumber == "Null" ? "WwiseUEPlatform_Null" :
  40. "WwiseUEPlatform_" + VersionNumber + "_" + Target.Platform.ToString());
  41. if (WwiseUEPlatformType == null)
  42. {
  43. throw new BuildException("Wwise does not support platform " + Target.Platform.ToString() + " on " + VersionNumber);
  44. }
  45. var PlatformInstance = Activator.CreateInstance(WwiseUEPlatformType, Target, ThirdPartyFolder) as WwiseUEPlatform;
  46. if (PlatformInstance == null)
  47. {
  48. throw new BuildException("Wwise could not instantiate platform " + Target.Platform.ToString() + " on " + VersionNumber);
  49. }
  50. return PlatformInstance;
  51. }
  52. protected static List<string> GetAllLibrariesInFolder(string LibFolder, string Extension, bool RemoveLibPrefix = true, bool GetFullPath = false)
  53. {
  54. List<string> ret = null;
  55. var FoundLibs = Directory.GetFiles(LibFolder, "*."+Extension);
  56. if (GetFullPath)
  57. {
  58. ret = new List<string>(FoundLibs);
  59. }
  60. else
  61. {
  62. ret = new List<string>();
  63. foreach (var Library in FoundLibs)
  64. {
  65. var LibName = Path.GetFileNameWithoutExtension(Library);
  66. if (RemoveLibPrefix && LibName.StartsWith("lib"))
  67. {
  68. LibName = LibName.Remove(0, 3);
  69. }
  70. ret.Add(LibName);
  71. }
  72. }
  73. return ret;
  74. }
  75. public virtual string AkConfigurationDir
  76. {
  77. get
  78. {
  79. switch (Target.Configuration)
  80. {
  81. case UnrealTargetConfiguration.Debug:
  82. var akConfiguration = Target.bDebugBuildsActuallyUseDebugCRT ? "Debug" : "Profile";
  83. return akConfiguration;
  84. case UnrealTargetConfiguration.Development:
  85. case UnrealTargetConfiguration.Test:
  86. case UnrealTargetConfiguration.DebugGame:
  87. return "Profile";
  88. default:
  89. return "Release";
  90. }
  91. }
  92. }
  93. public abstract string GetLibraryFullPath(string LibName, string LibPath);
  94. public abstract bool SupportsAkAutobahn { get; }
  95. public abstract bool SupportsCommunication { get; }
  96. public abstract bool SupportsDeviceMemory { get; }
  97. public abstract string AkPlatformLibDir { get; }
  98. public abstract string DynamicLibExtension { get; }
  99. public virtual bool SupportsOpus { get { return true; } }
  100. public virtual List<string> GetPublicLibraryPaths()
  101. {
  102. return new List<string>
  103. {
  104. Path.Combine(ThirdPartyFolder, AkPlatformLibDir, AkConfigurationDir, "lib")
  105. };
  106. }
  107. public virtual List<string> GetRuntimeDependencies()
  108. {
  109. return GetAllLibrariesInFolder(Path.Combine(ThirdPartyFolder, AkPlatformLibDir, AkConfigurationDir, "bin"), DynamicLibExtension, false, true);
  110. }
  111. public abstract List<string> GetAdditionalWwiseLibs();
  112. public abstract List<string> GetPublicSystemLibraries();
  113. public abstract List<string> GetPublicDelayLoadDLLs();
  114. public abstract List<string> GetPublicDefinitions();
  115. public abstract Tuple<string, string> GetAdditionalPropertyForReceipt(string ModuleDirectory);
  116. public abstract List<string> GetPublicFrameworks();
  117. public virtual List<string> GetSanitizedAkLibList(List<string> AkLibs)
  118. {
  119. List<string> SanitizedLibs = new List<string>();
  120. foreach(var lib in AkLibs)
  121. {
  122. foreach(var libPath in GetPublicLibraryPaths())
  123. {
  124. SanitizedLibs.Add(GetLibraryFullPath(lib, libPath));
  125. }
  126. }
  127. return SanitizedLibs;
  128. }
  129. }