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

Commit54305cc

Browse files
enricosadaKevinRansom
authored andcommitted
add more properties to Fsc msbuild task (dotnet#2523)
- SkipCompilerExecution to skip compilation (default false)- ProvideCommandLineArgs to populate output CommandLineArgs (default false)- CommandLineArgs (output) the list of fsc arguments
1 parentfc8e5af commit54305cc

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

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

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
161161
let mutablehighEntropyVA:bool=false
162162
let mutabletargetProfile:string=null
163163
let mutabledotnetFscCompilerPath:string=null
164+
let mutableskipCompilerExecution:bool=false
165+
let mutableprovideCommandLineArgs:bool=false
166+
let mutablecommandLineArgs:ITaskItem list=[]
164167

165168
let mutablecapturedArguments:string list=[]// list of individual args, to pass to HostObject Compile()
166169
let mutablecapturedFilenames:string list=[]// list of individual source filenames, to pass to HostObject Compile()
@@ -500,6 +503,19 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
500503
with get()= dotnetFscCompilerPath
501504
andset(p)= dotnetFscCompilerPath<- p
502505

506+
memberfsc.SkipCompilerExecution
507+
with get()= skipCompilerExecution
508+
andset(p)= skipCompilerExecution<- p
509+
510+
memberfsc.ProvideCommandLineArgs
511+
with get()= provideCommandLineArgs
512+
andset(p)= provideCommandLineArgs<- p
513+
514+
[<Output>]
515+
memberfsc.CommandLineArgs
516+
with get()= List.toArray commandLineArgs
517+
andset(p)= commandLineArgs<-(List.ofArray p)
518+
503519
// ToolTask methods
504520
overridefsc.ToolName="fsc.exe"
505521
overridefsc.StandardErrorEncoding=if utf8outputthen System.Text.Encoding.UTF8elsebase.StandardErrorEncoding
@@ -513,32 +529,41 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
513529

514530
/// Intercept the call to ExecuteTool to handle the host compile case.
515531
overridefsc.ExecuteTool(pathToTool,responseFileCommands,commandLineCommands)=
516-
lethost= box fsc.HostObject
517-
match hostwith
518-
|null->base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands)
519-
|_->
520-
letsources= sources|>Array.map(fun i->i.ItemSpec)
532+
if provideCommandLineArgsthen
533+
commandLineArgs<-
534+
fsc.GetCapturedArguments()
535+
|> Array.map(fun(arg: string)-> TaskItem(arg):> ITaskItem)
536+
|> Array.toList
537+
538+
if skipCompilerExecutionthen
539+
0
540+
else
541+
lethost= box fsc.HostObject
542+
match hostwith
543+
|null->base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands)
544+
|_->
545+
letsources= sources|>Array.map(fun i->i.ItemSpec)
521546
#if FX_NO_CONVERTER
522-
letbaseCallDelegate=new Func<int>(fun()-> fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands))
547+
letbaseCallDelegate=new Func<int>(fun()-> fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands))
523548
#else
524-
letbaseCall=fun(dummy: int)-> fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands)
525-
// We are using a Converter<int,int> rather than a "unit->int" because it is too hard to
526-
// figure out how to pass an F# function object via reflection.
527-
letbaseCallDelegate=new System.Converter<int,int>(baseCall)
549+
letbaseCall=fun(dummy: int)-> fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands)
550+
// We are using a Converter<int,int> rather than a "unit->int" because it is too hard to
551+
// figure out how to pass an F# function object via reflection.
552+
letbaseCallDelegate=new System.Converter<int,int>(baseCall)
528553
#endif
529-
try
530-
letret=
531-
(host.GetType()).InvokeMember("Compile", BindingFlags.Public||| BindingFlags.NonPublic||| BindingFlags.InvokeMethod||| BindingFlags.Instance,null, host,
532-
[| baseCallDelegate; box(capturedArguments|> List.toArray); box(capturedFilenames|> List.toArray)|],
533-
System.Globalization.CultureInfo.InvariantCulture)
534-
unbox ret
535-
with
536-
|:? System.Reflection.TargetInvocationExceptionas tiewhen(match tie.InnerExceptionwith|:? Microsoft.Build.Exceptions.BuildAbortedException->true|_->false)->
537-
fsc.Log.LogError(tie.InnerException.Message,[||])
538-
-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
539-
| e->
540-
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()))
541-
reraise()
554+
try
555+
letret=
556+
(host.GetType()).InvokeMember("Compile", BindingFlags.Public||| BindingFlags.NonPublic||| BindingFlags.InvokeMethod||| BindingFlags.Instance,null, host,
557+
[| baseCallDelegate; box(capturedArguments|> List.toArray); box(capturedFilenames|> List.toArray)|],
558+
System.Globalization.CultureInfo.InvariantCulture)
559+
unbox ret
560+
with
561+
|:? System.Reflection.TargetInvocationExceptionas tiewhen(match tie.InnerExceptionwith|:? Microsoft.Build.Exceptions.BuildAbortedException->true|_->false)->
562+
fsc.Log.LogError(tie.InnerException.Message,[||])
563+
-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
564+
| e->
565+
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()))
566+
reraise()
542567

543568
overridefsc.GenerateCommandLineCommands()=
544569
letbuilder=new FscCommandLineBuilder()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,7 @@ type Fsc = class
5555
member HighEntropyVA: bool with get,set
5656
member TargetProfile: string with get,set
5757
member DotnetFscCompilerPath: string with get,set
58+
member SkipCompilerExecution: bool with get,set
59+
member ProvideCommandLineArgs: bool with get,set
60+
member CommandLineArgs: Microsoft.Build.Framework.ITaskItem[] with get,set
5861
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp