Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit346a55b

Browse files
committed
Merge pull requestfsharp#80 from funnelweb/master
Fixfsharp#69 (remaining uses of #if MONO)
2 parents6cf719f +c60fda2 commit346a55b

File tree

6 files changed

+50
-16
lines changed

6 files changed

+50
-16
lines changed

‎src/FSharpSource.targets‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
<ConfigurationOutputDirectory>proto</ConfigurationOutputDirectory>
7474
</PropertyGroup>
7575

76-
<!-- For now define 'MONO', even when building using msbuild on Windows, see https://github.com/fsharp/fsharp/issues/69-->
76+
<!-- For now define 'CROSS_PLATFORM_COMPILER', even when building using msbuild on Windows, see https://github.com/fsharp/fsharp/issues/69-->
7777
<PropertyGroup>
78-
<DefineConstants>MONO;$(DefineConstants)</DefineConstants>
78+
<DefineConstants>CROSS_PLATFORM_COMPILER;$(DefineConstants)</DefineConstants>
7979
</PropertyGroup>
8080

8181
<!-- v2.0-specific flags-->

‎src/absil/ilsupp.fs‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,23 +1159,35 @@ type PdbSequencePoint =
11591159
pdbSeqPointEndColumn:int;}
11601160

11611161
letpdbReadOpen(moduleName:string)(path:string):PdbReader=
1162-
#ifMONO
1163-
{ symReader=null}
1164-
#else
1162+
ifIL.runningOnMonothen
1163+
{ symReader=null}
1164+
else
11651165
letCorMetaDataDispenser= System.Type.GetTypeFromProgID("CLRMetaData.CorMetaDataDispenser")
11661166
let mutableIID_IMetaDataImport=new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44");
11671167
letmdd= System.Activator.CreateInstance(CorMetaDataDispenser):?> IMetaDataDispenser
11681168
let mutableo:Object=new Object()
11691169
mdd.OpenScope(moduleName,0,&IID_IMetaDataImport,&o);
11701170
letimporterPtr= Marshal.GetComInterfaceForObject(o, typeof<IMetadataImport>)
11711171
try
1172-
letsymbolBinder= System.Diagnostics.SymbolStore.SymBinder()
1173-
{ symReader= symbolBinder.GetReader(importerPtr, moduleName, path)}
1172+
#if CROSS_PLATFORM_COMPILER
1173+
// ISymWrapper.dll is not available as a compile-time dependency for the cross-platform compiler, since it is Windows-only
1174+
// Access it via reflection instead.System.Diagnostics.SymbolStore.SymBinder
1175+
try
1176+
letisym= System.Reflection.Assembly.Load("ISymWrapper, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
1177+
letsymbolBinder= isym.CreateInstance("System.Diagnostics.SymbolStore.SymBinder")
1178+
letsymbolBinderTy= symbolBinder.GetType()
1179+
letreader= symbolBinderTy.InvokeMember("GetReader",BindingFlags.Public||| BindingFlags.InvokeMethod||| BindingFlags.Instance,null,symbolBinder,[| box importerPtr; box moduleName; box path|])
1180+
{ symReader= reader:?> ISymbolReader}
1181+
with_->
1182+
{ symReader=null}
1183+
#else
1184+
letsymbolBinder= System.Diagnostics.SymbolStore.SymBinder()
1185+
{ symReader= symbolBinder.GetReader(importerPtr, moduleName, path)}
1186+
#endif
11741187
finally
11751188
// Marshal.GetComInterfaceForObject adds an extra ref for importerPtr
11761189
if IntPtr.Zero<> importerPtrthen
11771190
Marshal.Release(importerPtr)|> ignore
1178-
#endif
11791191

11801192
// Note, the symbol reader's finalize method will clean up any unmanaged resources.
11811193
// If file locks persist, we may want to manually invoke finalize

‎src/fsharp/FSharp.Build/Fsc.fs‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
158158
let mutablecapturedArguments:string list=[]// list of individual args, to pass to HostObject Compile()
159159
let mutablecapturedFilenames:string list=[]// list of individual source filenames, to pass to HostObject Compile()
160160

161-
#if MONO
161+
162+
#if CROSS_PLATFORM_COMPILER
163+
// The properties TargetedRuntimeVersion and CopyLocalDependenciesWhenParentReferenceInGac
164+
// are not available to the cross-platform compiler since they are Windows only (not defined in the Mono
165+
// 4.0 XBuild support). So we only set them if available (to avoid a compile-time dependency).
166+
letrunningOnMono=try System.Type.GetType("Mono.Runtime")<>nullwith e->false
167+
doifnot runningOnMonothen
168+
typeof<ToolTask>.InvokeMember("YieldDuringToolExecution",(BindingFlags.Instance||| BindingFlags.SetProperty||| BindingFlags.Public),null,this,[| boxtrue|])|> ignore
162169
#else
163170
do
164171
this.YieldDuringToolExecution<-true// See bug 6483; this makes parallel build faster, and is fine to set unconditionally
@@ -365,12 +372,17 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
365372
System.Globalization.CultureInfo.InvariantCulture)
366373
unbox ret
367374
with
368-
#if MONO
375+
376+
#if CROSS_PLATFORM_COMPILER
377+
// The type "Microsoft.Build.Exceptions.BuildAbortedException is not available to
378+
// the cross-platform compiler since it is Windows only (not defined in the Mono
379+
// 4.0 XBuild support). So we test for the type using a string comparison.
380+
|:? System.Reflection.TargetInvocationExceptionas tiewhen(match tie.InnerExceptionwith|null->false| xwhen x.GetType().Name="Microsoft.Build.Exceptions.BuildAbortedException"->true|_->false)->
369381
#else
370382
|:? System.Reflection.TargetInvocationExceptionas tiewhen(match tie.InnerExceptionwith|:? Microsoft.Build.Exceptions.BuildAbortedException->true|_->false)->
383+
#endif
371384
fsc.Log.LogError(tie.InnerException.Message,[||])
372385
-1// ok, this is what happens when VS IDE cancels the build, no need to assert, just log the build-canceled error and return -1 to denote task failed
373-
#endif
374386
| e->
375387
System.Diagnostics.Debug.Assert(false,"HostObject received by Fsc task did not have a Compile method or the compile method threw an exception."+(e.ToString()))
376388
reraise()

‎src/fsharp/FSharp.Core/prim-types.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4226,7 +4226,7 @@ namespace Microsoft.FSharp.Core
42264226

42274227
#if BE_SECURITY_TRANSPARENT
42284228
[<assembly: System.Security.SecurityTransparent>]// assembly is fully transparent
4229-
#ifMONO
4229+
#ifCROSS_PLATFORM_COMPILER
42304230
#else
42314231
[<assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level2)>]// v4 transparency; soon to be the default, but not yet
42324232
#endif

‎src/fsharp/ReferenceResolution.fs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespaceViz
1+
namespaceViz
22

33
/// This type exists to have a concrete 'Target' type for a DebuggerVisualizerAttribute.
44
/// Ideally it would be out in its own assembly, but then the compiler would need to take a dependency on that assembly, so instead we
@@ -29,6 +29,7 @@ module internal MSBuildResolver =
2929
#if SILVERLIGHT
3030
#else
3131
openSystem
32+
openSystem.Reflection
3233
openMicrosoft.Build.Tasks
3334
openMicrosoft.Build.Utilities
3435
openMicrosoft.Build.Framework
@@ -205,9 +206,17 @@ module internal MSBuildResolver =
205206
#if BUILDING_WITH_LKG
206207
ignore targetProcessorArchitecture
207208
#else
208-
#if MONO
209+
lettargetedRuntimeVersionValue= typeof<obj>.Assembly.ImageRuntimeVersion
210+
#if CROSS_PLATFORM_COMPILER
211+
// The properties TargetedRuntimeVersion and CopyLocalDependenciesWhenParentReferenceInGac
212+
// are not available to the cross-platform compiler since they are Windows only (not defined in the Mono
213+
// 4.0 XBuild support). So we only set them if available (to avoid a compile-time dependency).
214+
letrunningOnMono=try System.Type.GetType("Mono.Runtime")<>nullwith e->false
215+
ifnot runningOnMonothen
216+
typeof<ResolveAssemblyReference>.InvokeMember("TargetedRuntimeVersion",(BindingFlags.Instance||| BindingFlags.SetProperty||| BindingFlags.Public),null,rar,[| box targetedRuntimeVersionValue|])|> ignore
217+
typeof<ResolveAssemblyReference>.InvokeMember("CopyLocalDependenciesWhenParentReferenceInGac",(BindingFlags.Instance||| BindingFlags.SetProperty||| BindingFlags.Public),null,rar,[| boxtrue|])|> ignore
209218
#else
210-
rar.TargetedRuntimeVersion<-typeof<obj>.Assembly.ImageRuntimeVersion
219+
rar.TargetedRuntimeVersion<-targetedRuntimeVersionValue
211220
rar.CopyLocalDependenciesWhenParentReferenceInGac<-true
212221
#endif
213222
#endif

‎src/fsharp/fsi/fsi.fs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ type internal FsiCommandLineOptions(argv: string[], tcConfigB, fsiConsoleOutput:
438438
let mutableenableConsoleKeyProcessing=
439439
// Mono on Win32 doesn't implement correct console processing
440440
not(runningOnMono&& System.Environment.OSVersion.Platform= System.PlatformID.Win32NT)
441-
#if MONO
441+
// In the cross-platform edition of F#, 'gui' support is currently off by default
442+
#if CROSS_PLATFORM_COMPILER
442443
let mutablegui=false// override via "--gui", off by default
443444
#else
444445
let mutablegui=true// override via "--gui", on by default

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp