This repository has been archived by the owner on Dec 18, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling loading native libs from project references CoreClr
- Loading branch information
moozzyk
committed
Oct 25, 2015
1 parent
b9f0af9
commit cba17e0
Showing
4 changed files
with
118 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Microsoft.Dnx.Runtime | ||
{ | ||
internal class NativeLibPathUtils | ||
{ | ||
public static IEnumerable<string> GetNativeSubfolderCandidates(IRuntimeEnvironment runtimeEnvironment) | ||
{ | ||
if (runtimeEnvironment.OperatingSystem == RuntimeOperatingSystems.Windows) | ||
{ | ||
return PlatformServices.Default.Runtime.GetAllRuntimeIdentifiers(); | ||
} | ||
|
||
var runtimeId = PlatformServices.Default.Runtime.GetRuntimeOsName(); | ||
|
||
return new[] | ||
{ | ||
runtimeId, | ||
runtimeId.Split('-')[0], | ||
runtimeId.Split('.')[0] | ||
}; | ||
} | ||
|
||
public static string GetProjectNativeLibPath(string projectPath, string nativeSubfolder) | ||
{ | ||
return Path.Combine(projectPath, "runtimes", nativeSubfolder, "native"); | ||
} | ||
|
||
public static bool IsMatchingNativeLibrary(IRuntimeEnvironment runtimeEnvironment, string requestedFile, string actualFile) | ||
{ | ||
if (string.Equals(requestedFile, actualFile, StringComparison.Ordinal)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (runtimeEnvironment.OperatingSystem == RuntimeOperatingSystems.Windows) | ||
{ | ||
return string.Equals(requestedFile, actualFile, StringComparison.OrdinalIgnoreCase) || | ||
string.Equals(requestedFile + ".dll", actualFile, StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
if (runtimeEnvironment.OperatingSystem == RuntimeOperatingSystems.Linux) | ||
{ | ||
return string.Equals(requestedFile + ".so", actualFile, StringComparison.Ordinal); | ||
} | ||
|
||
return string.Equals(requestedFile + ".dylib", actualFile, StringComparison.Ordinal); | ||
} | ||
|
||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test/Microsoft.Dnx.Runtime.Tests/NativeLibPathUitlsFacts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
|
||
using Xunit; | ||
|
||
namespace Microsoft.Dnx.Runtime.Tests | ||
{ | ||
public class NativeLibPathUitlsFacts | ||
{ | ||
[Fact] | ||
public void test() | ||
{ | ||
|
||
} | ||
} | ||
} |