// Copyright Epic Games, Inc. All Rights Reserved.

using System.IO;
using UnrealBuildTool;

public class AronaCore : ModuleRules
{
	public AronaCore(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
		
		PublicIncludePaths.AddRange(
			new string[] {
				ModuleDirectory
			}
		);
		
		PublicDependencyModuleNames.AddRange(
			new string[]
			{
				"Core",
				"PortAudio",
				"VST",
				"Sndfile",
				"SignalProcessing",
				"UELibSampleRate"
				// ... add other public dependencies that you statically link with here ...
			}
		);
		
		JuceSetup(Target);
	}
	
	void JuceSetup(ReadOnlyTargetRules Target)
	{
		PublicDefinitions.AddRange(new []
		{
			"DOXYGEN=0",
			"JUCE_EXCEPTIONS_DISABLED=0",
		});
		
		// setup big le endian
		if (Target.Platform == UnrealTargetPlatform.Mac)
		{
			PublicDefinitions.AddRange(new []
			{
				"JUCE_BIG_ENDIAN=1",
				"JUCE_LITTLE_ENDIAN=0",
			});
		}
		else
		{
			PublicDefinitions.AddRange(new []
			{
				"JUCE_BIG_ENDIAN=0",
				"JUCE_LITTLE_ENDIAN=1",
			});
		}
		
		// setup platform
		if (Target.Platform == UnrealTargetPlatform.Win64)
		{
			PublicDefinitions.AddRange(new []
			{
				"JUCE_MAC=0",
				"TARGET_API_MAC_CARBON=0",
				"JUCE_IOS=0",
				"JUCE_ANDROID=0",
			});
		}
		else if (Target.Platform == UnrealTargetPlatform.Mac)
		{
			PublicDefinitions.AddRange(new []
			{
				"JUCE_MAC=1",
				"JUCE_IOS=0",
				"JUCE_ANDROID=0",
			});
		}
		else if (Target.Platform == UnrealTargetPlatform.IOS)
		{
			PublicDefinitions.AddRange(new []
			{
				"JUCE_MAC=0",
				"JUCE_IOS=1",
				"JUCE_ANDROID=0",
			});
		}
		else if (Target.Platform == UnrealTargetPlatform.Android)
		{
			PublicDefinitions.AddRange(new []
			{
				"JUCE_MAC=0",
				"JUCE_IOS=0",
				"JUCE_ANDROID=1",
			});
		}
		
		// setup compiler
		if (Target.WindowsPlatform.Compiler == WindowsCompiler.VisualStudio2022 ||
		    Target.WindowsPlatform.Compiler == WindowsCompiler.VisualStudio2019)
		{
			PublicDefinitions.AddRange(new[]
			{
				"JUCE_MSVC=1",
				"JUCE_CLANG=0",
				"JUCE_GCC=0",
			});
		}
		else if (Target.WindowsPlatform.Compiler == WindowsCompiler.Clang || Target.WindowsPlatform.Compiler == WindowsCompiler.ClangRTFM)
		{
			PublicDefinitions.AddRange(new[]
			{
				"JUCE_MSVC=0",
				"JUCE_CLANG=1",
				"JUCE_GCC=0",
			});
		}
		else
		{
			PublicDefinitions.AddRange(new[]
			{
				"JUCE_MSVC=0",
				"JUCE_CLANG=0",
				"JUCE_GCC=0",
			});
		}
	}
}