228 lines
7.9 KiB
C#
228 lines
7.9 KiB
C#
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2023 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;
|
|
|
|
PublicDependencyModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"Core",
|
|
}
|
|
);
|
|
|
|
PrivateDependencyModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"SenseGloveInterop",
|
|
"SenseGloveLog",
|
|
"SenseGloveTypes",
|
|
"SenseGloveUtils",
|
|
}
|
|
);
|
|
|
|
PrivateIncludePathModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"SenseGloveBuildHacks",
|
|
}
|
|
);
|
|
|
|
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 LibraryName = "sgcore";
|
|
|
|
if (Target.Platform == UnrealTargetPlatform.Android)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "android"));
|
|
|
|
#if UE_5_1_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r25b"));
|
|
#elif UE_5_0_OR_LATER
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r21e"));
|
|
#else
|
|
Debug.Assert(false, "Developing for Android on UE versions older than 5.0 is not supported!");
|
|
#endif
|
|
|
|
#if UE_5_2_OR_LATER
|
|
if (Target.Architecture == UnrealArch.Arm64)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "arm64"));
|
|
}
|
|
else if (Target.Architecture == UnrealArch.X64)
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x64"));
|
|
}
|
|
else
|
|
{
|
|
Debug.Assert(false, "Unsupported Android architecture!");
|
|
}
|
|
#else
|
|
IAndroidToolChain ToolChain = AndroidExports.CreateToolChain(Target.ProjectFile);
|
|
List<string> Architectures = ToolChain.GetAllArchitectures();
|
|
|
|
foreach (string Arch in Architectures)
|
|
{
|
|
if (Arch == "-arm64")
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "arm64"));
|
|
break;
|
|
}
|
|
else if (Arch == "-armv7")
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "armv7"));
|
|
break;
|
|
}
|
|
else if (Arch == "-x64")
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x64"));
|
|
break;
|
|
}
|
|
else if (Arch == "-86")
|
|
{
|
|
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86"));
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
Debug.Assert(false, "Unsupported Android architecture!");
|
|
break;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
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;
|
|
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!");
|
|
}
|
|
|
|
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);
|
|
}
|
|
} |