Skip to content

Commit

Permalink
fixes to compile CoreFX projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex D committed Jul 25, 2017
1 parent c678b66 commit 7c6f292
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions Il2Native.Logic/Cs2CGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private void AddAsseblyReference(List<MetadataImageReference> assemblies, HashSe
var resolvedFilePath = this.ResolveAssemblyReferense(assemblyIdentity);
if (resolvedFilePath == null)
{
Console.WriteLine("Error: Can't resolve reference: " + assemblyIdentity);
return;
}

Expand Down
16 changes: 8 additions & 8 deletions Il2Native.Logic/Project/ProjectLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void BuildWellKnownValues(string name, string filePath)

private bool ProcessElement(XElement element)
{
if (!ProjectCondition(element))
if (!CheckCondition(element))
{
return true;
}
Expand Down Expand Up @@ -511,15 +511,15 @@ private bool LoadImport(XElement element)

private void LoadPropertyGroup(XElement element)
{
foreach (var property in element.Elements().Where(i => ProjectCondition(i)))
foreach (var property in element.Elements().Where(i => CheckCondition(i)))
{
this.Options[property.Name.LocalName] = this.FillProperties(property.Value);
}
}

private void LoadItemGroup(XElement element)
{
foreach (var item in element.Elements().Where(i => ProjectCondition(i)))
foreach (var item in element.Elements().Where(i => CheckCondition(i)))
{
switch (item.Name.LocalName)
{
Expand Down Expand Up @@ -803,7 +803,7 @@ private bool ProcessChoose(XElement element)
{
var result = true;
var any = false;
foreach (var item in element.Elements(ns + "When").Where(i => ProjectCondition(i)))
foreach (var item in element.Elements(ns + "When").Where(i => CheckCondition(i)))
{
any = true;
foreach (var subItem in item.Elements())
Expand Down Expand Up @@ -831,7 +831,7 @@ private string[] LoadReferencesFromProject(string firstSource, XDocument project
var xElement = project.Root;
if (xElement != null)
{
return xElement.Elements(ns + "ItemGroup").Elements(ns + "Reference")
return xElement.Elements(ns + "ItemGroup").Where(i => CheckCondition(i)).Elements(ns + "Reference")
.Select(e => GetReferenceValue(e))
.Union(this.LoadReferencesFromProjectReferences(firstSource, xElement)).ToArray();
}
Expand All @@ -844,7 +844,7 @@ private string[] LoadReferencesFromRuntime(string firstSource, XDocument project
var xElement = project.Root;
if (xElement != null)
{
return xElement.Elements(ns + "ItemGroup").Elements(ns + "ReferenceFromRuntime")
return xElement.Elements(ns + "ItemGroup").Where(i => CheckCondition(i)).Elements(ns + "ReferenceFromRuntime")
.Select(e => GetReferenceValue(e)).ToArray();
}

Expand Down Expand Up @@ -873,7 +873,7 @@ private string PathCombine(string possibleFilePath)
return possibleFilePath;
}

private bool ProjectCondition(XElement element)
private bool CheckCondition(XElement element)
{
var conditionAttribute = element.Attribute("Condition");
if (conditionAttribute == null)
Expand Down Expand Up @@ -1409,7 +1409,7 @@ private IEnumerable<string> LoadProjectReferencesFromProject(string prjectFullFi
var projectRoot = project.Root;
if (projectRoot != null)
{
foreach (var projectReference in projectRoot.Elements(ns + "ItemGroup").Elements(ns + "ProjectReference"))
foreach (var projectReference in projectRoot.Elements(ns + "ItemGroup").Where(i => CheckCondition(i)).Elements(ns + "ProjectReference"))
{
var projectFile = this.GetRealFolderFromProject(prjectFullFilePath, projectReference);
foreach (var subProjectFile in this.LoadProjectReferencesFromProject(projectFile, XDocument.Load(projectFile)))
Expand Down
2 changes: 1 addition & 1 deletion Il2Native/Il2Native.CmdLine.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>/release C:\Dev\Gits\corefx\src\System.Collections\src\System.Collections.csproj /p:Configuration=netstandard2.0-Windows_NT-Release</StartArguments>
<StartArguments>/release C:\Dev\Gits\corefx\src\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj /p:Configuration=netstandard2.0-Windows_NT-Release</StartArguments>
<StartWorkingDirectory>C:\Temp\cs2cpp_tries\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,20 @@ Then your targeted library
cd System_Private_Uri
build_vs2017_release.bat
```

How to compile CoreFX Console project
-----------

1) Generating source code for each reference

Cs2Cpp.exe /release C:\Dev\Gits\coreclr\src\mscorlib\System.Private.CoreLib.csproj
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Collections\src\System.Collections.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Diagnostics.Contracts\src\System.Diagnostics.Contracts.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Diagnostics.Tools\src\System.Diagnostics.Tools.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Resources.ResourceManager\src\System.Resources.ResourceManager.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Runtime.InteropServices\src\System.Runtime.InteropServices.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Text.Encoding.Extensions\src\System.Text.Encoding.Extensions.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Threading\src\System.Threading.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Threading.Tasks\src\System.Threading.Tasks.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release C:\Dev\Gits\corefx\src\System.Console\src\System.Console.csproj /p:Configuration=netstandard2.0-Windows_NT-Release /corelib:System.Private.CoreLib.dll

0 comments on commit 7c6f292

Please sign in to comment.