put 'native' section in to runtime targets for deps file
This commit is contained in:
parent
dc11ed2ba8
commit
008a1ad0fa
7 changed files with 38 additions and 8 deletions
|
@ -129,6 +129,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
export.Library.Identity.Version.ToString(),
|
||||
export.Library.Hash,
|
||||
assemblies.Select(RuntimeAssembly.Create),
|
||||
export.NativeLibraries.Select(l => l.RelativePath),
|
||||
export.ResourceAssemblies.Select(CreateResourceAssembly),
|
||||
export.RuntimeTargets.Select(CreateRuntimeTarget),
|
||||
libraryDependencies,
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
version: identity.Item3,
|
||||
hash: identity.Item4,
|
||||
assemblies: packageGroup.Select(l => RuntimeAssembly.Create(l.AssetPath)),
|
||||
nativeLibraries: Enumerable.Empty<string>(),
|
||||
resourceAssemblies: Enumerable.Empty<ResourceAssembly>(),
|
||||
subTargets: Enumerable.Empty<RuntimeTarget>(),
|
||||
dependencies: Enumerable.Empty<Dependency>(),
|
||||
|
|
|
@ -169,10 +169,12 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
));
|
||||
}
|
||||
|
||||
var assemblies = ReadAssemblies(libraryObject, DependencyContextStrings.RuntimeAssembliesKey)
|
||||
var assemblies = ReadAssetList(libraryObject, DependencyContextStrings.RuntimeAssembliesKey)
|
||||
.Select(RuntimeAssembly.Create)
|
||||
.ToArray();
|
||||
|
||||
var nativeLibraries = ReadAssetList(libraryObject, DependencyContextStrings.NativeLibrariesKey);
|
||||
|
||||
var resourceAssemblies = ReadResourceAssemblies((JObject)libraryObject[DependencyContextStrings.ResourceAssembliesPropertyName]);
|
||||
|
||||
return new RuntimeLibrary(
|
||||
|
@ -181,6 +183,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
version: version,
|
||||
hash: stub.Hash,
|
||||
assemblies: assemblies,
|
||||
nativeLibraries: nativeLibraries,
|
||||
resourceAssemblies: resourceAssemblies,
|
||||
subTargets: runtimeTargets.ToArray(),
|
||||
dependencies: dependencies,
|
||||
|
@ -188,7 +191,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
else
|
||||
{
|
||||
var assemblies = ReadAssemblies(libraryObject, DependencyContextStrings.CompileTimeAssembliesKey);
|
||||
var assemblies = ReadAssetList(libraryObject, DependencyContextStrings.CompileTimeAssembliesKey);
|
||||
return new CompilationLibrary(stub.Type, name, version, stub.Hash, assemblies, dependencies, stub.Serviceable);
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +229,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
}
|
||||
|
||||
private static string[] ReadAssemblies(JObject libraryObject, string name)
|
||||
private static string[] ReadAssetList(JObject libraryObject, string name)
|
||||
{
|
||||
var assembliesObject = (JObject) libraryObject[name];
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
internal const string RuntimeAssembliesKey = "runtime";
|
||||
|
||||
internal const string NativeLibrariesKey = "native";
|
||||
|
||||
internal const string RuntimeTargetPropertyName = "runtimeTarget";
|
||||
|
||||
internal const string LibrariesPropertyName = "libraries";
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
return;
|
||||
}
|
||||
libraryObject.Add(new JProperty(DependencyContextStrings.CompileTimeAssembliesKey,
|
||||
WriteAssemblies(compilationAssemblies))
|
||||
WriteAssetList(compilationAssemblies))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
return;
|
||||
}
|
||||
libraryObject.Add(new JProperty(DependencyContextStrings.RuntimeAssembliesKey,
|
||||
WriteAssemblies(runtimeAssemblies.Select(a => a.Path)))
|
||||
WriteAssetList(runtimeAssemblies.Select(a => a.Path)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -197,6 +197,12 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
AddDependencies(libraryObject, runtimeLibrary.Dependencies);
|
||||
AddRuntimeAssemblies(libraryObject, runtimeLibrary.Assemblies);
|
||||
AddResourceAssemblies(libraryObject, runtimeLibrary.ResourceAssemblies);
|
||||
|
||||
if (runtimeLibrary.NativeLibraries.Any())
|
||||
{
|
||||
libraryObject.Add(DependencyContextStrings.NativeLibrariesKey, WriteAssetList(runtimeLibrary.NativeLibraries));
|
||||
}
|
||||
|
||||
return libraryObject;
|
||||
}
|
||||
|
||||
|
@ -213,7 +219,6 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
|
||||
private JObject WritePortableTargetLibrary(RuntimeLibrary runtimeLibrary, CompilationLibrary compilationLibrary)
|
||||
{
|
||||
|
||||
var libraryObject = new JObject();
|
||||
|
||||
var dependencies = new HashSet<Dependency>();
|
||||
|
@ -229,6 +234,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
AddResourceAssemblies(libraryObject, runtimeLibrary.ResourceAssemblies);
|
||||
AddRuntimeAssemblies(libraryObject, runtimeLibrary.Assemblies);
|
||||
libraryObject.Add(DependencyContextStrings.NativeLibrariesKey, WriteAssetList(runtimeLibrary.NativeLibraries));
|
||||
|
||||
dependencies.UnionWith(runtimeLibrary.Dependencies);
|
||||
}
|
||||
|
@ -272,9 +278,9 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
}
|
||||
}
|
||||
|
||||
private JObject WriteAssemblies(IEnumerable<string> assemblies)
|
||||
private JObject WriteAssetList(IEnumerable<string> assetPaths)
|
||||
{
|
||||
return new JObject(assemblies.Select(assembly => new JProperty(NormalizePath(assembly), new JObject())));
|
||||
return new JObject(assetPaths.Select(assembly => new JProperty(NormalizePath(assembly), new JObject())));
|
||||
}
|
||||
|
||||
private JObject WriteLibraries(DependencyContext context)
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
string version,
|
||||
string hash,
|
||||
IEnumerable<RuntimeAssembly> assemblies,
|
||||
IEnumerable<string> nativeLibraries,
|
||||
IEnumerable<ResourceAssembly> resourceAssemblies,
|
||||
IEnumerable<RuntimeTarget> subTargets,
|
||||
IEnumerable<Dependency> dependencies,
|
||||
|
@ -23,9 +24,12 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
Assemblies = assemblies.ToArray();
|
||||
ResourceAssemblies = resourceAssemblies.ToArray();
|
||||
RuntimeTargets = subTargets.ToArray();
|
||||
NativeLibraries = nativeLibraries.ToArray();
|
||||
}
|
||||
|
||||
public IReadOnlyList<RuntimeAssembly> Assemblies { get; }
|
||||
|
||||
public IReadOnlyList<string> NativeLibraries { get; }
|
||||
|
||||
public IReadOnlyList<ResourceAssembly> ResourceAssemblies { get; }
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new [] { RuntimeAssembly.Create("Banana.dll")},
|
||||
new [] { "runtimes\\linux\\native\\native.so" },
|
||||
new [] { new ResourceAssembly("en-US\\Banana.Resource.dll", "en-US")},
|
||||
new []
|
||||
{
|
||||
|
@ -172,8 +173,11 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
|
||||
var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;
|
||||
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
|
||||
|
||||
library.Should().HavePropertyAsObject("runtime")
|
||||
.Subject.Should().HaveProperty("Banana.dll");
|
||||
library.Should().HavePropertyAsObject("native")
|
||||
.Subject.Should().HaveProperty("runtimes/linux/native/native.so");
|
||||
|
||||
var runtimeTargets = library.Should().HavePropertyAsObject("runtimeTargets").Subject;
|
||||
|
||||
|
@ -226,6 +230,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new [] { RuntimeAssembly.Create("Banana.dll")},
|
||||
new [] { "native.dll" },
|
||||
new ResourceAssembly[] {},
|
||||
new []
|
||||
{
|
||||
|
@ -247,8 +252,11 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
|
||||
var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;
|
||||
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
|
||||
|
||||
library.Should().HavePropertyAsObject("runtime")
|
||||
.Subject.Should().HaveProperty("Banana.dll");
|
||||
library.Should().HavePropertyAsObject("native")
|
||||
.Subject.Should().HaveProperty("native.dll");
|
||||
|
||||
library.Should().HavePropertyAsObject("compile")
|
||||
.Subject.Should().HaveProperty("ref/Banana.dll");
|
||||
|
@ -286,6 +294,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new [] { RuntimeAssembly.Create("Banana.dll")},
|
||||
new [] { "runtimes\\osx\\native\\native.dylib" },
|
||||
new ResourceAssembly[] {},
|
||||
new RuntimeTarget[] {},
|
||||
new [] {
|
||||
|
@ -303,6 +312,8 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
|
||||
library.Should().HavePropertyAsObject("runtime")
|
||||
.Subject.Should().HaveProperty("Banana.dll");
|
||||
library.Should().HavePropertyAsObject("native")
|
||||
.Subject.Should().HaveProperty("runtimes/osx/native/native.dylib");
|
||||
|
||||
//libraries
|
||||
var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
|
||||
|
@ -327,6 +338,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new RuntimeAssembly[] { },
|
||||
new string[] { },
|
||||
new []
|
||||
{
|
||||
new ResourceAssembly("en-US/Fruits.resources.dll", "en-US")
|
||||
|
@ -361,6 +373,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
"1.2.3",
|
||||
"HASH",
|
||||
new RuntimeAssembly[] { },
|
||||
new string[] { },
|
||||
new []
|
||||
{
|
||||
new ResourceAssembly("en-US/Fruits.resources.dll", "en-US")
|
||||
|
|
Loading…
Reference in a new issue