// Fill out your copyright notice in the Description page of Project Settings.

using System.IO;
using UnrealBuildTool;

public class PDB_viewer : ModuleRules
{
    private string ModulePath
    {
        get { return ModuleDirectory; }
    }

    private string ThirdPartyPath
    {
        get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty")); }
    }

    private const string LibDirectory = "Libraries";
    private const string IncDirectory = "Includes";

    public bool LoadProteinModelLibrary(TargetInfo Target)
    {
        bool isLibSupported = false;

        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            isLibSupported = true;
            string LibrariesPath = Path.Combine(ThirdPartyPath, "ProteinDataModel", LibDirectory);
            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "ProteinDataModel.lib"));
        }

        if (isLibSupported)
        {
            PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "ProteinDataModel", IncDirectory));
        }

        Definitions.Add(string.Format("WITH_PROTEIN_MODEL_BINDING={0}", isLibSupported ? 1 : 0));

        return isLibSupported;
    }

    public bool LoadPDBReader(TargetInfo Target)
    {
        bool isLibSupported = false;

        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            isLibSupported = true;
            string LibrariesPath = Path.Combine(ThirdPartyPath, "PDBReader", LibDirectory);
            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "PDBReader.lib"));
        }

        if (isLibSupported)
        {
            PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "PDBReader", IncDirectory));
        }

        Definitions.Add(string.Format("WITH_PDB_READER_BINDING={0}", isLibSupported ? 1 : 0));

        return isLibSupported;
    }

    public bool LoadBoost4PDBViewer(TargetInfo Target)
    {
        bool isLibSupported = false;

        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            isLibSupported = true;
            string LibrariesPath = Path.Combine(ThirdPartyPath, "Boost", LibDirectory);
            PublicAdditionalLibraries.AddRange(Directory.GetFiles(LibrariesPath));
        }

        if (isLibSupported)
        {
            PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "Boost", IncDirectory));
        }

        Definitions.Add(string.Format("WITH_BOOST_BINDING={0}", isLibSupported ? 1 : 0));

        bUseRTTI = true;

        return isLibSupported;
    }

    public PDB_viewer(TargetInfo Target)
    {
		UEBuildConfiguration.bForceEnableExceptions = true;
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

        PrivateDependencyModuleNames.AddRange(new string[] { });

        //PublicIncludePaths.AddRange(new string[] { Path.Combine(ThirdPartyPath, "Boost", IncDirectory) });

        // Uncomment if you are using Slate UI
        // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");

        // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true

        LoadProteinModelLibrary(Target);
        LoadPDBReader(Target);
        LoadBoost4PDBViewer(Target);

        MinFilesUsingPrecompiledHeaderOverride = 1;
        bFasterWithoutUnity = true;
    }
}
