Skip to content

Commit e0318a8

Browse files
authored
FSharp ms build task to support new xommand line options (#1616)
1 parent 749ba2d commit e0318a8

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/FSharpSource.Settings.targets

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
<DebugType Condition=" '$(DebugType)' == '' and '$(TargetFramework)' == 'coreclr' ">embedded</DebugType>
3232
<Optimize Condition=" '$(Optimize)' == '' ">false</Optimize>
3333
<ErrorReport Condition=" '$(ErrorReport)' == '' ">prompt</ErrorReport>
34-
<OtherFlags Condition=" '$(DebugType)' == '' and '$(TargetFramework)' != 'coreclr' ">$(OtherFlags) --no-jit-optimize</OtherFlags>
35-
<OtherFlags Condition=" '$(DebugType)' == '' and '$(TargetFramework)' == 'coreclr' ">$(OtherFlags) --no-jit-optimize --embed</OtherFlags>
34+
<OtherFlags>$(OtherFlags) --no-jit-optimize</OtherFlags>
35+
<EmbedAllSource Condition=" '$(DebugType)' == 'portable' or '$(DebugType)' == 'embedded' ">true</EmbedAllSource>
36+
<SourceLink Condition=" '$(DebugType)' == 'portable' or '$(DebugType)' == 'embedded' ">$(IntermediateOutputPath)source_link.json</SourceLink>
3637
<DefineConstants Condition=" '$(ProjectLanguage)' != 'VisualBasic' ">DEBUG;TRACE;CODE_ANALYSIS;$(DefineConstants)</DefineConstants>
3738
<DefineConstants Condition=" '$(ProjectLanguage)' == 'VisualBasic' ">DEBUG=True,TRACE=True,CODE_ANALYSIS=True,$(DefineConstants)</DefineConstants>
3839
<SIGN_WITH_MSFT_KEY Condition=" '$(SIGN_WITH_MSFT_KEY)' == '' ">false</SIGN_WITH_MSFT_KEY>
@@ -41,6 +42,7 @@
4142
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
4243
<DebugType Condition=" '$(DebugType)' == '' ">pdbonly</DebugType>
4344
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
45+
<EmbedAllSource>false</EmbedAllSource>
4446
<ErrorReport Condition=" '$(ErrorReport)' == '' ">prompt</ErrorReport>
4547
<DefineConstants Condition=" '$(ProjectLanguage)' != 'VisualBasic' ">TRACE;$(DefineConstants)</DefineConstants>
4648
<DefineConstants Condition=" '$(ProjectLanguage)' == 'VisualBasic' ">TRACE=True,$(DefineConstants)</DefineConstants>

src/fsharp/FSharp.Build/Fsc.fs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
122122
let mutable defineConstants : ITaskItem[] = [||]
123123
let mutable disabledWarnings : string = null
124124
let mutable documentationFile : string = null
125+
let mutable embedAllSources = false
126+
let mutable embed : string = null
125127
let mutable generateInterfaceFile : string = null
126128
let mutable keyFile : string = null
127129
let mutable noFramework = false
@@ -136,6 +138,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
136138
let mutable referencePath : string = null
137139
let mutable resources : ITaskItem[] = [||]
138140
let mutable sources : ITaskItem[] = [||]
141+
let mutable sourceLink : string = null
139142
let mutable targetType : string = null
140143
#if FX_ATLEAST_35
141144
#else
@@ -183,6 +186,10 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
183186
| "EMBEDDED" -> "embedded"
184187
| "FULL" -> "full"
185188
| _ -> null)
189+
if embedAllSources then
190+
builder.AppendSwitch("--embed+")
191+
builder.AppendSwitchIfNotNull("--embed:", embed)
192+
builder.AppendSwitchIfNotNull("--sourcelink:", sourceLink)
186193
// NoFramework
187194
if noFramework then
188195
builder.AppendSwitch("--noframework")
@@ -316,7 +323,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
316323
member fsc.DebugSymbols
317324
with get() = debugSymbols
318325
and set(b) = debugSymbols <- b
319-
// --debug <none/portable/pdbonly/full>: Emit debugging information
326+
// --debug <none/portable/embedded/pdbonly/full>: Emit debugging information
320327
member fsc.DebugType
321328
with get() = debugType
322329
and set(s) = debugType <- s
@@ -332,6 +339,12 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
332339
member fsc.DocumentationFile
333340
with get() = documentationFile
334341
and set(s) = documentationFile <- s
342+
member fsc.EmbedAllSources
343+
with get() = embedAllSources
344+
and set(s) = embedAllSources <- s
345+
member fsc.Embed
346+
with get() = embed
347+
and set(e) = embed <- e
335348
// --generate-interface-file <string>:
336349
// Print the inferred interface of the
337350
// assembly to a file.
@@ -398,6 +411,10 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
398411
member fsc.Resources
399412
with get() = resources
400413
and set(a) = resources <- a
414+
// SourceLink
415+
member fsc.SourceLink
416+
with get() = sourceLink
417+
and set(s) = sourceLink <- s
401418
// source files
402419
member fsc.Sources
403420
with get() = sources

src/fsharp/FSharp.Build/Fsc.fsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ type Fsc = class
2323
member DefineConstants : Microsoft.Build.Framework.ITaskItem [] with get,set
2424
member DisabledWarnings : string with get,set
2525
member DocumentationFile : string with get,set
26+
member Embed : string with get,set
27+
member EmbedAllSources : bool with get,set
2628
member GenerateInterfaceFile : string with get,set
2729
member KeyFile : string with get,set
2830
member NoFramework : bool with get,set
@@ -37,6 +39,7 @@ type Fsc = class
3739
member References : Microsoft.Build.Framework.ITaskItem [] with get,set
3840
member ReferencePath : string with get,set
3941
member Resources : Microsoft.Build.Framework.ITaskItem [] with get,set
42+
member SourceLink : string with get,set
4043
member Sources : Microsoft.Build.Framework.ITaskItem [] with get,set
4144
member TargetType : string with get,set
4245
#if FX_ATLEAST_35

src/fsharp/FSharp.Build/Microsoft.FSharp.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ this file.
160160
DefineConstants="$(DefineConstants)"
161161
DisabledWarnings="$(NoWarn)"
162162
DocumentationFile="$(DocumentationFile)"
163+
EmbedAllSources="$(EmbedAllSources)"
164+
Embed="$(Embed)"
163165
GenerateInterfaceFile="$(GenerateInterfaceFile)"
164166
KeyFile="$(KeyOriginatorFile)"
165167
LCID="$(LCID)"
@@ -173,6 +175,7 @@ this file.
173175
References="@(ReferencePath)"
174176
ReferencePath="$(ReferencePath)"
175177
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)"
178+
SourceLink="$(SourceLink)"
176179
Sources="@(CompileBefore);@(Compile);@(CompileAfter)"
177180
Tailcalls="$(Tailcalls)"
178181
TargetType="$(OutputType)"

0 commit comments

Comments
 (0)