提交 72bd2073 编写于 作者: J Jared Parsons

Merge pull request #2122 from jaredpar/cross-plat-alt

Cross Platform build issues
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
...@@ -47,6 +48,20 @@ private static Assembly ReflectionOnlyAssemblyResolveHandler(object sender, Reso ...@@ -47,6 +48,20 @@ private static Assembly ReflectionOnlyAssemblyResolveHandler(object sender, Reso
return null; return null;
} }
public static bool IsRunningOnMono()
{
return Type.GetType ("Mono.Runtime") != null;
}
public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid)
{
// This API isn't available on Mono hence we must use reflection to access it.
Debug.Assert(!IsRunningOnMono());
var getRuntimeInterfaceAsObject = typeof(RuntimeEnvironment).GetMethod("GetRuntimeInterfaceAsObject", BindingFlags.Public | BindingFlags.Static);
return getRuntimeInterfaceAsObject.Invoke(null, new object[] { clsid, riid });
}
/// <summary> /// <summary>
/// Verifies the specified image. Subscribe to <see cref="ReflectionOnlyAssemblyResolve"/> to provide a loader for dependent assemblies. /// Verifies the specified image. Subscribe to <see cref="ReflectionOnlyAssemblyResolve"/> to provide a loader for dependent assemblies.
/// </summary> /// </summary>
...@@ -68,6 +83,13 @@ public static string[] PeVerify(string filePath) ...@@ -68,6 +83,13 @@ public static string[] PeVerify(string filePath)
private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPath) private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPath)
{ {
if (IsRunningOnMono())
{
// PEverify is currently unsupported on Mono hence return an empty
// set of messages
return new string[] { };
}
lock (s_guard) lock (s_guard)
{ {
GCHandle pinned = GCHandle.Alloc(peImage, GCHandleType.Pinned); GCHandle pinned = GCHandle.Alloc(peImage, GCHandleType.Pinned);
...@@ -75,10 +97,10 @@ private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPa ...@@ -75,10 +97,10 @@ private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPa
{ {
IntPtr buffer = pinned.AddrOfPinnedObject(); IntPtr buffer = pinned.AddrOfPinnedObject();
ICLRValidator validator = (ICLRValidator)RuntimeEnvironment.GetRuntimeInterfaceAsObject(s_clsIdClrRuntimeHost, typeof(ICLRRuntimeHost).GUID); ICLRValidator validator = (ICLRValidator)GetRuntimeInterfaceAsObject(s_clsIdClrRuntimeHost, typeof(ICLRRuntimeHost).GUID);
ValidationErrorHandler errorHandler = new ValidationErrorHandler(validator); ValidationErrorHandler errorHandler = new ValidationErrorHandler(validator);
IMetaDataDispenser dispenser = (IMetaDataDispenser)RuntimeEnvironment.GetRuntimeInterfaceAsObject(s_clsIdCorMetaDataDispenser, typeof(IMetaDataDispenser).GUID); IMetaDataDispenser dispenser = (IMetaDataDispenser)GetRuntimeInterfaceAsObject(s_clsIdCorMetaDataDispenser, typeof(IMetaDataDispenser).GUID);
// the buffer needs to be pinned during validation // the buffer needs to be pinned during validation
Guid riid = typeof(IMetaDataImport).GUID; Guid riid = typeof(IMetaDataImport).GUID;
......
...@@ -106,9 +106,6 @@ ...@@ -106,9 +106,6 @@
<Reference Include="xunit"> <Reference Include="xunit">
<HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath> <HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ReachFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
...@@ -233,4 +230,4 @@ ...@@ -233,4 +230,4 @@
<Import Project="..\..\..\build\Roslyn.Toolsets.Xunit.targets" /> <Import Project="..\..\..\build\Roslyn.Toolsets.Xunit.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
$(CleanDependsOn) $(CleanDependsOn)
</CleanDependsOn> </CleanDependsOn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<MonoPrefix Condition="'$(OS)' != 'Windows_NT'">mono </MonoPrefix>
</PropertyGroup>
<Target <Target
Name="GenerateSyntaxModel" Name="GenerateSyntaxModel"
...@@ -40,14 +44,9 @@ ...@@ -40,14 +44,9 @@
Outputs="@(SyntaxDefinition -> '$(IntermediateOutputPath)%(Filename)%(Extension).Generated$(DefaultLanguageSourceExtension)')" Outputs="@(SyntaxDefinition -> '$(IntermediateOutputPath)%(Filename)%(Extension).Generated$(DefaultLanguageSourceExtension)')"
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'" Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
> >
<PropertyGroup Condition="'$(Language)' == 'VB'">
<SyntaxGenerator>"$(VBSyntaxGeneratorToolPath)"</SyntaxGenerator>
</PropertyGroup>
<PropertyGroup Condition="'$(Language)' == 'C#'">
<SyntaxGenerator Condition=" '$(OS)' == 'Windows_NT' ">"$(CSharpSyntaxGeneratorToolPath)"</SyntaxGenerator>
<SyntaxGenerator Condition=" '$(OS)' != 'Windows_NT' ">mono $(CSharpSyntaxGeneratorToolPath)</SyntaxGenerator>
</PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SyntaxGenerator Condition="'$(Language)' == 'VB'">$(MonoPrefix) "$(VBSyntaxGeneratorToolPath)"</SyntaxGenerator>
<SyntaxGenerator Condition="'$(Language)' == 'C#'">$(MonoPrefix) "$(CSharpSyntaxGeneratorToolPath)"</SyntaxGenerator>
<GeneratedSyntaxModel>@(SyntaxDefinition -> '$(IntermediateOutputPath)%(Filename)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedSyntaxModel> <GeneratedSyntaxModel>@(SyntaxDefinition -> '$(IntermediateOutputPath)%(Filename)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedSyntaxModel>
</PropertyGroup> </PropertyGroup>
...@@ -78,8 +77,6 @@ ...@@ -78,8 +77,6 @@
> >
<PropertyGroup> <PropertyGroup>
<SyntaxGenerator>"$(VBSyntaxGeneratorToolPath)"</SyntaxGenerator> <SyntaxGenerator>"$(VBSyntaxGeneratorToolPath)"</SyntaxGenerator>
</PropertyGroup>
<PropertyGroup>
<GeneratedSyntaxModelGetText>@(SyntaxGetTextDefinition -> '$(IntermediateOutputPath)\%(FileName)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedSyntaxModelGetText> <GeneratedSyntaxModelGetText>@(SyntaxGetTextDefinition -> '$(IntermediateOutputPath)\%(FileName)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedSyntaxModelGetText>
</PropertyGroup> </PropertyGroup>
...@@ -109,14 +106,9 @@ ...@@ -109,14 +106,9 @@
Outputs="@(SyntaxTestDefinition -> '$(IntermediateOutputPath)\%(FileName)%(Extension).Generated$(DefaultLanguageSourceExtension)')" Outputs="@(SyntaxTestDefinition -> '$(IntermediateOutputPath)\%(FileName)%(Extension).Generated$(DefaultLanguageSourceExtension)')"
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'" Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
> >
<PropertyGroup Condition="'$(Language)' == 'VB'">
<SyntaxGenerator>"$(VBSyntaxGeneratorToolPath)"</SyntaxGenerator>
</PropertyGroup>
<PropertyGroup Condition="'$(Language)' == 'C#'">
<SyntaxGenerator Condition=" '$(OS)' == 'Windows_NT' ">"$(CSharpSyntaxGeneratorToolPath)"</SyntaxGenerator>
<SyntaxGenerator Condition=" '$(OS)' != 'Windows_NT' ">mono $(CSharpSyntaxGeneratorToolPath)</SyntaxGenerator>
</PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SyntaxGenerator Condition="'$(Language)' == 'VB'">$(MonoPrefix) "$(VBSyntaxGeneratorToolPath)"</SyntaxGenerator>
<SyntaxGenerator Condition="'$(Language)' == 'C#'">$(MonoPrefix) "$(CSharpSyntaxGeneratorToolPath)"</SyntaxGenerator>
<GeneratedSyntaxModelTests>@(SyntaxTestDefinition -> '$(IntermediateOutputPath)\%(FileName)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedSyntaxModelTests> <GeneratedSyntaxModelTests>@(SyntaxTestDefinition -> '$(IntermediateOutputPath)\%(FileName)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedSyntaxModelTests>
</PropertyGroup> </PropertyGroup>
...@@ -147,8 +139,7 @@ ...@@ -147,8 +139,7 @@
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'" Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
> >
<PropertyGroup> <PropertyGroup>
<BoundTreeGenerator Condition=" '$(OS)' == 'Windows_NT' ">"$(BoundTreeGeneratorToolPath)"</BoundTreeGenerator> <BoundTreeGenerator>$(MonoPrefix) "$(BoundTreeGeneratorToolPath)"</BoundTreeGenerator>
<BoundTreeGenerator Condition=" '$(OS)' != 'Windows_NT' ">mono $(BoundTreeGeneratorToolPath)</BoundTreeGenerator>
<GeneratedBoundTree>@(BoundTreeDefinition -> '$(IntermediateOutputPath)%(Filename)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedBoundTree> <GeneratedBoundTree>@(BoundTreeDefinition -> '$(IntermediateOutputPath)%(Filename)%(Extension).Generated$(DefaultLanguageSourceExtension)')</GeneratedBoundTree>
</PropertyGroup> </PropertyGroup>
...@@ -183,16 +174,9 @@ ...@@ -183,16 +174,9 @@
Outputs="@(ErrorCode -> '$(IntermediateOutputPath)ErrorFacts.Generated$(DefaultLanguageSourceExtension)')" Outputs="@(ErrorCode -> '$(IntermediateOutputPath)ErrorFacts.Generated$(DefaultLanguageSourceExtension)')"
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'" Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
> >
<PropertyGroup Condition="'$(Language)' == 'VB'">
<ErrorFactsGenerator>"$(VBErrorFactsGeneratorToolPath)"</ErrorFactsGenerator>
</PropertyGroup>
<PropertyGroup Condition="'$(Language)' == 'C#'">
<ErrorFactsGenerator Condition=" '$(OS)' == 'Windows_NT' ">"$(CSharpErrorFactsGeneratorToolPath)"</ErrorFactsGenerator>
<ErrorFactsGenerator Condition=" '$(OS)' != 'Windows_NT' ">mono $(CSharpErrorFactsGeneratorToolPath)</ErrorFactsGenerator>
</PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ErrorFactsGenerator Condition="'$(Language)' == 'VB'">$(MonoPrefix) "$(VBErrorFactsGeneratorToolPath)"</ErrorFactsGenerator>
<ErrorFactsGenerator Condition="'$(Language)' == 'C#'">$(MonoPrefix) "$(CSharpErrorFactsGeneratorToolPath)"</ErrorFactsGenerator>
<GeneratedErrorFacts>@(ErrorCode -> '$(IntermediateOutputPath)ErrorFacts.Generated$(DefaultLanguageSourceExtension)')</GeneratedErrorFacts> <GeneratedErrorFacts>@(ErrorCode -> '$(IntermediateOutputPath)ErrorFacts.Generated$(DefaultLanguageSourceExtension)')</GeneratedErrorFacts>
</PropertyGroup> </PropertyGroup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册