Files
Plugin/Source/SenseGloveCoreImpl/SenseGloveCoreImpl.Build.cs
T

200 lines
7.3 KiB
C#

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2024 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnrealBuildTool;
public class SenseGloveCoreImpl : ModuleRules
{
public SenseGloveCoreImpl(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
bEnableExceptions = true;
bUseRTTI = true;
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"SenseGloveLog",
"SenseGloveUtils",
"SenseGloveTypes",
}
);
PrivateIncludePathModuleNames.AddRange(
new string[]
{
"SenseGloveBuildHacks",
"SenseGloveInterop",
}
);
AddCoreLibrary(Target);
PublicDefinitions.Add("SENSEGLOVE_BUILDING_CORE_IMPL_MODULE");
PublicDefinitions.Add("SENSEGLOVE_UNREAL_ENGINE_PLUGIN");
}
private void AddCoreLibrary(ReadOnlyTargetRules Target)
{
string PluginRootDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
string SourceDirectory = Path.GetFullPath(Path.Combine(PluginRootDirectory, "Source"));
string ThirdPartyDirectory = Path.GetFullPath(Path.Combine(SourceDirectory, "ThirdParty"));
string LibraryPath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "lib"));
string LibraryPathAnroidArm64 = "";
string LibraryPathAnroidx64 = "";
string LibraryName = "sgcore";
if (Target.Platform == UnrealTargetPlatform.Android)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "android"));
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r25b"));
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPath, "arm64"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPath, "x64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (Target.Platform == UnrealTargetPlatform.Linux)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#elif UE_5_0_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v20"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
}
#if UE_5_0_OR_LATER
else if (Target.Platform == UnrealTargetPlatform.LinuxArm64)
#else
else if (Target.Platform == UnrealTargetPlatform.LinuxAArch64)
#endif
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#elif UE_5_0_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v20"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "aarch64"));
}
else if (Target.Platform == UnrealTargetPlatform.Win64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "win64"));
switch (Target.WindowsPlatform.Compiler)
{
#if UE_5_0_OR_LATER
case WindowsCompiler.VisualStudio2022:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc143"));
break;
#endif
#if ! UE_5_4_OR_LATER && UE_5_0_OR_LATER
case WindowsCompiler.VisualStudio2019:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc142"));
break;
#endif
default:
Debug.Assert(false, "Unsupported engine version or compiler!");
break;
}
LibraryName = string.Format("{0}.lib", LibraryName);
}
else
{
Debug.Assert(false, "Unsupported platform!");
}
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
PrivateIncludePaths.Add(IncludePath);
bool bDebug = (Target.Configuration == UnrealTargetConfiguration.Debug);
if (Target.Platform == UnrealTargetPlatform.Android)
{
if (bDebug)
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "debug"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "debug"));
}
else
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "release"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "release"));
}
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, LibraryName));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, LibraryName));
PublicAdditionalLibraries.Add(LibraryPathAnroidArm64);
PublicAdditionalLibraries.Add(LibraryPathAnroidx64);
}
else
{
if (bDebug)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
}
else
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
}
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
PublicAdditionalLibraries.Add(LibraryPath);
}
}
}