265 lines
9.8 KiB
C#
265 lines
9.8 KiB
C#
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2022 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 SenseGloveConnectImpl : ModuleRules
|
|
{
|
|
public SenseGloveConnectImpl(ReadOnlyTargetRules Target) : base(Target)
|
|
{
|
|
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
|
|
|
bEnableExceptions = true;
|
|
bUseRTTI = true;
|
|
|
|
PublicDependencyModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"Core",
|
|
}
|
|
);
|
|
|
|
PrivateDependencyModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"SenseGloveBuildHacks",
|
|
"SenseGloveInterop",
|
|
"SenseGloveLog",
|
|
"SenseGloveTypes",
|
|
"SenseGloveUtils",
|
|
}
|
|
);
|
|
|
|
AddConnectLibrary(Target);
|
|
AddSerialLibrary(Target);
|
|
|
|
PublicDefinitions.Add("SENSEGLOVE_BUILDING_CONNECT_IMPL_MODULE");
|
|
PublicDefinitions.Add("SENSEGLOVE_UNREAL_ENGINE_PLUGIN");
|
|
}
|
|
|
|
private void AddConnectLibrary(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 LibraryName = "sgconnect";
|
|
|
|
if (Target.Platform == UnrealTargetPlatform.Android)
|
|
{
|
|
IAndroidToolChain ToolChain = AndroidExports.CreateToolChain(Target.ProjectFile);
|
|
List<string> Architectures = ToolChain.GetAllArchitectures();
|
|
foreach (string Arch in Architectures)
|
|
{
|
|
if (Arch != "-arm64")
|
|
{
|
|
Debug.Assert(false, "Only AArch64/ARM64 variant of Android is supported!");
|
|
}
|
|
}
|
|
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "oculus"));
|
|
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_0_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v20"));
|
|
#elif UE_4_27_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v19"));
|
|
#elif UE_4_26_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v17"));
|
|
#elif UE_4_25_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v16"));
|
|
#elif UE_4_24_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v15"));
|
|
#elif UE_4_23_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v15"));
|
|
#elif UE_4_22_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v13"));
|
|
#else
|
|
Debug.Assert(false, "Unsupported compiler!");
|
|
#endif
|
|
}
|
|
else if (Target.Platform == UnrealTargetPlatform.Win64)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "win64"));
|
|
switch (Target.WindowsPlatform.Compiler)
|
|
{
|
|
#if UE_4_27_OR_LATER
|
|
case WindowsCompiler.VisualStudio2022:
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc143"));
|
|
break;
|
|
#endif
|
|
#if UE_4_22_OR_LATER
|
|
case WindowsCompiler.VisualStudio2019:
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc142"));
|
|
break;
|
|
#endif
|
|
#if ! UE_5_0_OR_LATER && UE_4_17_OR_LATER
|
|
case WindowsCompiler.VisualStudio2017:
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc141"));
|
|
break;
|
|
#endif
|
|
default:
|
|
Debug.Assert(false, "Unsupported compiler!");
|
|
break;
|
|
}
|
|
|
|
LibraryName = string.Format("{0}.lib", LibraryName);
|
|
}
|
|
else
|
|
{
|
|
Debug.Assert(false, "Unsupported platform!");
|
|
}
|
|
|
|
bool bDebug = (Target.Configuration == UnrealTargetConfiguration.Debug);
|
|
if (bDebug)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
|
|
}
|
|
else
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
|
|
}
|
|
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
|
|
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
|
|
|
|
PrivateIncludePaths.Add(IncludePath);
|
|
PublicAdditionalLibraries.Add(LibraryPath);
|
|
}
|
|
|
|
private void AddSerialLibrary(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 LibraryName = "serial";
|
|
|
|
if (Target.Platform == UnrealTargetPlatform.Android)
|
|
{
|
|
IAndroidToolChain ToolChain = AndroidExports.CreateToolChain(Target.ProjectFile);
|
|
List<string> Architectures = ToolChain.GetAllArchitectures();
|
|
foreach (string Arch in Architectures)
|
|
{
|
|
if (Arch != "-arm64")
|
|
{
|
|
Debug.Assert(false, "Only AArch64/ARM64 variant of Android is supported!");
|
|
}
|
|
}
|
|
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "oculus"));
|
|
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_0_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v20"));
|
|
#elif UE_4_27_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v19"));
|
|
#elif UE_4_26_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v17"));
|
|
#elif UE_4_25_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v16"));
|
|
#elif UE_4_24_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v15"));
|
|
#elif UE_4_23_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v15"));
|
|
#elif UE_4_22_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v13"));
|
|
#else
|
|
Debug.Assert(false, "Unsupported compiler!");
|
|
#endif
|
|
}
|
|
else if (Target.Platform == UnrealTargetPlatform.Win64)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "win64"));
|
|
switch (Target.WindowsPlatform.Compiler)
|
|
{
|
|
#if UE_4_27_OR_LATER
|
|
case WindowsCompiler.VisualStudio2022:
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc143"));
|
|
break;
|
|
#endif
|
|
#if UE_4_22_OR_LATER
|
|
case WindowsCompiler.VisualStudio2019:
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc142"));
|
|
break;
|
|
#endif
|
|
#if ! UE_5_0_OR_LATER && UE_4_17_OR_LATER
|
|
case WindowsCompiler.VisualStudio2017:
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc141"));
|
|
break;
|
|
#endif
|
|
default:
|
|
Debug.Assert(false, "Unsupported compiler!");
|
|
break;
|
|
}
|
|
|
|
LibraryName = string.Format("{0}.lib", LibraryName);
|
|
}
|
|
else
|
|
{
|
|
Debug.Assert(false, "Unsupported platform!");
|
|
}
|
|
|
|
bool bDebug = (Target.Configuration == UnrealTargetConfiguration.Debug);
|
|
if (bDebug)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
|
|
}
|
|
else
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
|
|
}
|
|
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
|
|
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
|
|
|
|
PrivateIncludePaths.Add(IncludePath);
|
|
PublicAdditionalLibraries.Add(LibraryPath);
|
|
}
|
|
} |