Skip to content

Commit

Permalink
Another go at --- Map workspace to iprojectsite (#3564)
Browse files Browse the repository at this point in the history
* Saved

* SDK editor support

* Address merge issues

* Feedback

* reduce delta

* invalidate ide when a new file is discovered

* Go faster stripes

* feedback + refactor

* tryFindIndex

* Cleanup + Ensure that FSharp.Core.BuildFromSource.proj works at designtime

* final clean up

* label for HandleCommandLineChanges

* ensure some buildfromsource porojects load
  • Loading branch information
KevinRansom authored Sep 16, 2017
1 parent 4769a92 commit 602daf8
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 59 deletions.
3 changes: 2 additions & 1 deletion src/FSharpSource.BuildFromSource.targets
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<Target Name="CopyAndSubstituteTextFiles"
BeforeTargets="Compile"
Inputs="@(CopyAndSubstituteText)"
Outputs="@(CopyAndSubstituteText->'$(OutDir)%(TargetFilename)')" >
Outputs="@(CopyAndSubstituteText->'$(OutDir)%(TargetFilename)')"
Condition="'$(DesignTimeBuild)' != 'true'">

<ItemGroup>
<Results Include="@(CopyAndSubstituteText->'$(OutDir)%(TargetFilename)')">
Expand Down
2 changes: 1 addition & 1 deletion src/buildfromsource.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if ERRORLEVEL 1 echo Error: failed && goto :failure
rem build and pack tools
dotnet restore %__scriptpath%fsharp\FSharp.Compiler.nuget\FSharp.Compiler.nuget.BuildFromSource.fsproj
if ERRORLEVEL 1 echo Error: failed && goto :failure
dotnet pack %__scriptpath%fsharp\FSharp.Compiler.nuget\FSharp.Compiler.nuget.BuildFromSource.fsproj -c release
dotnet pack %__scriptpath%fsharp\FSharp.Compiler.nuget\FSharp.Compiler.nuget.BuildFromSource.fsproj -c debug
if ERRORLEVEL 1 echo Error: failed && goto :failure

goto :success
Expand Down
5 changes: 1 addition & 4 deletions src/fsharp/FSharp.Build/InternalsVisibleTo.fs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.FSharp
open System.Reflection
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Unittests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]


[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Unittests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]
do()

4 changes: 2 additions & 2 deletions src/fsharp/FSharp.Core/FSharp.Core.BuildFromSource.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<OtherFlags>$(OtherFlags) --warnon:1182 --compiling-fslib --compiling-fslib-40 --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
</PropertyGroup>

<Import Project = "$(MSBuildThisFileDirectory)..\..\FSharpSource.BuildFromSource.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\..\FSharpSource.BuildFromSource.targets" />
<ItemGroup>
<EmbeddedResource Include="FSCore.resx">
<Link>FSCore.resx</Link>
Expand Down Expand Up @@ -212,7 +212,7 @@
<!-- NOTE: The optdata and sigdata files are no longer needed by the F# compiler (the information is -->
<!-- integrated as resources into more recent FSharp.Core.dll's. However they are still produced to -->
<!-- allow older versions of the F# compiler to reference more recent FSharp.Core packages -->
<Target Name="CopyToBuiltBin" BeforeTargets="AfterCompile" AfterTargets="CoreCompile" >
<Target Name="CopyToBuiltBin" BeforeTargets="AfterCompile" AfterTargets="CoreCompile" Condition="'$(DesignTimeBuild)' != 'true'">
<ItemGroup>
<BuiltProjectOutputGroupKeyOutput Include="$(IntermediateOutputPath)/FSharp.Core.sigdata" />
<BuiltProjectOutputGroupKeyOutput Include="$(IntermediateOutputPath)/FSharp.Core.optdata" />
Expand Down
1 change: 0 additions & 1 deletion src/fsharp/fsi/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
do tcConfigB.resolutionEnvironment <- ResolutionEnvironment.EditingOrCompilation false
do tcConfigB.useSimpleResolution <- true
do SetTargetProfile tcConfigB "netcore" // always assume System.Runtime codegen
//do SetTargetProfile tcConfigB "privatecorelib" // always assume System.Private.CoreLib codegen
#endif

// Preset: --optimize+ -g --tailcalls+ (see 4505)
Expand Down
34 changes: 28 additions & 6 deletions src/fsharp/vs/IncrementalBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,11 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs
/// CreateIncrementalBuilder (for background type checking). Note that fsc.fs also
/// creates an incremental builder used by the command line compiler.
static member TryCreateBackgroundBuilderForProjectOptions (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, frameworkTcImportsCache: FrameworkImportsCache, loadClosureOpt:LoadClosure option, sourceFiles:string list, commandLineArgs:string list, projectReferences, projectDirectory, useScriptResolutionRules, keepAssemblyContents, keepAllBackgroundResolutions, maxTimeShareMilliseconds) =
let targetProfileSwitch = "--targetprofile:"
let useSimpleResolutionSwitch = "--simpleresolution"

cancellable {

// Trap and report warnings and errors from creation.
use errorScope = new ErrorScope()
let! builderOpt =
Expand All @@ -1695,23 +1698,38 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs

/// Create a type-check configuration
let tcConfigB, sourceFilesNew =


let getSwitchValue switchstring =
match commandLineArgs |> Seq.tryFindIndex(fun s -> s.StartsWith(switchstring)) with
| Some idx -> Some(commandLineArgs.[idx].Substring(switchstring.Length))
| _ -> None

// see also fsc.fs:runFromCommandLineToImportingAssemblies(), as there are many similarities to where the PS creates a tcConfigB
let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir, implicitIncludeDir=projectDirectory, optimizeForMemory=true, isInteractive=false, isInvalidationSupported=true, defaultCopyFSharpCore=false)

// The following uses more memory but means we don't take read-exclusions on the DLLs we reference
// Could detect well-known assemblies--ie System.dll--and open them with read-locks
tcConfigB.openBinariesInMemory <- true

tcConfigB.resolutionEnvironment <- (ReferenceResolver.ResolutionEnvironment.EditingOrCompilation true)

tcConfigB.conditionalCompilationDefines <-
let define = if useScriptResolutionRules then "INTERACTIVE" else "COMPILED"
define::tcConfigB.conditionalCompilationDefines

tcConfigB.projectReferences <- projectReferences

#if COMPILER_SERVICE_ASSUMES_DOTNETCORE_COMPILATION
tcConfigB.useSimpleResolution <- true // turn off msbuild resolution
#else
tcConfigB.useSimpleResolution <- (getSwitchValue useSimpleResolutionSwitch) |> Option.isSome
#endif
match (getSwitchValue targetProfileSwitch) with
| Some v ->
let _s = v
CompileOptions.SetTargetProfile tcConfigB v
| None -> ()

// Apply command-line arguments and collect more source files if they are in the arguments
let sourceFilesNew =
try
Expand All @@ -1725,12 +1743,16 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs

// Never open PDB files for the language service, even if --standalone is specified
tcConfigB.openDebugInformationForLaterStaticLinking <- false

match commandLineArgs |> Seq.tryFind(fun s -> s.StartsWith(targetProfileSwitch)) with
| Some arg ->
let profile = arg.Substring(targetProfileSwitch.Length)
CompileOptions.SetTargetProfile tcConfigB profile
| _ -> ()
tcConfigB, sourceFilesNew

match loadClosureOpt with
| Some loadClosure ->
let dllReferences =
| Some loadClosure ->
let dllReferences =
[for reference in tcConfigB.referencedDLLs do
// If there's (one or more) resolutions of closure references then yield them all
match loadClosure.References |> List.tryFind (fun (resolved,_)->resolved=reference.Text) with
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@ type FsiInteractiveChecker(legacyReferenceResolver, reactorOps: IReactorOperatio

let loadClosure = LoadClosure.ComputeClosureOfSourceText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, CodeContext.Editing, tcConfig.useSimpleResolution, tcConfig.useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions, assumeDotNetFramework)
let! tcErrors, tcFileResult = Parser.CheckOneFile(parseResults, source, filename, "project", tcConfig, tcGlobals, tcImports, tcState, Some loadClosure, backgroundDiagnostics, reactorOps, (fun () -> true), None, userOpName)

return
match tcFileResult with
| Parser.TypeCheckAborted.No scope ->
Expand All @@ -3150,7 +3150,7 @@ type FsiInteractiveChecker(legacyReferenceResolver, reactorOps: IReactorOperatio
| _ ->
failwith "unexpected aborted"
}

//----------------------------------------------------------------------------
// CompilerEnvironment, DebuggerEnvironment
//
Expand Down
Loading

0 comments on commit 602daf8

Please sign in to comment.