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

using System.IO;
using UnrealBuildTool;

public class PocketSphinxLibrary : ModuleRules
{

    private string ThirdPartyLibrariesDirectory
    {
        get
        {
            return Path.Combine(ModuleDirectory, Target.Platform.ToString());
        }
    }

    private string ThirdPartyIncludesDirectory
    {
        get
        {
            return Path.Combine(ModuleDirectory, "Public");
        }
    }

    private string PluginModelDirectory
    {
        get
        {
            return Path.Combine(PluginDirectory, "Model/...");
        }
    }

    private string PluginBinariesDirectory
    {
        get
        {
            return Path.Combine("$(PluginDir)", "Binaries", Target.Platform.ToString());
        }
    }

    public PocketSphinxLibrary(ReadOnlyTargetRules Target) : base(Target)
    {
        Type = ModuleType.External;

        PublicIncludePaths.Add(ThirdPartyIncludesDirectory);

        RuntimeDependencies.Add(PluginModelDirectory, StagedFileType.NonUFS);

        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyLibrariesDirectory, "pocketsphinx.lib"));
            PublicDelayLoadDLLs.Add("pocketsphinx.dll");
            RuntimeDependencies.Add(Path.Combine(PluginBinariesDirectory, "pocketsphinx.dll"), Path.Combine(ThirdPartyLibrariesDirectory, "pocketsphinx.dll"));
        }
        else if (Target.Platform == UnrealTargetPlatform.Linux)
        {
            PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyLibrariesDirectory, "libpocketsphinx.so"));
            PublicDelayLoadDLLs.Add("libpocketsphinx.so");
            RuntimeDependencies.Add(Path.Combine(PluginBinariesDirectory, "libpocketsphinx.so"), Path.Combine(ThirdPartyLibrariesDirectory, "libpocketsphinx.so"));
        }
        else if (Target.Platform == UnrealTargetPlatform.Mac)
        {
            PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyLibrariesDirectory, "libpocketsphinx.dylib"));
            PublicDelayLoadDLLs.Add(Path.Combine(ThirdPartyLibrariesDirectory, "libpocketsphinx.dylib"));
            RuntimeDependencies.Add(Path.Combine(PluginBinariesDirectory, "libpocketsphinx.dylib"), Path.Combine(ThirdPartyLibrariesDirectory, "libpocketsphinx.dylib"));
        }
    }
}
