Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Support for using Mono / .NET Core from default install paths
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltris committed Jun 10, 2019
1 parent c00d9cc commit 8c2b514
Show file tree
Hide file tree
Showing 3 changed files with 437 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<AssemblyName>UnrealEngine.Runtime</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -21,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
Expand All @@ -32,6 +34,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
20 changes: 19 additions & 1 deletion Source/USharp/Private/CSharpLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CSharpLoader.h"
#include "USharpPCH.h"
#include "ExportedFunctions/ExportedFunctions.h"
#include "DotNetRuntimeFinder.h"

#if PLATFORM_LINUX
#include <signal.h>
Expand Down Expand Up @@ -271,9 +272,19 @@ void CSharpLoader::SetupPaths()

// Mono should be under "/Binaries/Managed/Runtimes/Mono/[PLATFORM]/bin/"
monoLibPaths.Add(FPaths::Combine(*ManagedBinDir, TEXT("Runtimes"), TEXT("Mono"), *GetPlatformString(), TEXT("bin")));

FString MonoInstallPath = FindMonoInstallPath();
if (!MonoInstallPath.IsEmpty() && FPaths::DirectoryExists(MonoInstallPath))
{
monoLibPaths.Add(MonoInstallPath);
}

// CoreCLR should be under "/Binaries/Managed/Runtimes/CoreCLR/[PLATFORM]/"
coreCLRLibPaths.Add(FPaths::Combine(*ManagedBinDir, TEXT("Runtimes"), TEXT("CoreCLR"), *GetPlatformString()));
FString CoreCLRInstallPath = FindCoreCLRInstallPath();
if (!CoreCLRInstallPath.IsEmpty() && FPaths::DirectoryExists(CoreCLRInstallPath))
{
coreCLRLibPaths.Add(CoreCLRInstallPath);
}
}

FString CSharpLoader::GetPlatformString()
Expand Down Expand Up @@ -525,6 +536,13 @@ bool CSharpLoader::LoadRuntimeMono()

FString assemblyDir = FPaths::Combine(*monoDirectory, TEXT(".."), TEXT("lib"));
FString configDir = FPaths::Combine(*monoDirectory, TEXT(".."), TEXT("etc"));
#if PLATFORM_LINUX
// If this is from the install path then etc will be under the root /etc/ directory
if (!FPaths::FileExists(FPaths::Combine(*configDir, TEXT("mono"), TEXT("config"))))
{
configDir = FPaths::Combine(*monoDirectory, TEXT(".."), TEXT(".."), TEXT("etc"));
}
#endif
mono_set_dirs(TCHAR_TO_ANSI(*assemblyDir), TCHAR_TO_ANSI(*configDir));
#if UE_BUILD_DEBUG || UE_BUILD_DEVELOPMENT
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
Expand Down
Loading

0 comments on commit 8c2b514

Please sign in to comment.