-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from rneatherway/fsharp-core-2
FSharp.Core resolution for scripts and projects
- Loading branch information
Showing
16 changed files
with
303 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
namespace FsAutoComplete | ||
|
||
open System | ||
open System.IO | ||
|
||
module Environment = | ||
let private environVar v = Environment.GetEnvironmentVariable v | ||
|
||
let private programFilesX86 = | ||
let wow64 = environVar "PROCESSOR_ARCHITEW6432" | ||
let globalArch = environVar "PROCESSOR_ARCHITECTURE" | ||
match wow64, globalArch with | ||
| "AMD64", "AMD64" | ||
| null, "AMD64" | ||
| "x86", "AMD64" -> environVar "ProgramFiles(x86)" | ||
| _ -> environVar "ProgramFiles" | ||
|> fun detected -> if detected = null then @"C:\Program Files (x86)\" else detected | ||
|
||
// Below code slightly modified from FAKE MSBuildHelper.fs | ||
|
||
let inline private combinePaths path1 (path2 : string) = Path.Combine(path1, path2.TrimStart [| '\\'; '/' |]) | ||
|
||
let inline private (@@) path1 path2 = combinePaths path1 path2 | ||
|
||
let private tryFindFile dirs file = | ||
let files = | ||
dirs | ||
|> Seq.map (fun (path : string) -> | ||
let dir = new DirectoryInfo(path) | ||
if not dir.Exists then "" | ||
else | ||
let fi = new FileInfo(dir.FullName @@ file) | ||
if fi.Exists then fi.FullName | ||
else "") | ||
|> Seq.filter ((<>) "") | ||
|> Seq.cache | ||
if not (Seq.isEmpty files) then Some(Seq.head files) | ||
else None | ||
|
||
let private tryFindPath backupPaths tool = | ||
let paths = Environment.GetEnvironmentVariable "PATH" + string Path.PathSeparator + backupPaths | ||
let paths = paths.Split(Path.PathSeparator) | ||
tryFindFile paths tool | ||
|
||
let private findPath backupPaths tool = | ||
match tryFindPath backupPaths tool with | ||
| Some file -> file | ||
| None -> tool | ||
|
||
let msbuild = | ||
if Utils.runningOnMono then "xbuild" | ||
else | ||
let MSBuildPath = | ||
(programFilesX86 @@ @"\MSBuild\14.0\Bin") + ";" + | ||
(programFilesX86 @@ @"\MSBuild\12.0\Bin") + ";" + | ||
(programFilesX86 @@ @"\MSBuild\12.0\Bin\amd64") + ";" + | ||
@"c:\Windows\Microsoft.NET\Framework\v4.0.30319\;" + | ||
@"c:\Windows\Microsoft.NET\Framework\v4.0.30128\;" + | ||
@"c:\Windows\Microsoft.NET\Framework\v3.5\" | ||
let ev = Environment.GetEnvironmentVariable "MSBuild" | ||
if not (String.IsNullOrEmpty ev) then ev | ||
else findPath MSBuildPath "MSBuild.exe" | ||
|
||
let private fsharpInstallationPath = | ||
["4.0"; "3.1"; "3.0"] | ||
|> List.map (fun v -> programFilesX86 @@ @"\Microsoft SDKs\F#\" @@ v @@ @"\Framework\v4.0") | ||
|> List.tryFind Directory.Exists | ||
|
||
let fsi = | ||
if Utils.runningOnMono then "fsharpi" | ||
else | ||
Option.getOrElse "" fsharpInstallationPath @@ "fsi.exe" | ||
|
||
let fsc = | ||
if Utils.runningOnMono then "fsharpc" | ||
else | ||
Option.getOrElse "" fsharpInstallationPath @@ "fsc.exe" | ||
|
||
let fsharpCoreOpt = | ||
if Utils.runningOnMono then | ||
let mscorlibDir = Path.GetDirectoryName typeof<obj>.Assembly.Location | ||
if List.forall File.Exists (List.map (combinePaths mscorlibDir) ["FSharp.Core.dll"; "FSharp.Core.optdata"; "FSharp.Core.sigdata"]) then | ||
Some (mscorlibDir @@ "FSharp.Core.dll") | ||
else | ||
None | ||
else | ||
let referenceAssembliesPath = | ||
programFilesX86 @@ @"Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\" | ||
let fsharpCoreVersions = ["4.4.0.0"; "4.3.1.0"; "4.3.0.0"] | ||
tryFindFile (List.map (combinePaths referenceAssembliesPath) fsharpCoreVersions) "FSharp.Core.dll" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
FsAutoComplete/test/integration/NoFSharpCoreReference/FileTwo.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module FileTwo | ||
|
||
type Foo = | ||
| Bar | ||
| Qux | ||
|
||
let addition x y = x + y | ||
|
||
let add x y = x + y | ||
|
||
type NewObjectType() = | ||
|
||
member x.Terrific (y : int) : int = | ||
y |
15 changes: 15 additions & 0 deletions
15
FsAutoComplete/test/integration/NoFSharpCoreReference/Program.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module X = | ||
let func x = x + 1 | ||
|
||
let testval = FileTwo.NewObjectType() | ||
|
||
let val2 = X.func 2 | ||
|
||
let val3 = testval.Terrific val2 | ||
|
||
let val4 : FileTwo.NewObjectType = testval | ||
|
||
[<EntryPoint>] | ||
let main args = | ||
printfn "Hello %d" val2 | ||
0 |
21 changes: 21 additions & 0 deletions
21
FsAutoComplete/test/integration/NoFSharpCoreReference/Runner.fsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#load "../TestHelpers.fsx" | ||
open TestHelpers | ||
open System.IO | ||
open System | ||
|
||
(* | ||
* This test is a simple sanity check of a basic run of the program. | ||
* A few completions, files and script. | ||
*) | ||
|
||
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ | ||
File.Delete "output.json" | ||
|
||
let p = new FsAutoCompleteWrapper() | ||
|
||
|
||
p.project "Test1.fsproj" | ||
p.send "quit\n" | ||
p.finalOutput () | ||
|> writeNormalizedOutput "output.json" | ||
|
6 changes: 6 additions & 0 deletions
6
FsAutoComplete/test/integration/NoFSharpCoreReference/Script.fsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
module XA = | ||
let funky x = x + 1 | ||
|
||
let val99 = XA.funky 21 |
Oops, something went wrong.