// Georgy Treshchev 2026 All Rights Reserved.

using UnrealBuildTool;
using System.IO;

public class RuntimeSpeechRecognizerVoskEditor : ModuleRules
{
	// In earlier UE versions (such as 4.27), the architecture string is empty.
	protected string ArchitectureString
	{
		get
		{
			if (Target.Architecture.ToString().Length > 0)
			{
				return Target.Architecture.ToString();
			}
			else
			{
				return "x64";
			}
		}
	}
	
	public RuntimeSpeechRecognizerVoskEditor(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new[]
		{
			"Core",
			"CoreUObject",
			"Engine",
			"RuntimeSpeechRecognizer",
			"RuntimeSpeechRecognizerEditor",
			"RuntimeSpeechRecognizerVosk"
		});

		PrivateDependencyModuleNames.AddRange(new[]
		{
			"Slate",
			"SlateCore",
			"UnrealEd",
			"PropertyEditor",
			"InputCore",
			"HTTP",
			"Projects",
			"FileUtilities",
			"EditorStyle"
		});
		
		if ((Target.Version.MajorVersion >= 5 && Target.Version.MinorVersion < 3) || (Target.Version.MajorVersion < 5))
		{
			PrivateDependencyModuleNames.Add("OpenSSL");
			PrivateDependencyModuleNames.Add("zlib");

			string VersionPath = Path.Combine(ModuleDirectory, "1.9.2");
			string LibraryPath = Path.Combine(VersionPath, "lib");

			PublicSystemIncludePaths.Add(Path.Combine(VersionPath, "include"));

			if (Target.Platform == UnrealTargetPlatform.Win64)
			{
				PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "Win64", ArchitectureString, "Release", "zip.lib"));
			}
			else if (Target.Platform == UnrealTargetPlatform.Mac)
			{
				PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "Mac", "Release", "libzip.a"));
			}
			else if (Target.IsInPlatformGroup(UnrealPlatformGroup.Unix))
			{
				PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "Unix", ArchitectureString, "Release", "libzip.a"));
			}
		}
		
		if (Target.Version.MajorVersion >= 5 && Target.Version.MinorVersion >= 0)
		{
			PrivateDependencyModuleNames.AddRange(
				new string[]
				{
					"DeveloperToolSettings"
				}
			);
		}
	}
}