Browse Source

improvements to the F# build tasks and stopping the interactive console throwing an error on start up

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2967 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Robert Pickering 18 years ago
parent
commit
b9725ed5a9
  1. 10
      src/AddIns/BackendBindings/FSharp/FSharp.Build.Tasks/Project/Src/Fsc.cs
  2. 107
      src/AddIns/BackendBindings/FSharp/FSharpBinding/Project/Src/fsi.fs
  3. BIN
      src/AddIns/BackendBindings/FSharp/RequiredLibraries/FSharp.Build.Tasks.dll

10
src/AddIns/BackendBindings/FSharp/FSharp.Build.Tasks/Project/Src/Fsc.cs

@ -117,7 +117,7 @@ namespace FSharp.Build.Tasks @@ -117,7 +117,7 @@ namespace FSharp.Build.Tasks
if (path != null) {
path = Path.Combine(path, ToolName);
} else {
string[] dirs = Directory.GetDirectories(Environment.GetEnvironmentVariable("ProgramFiles"));
string[] dirs = Directory.GetDirectories(Environment.GetEnvironmentVariable("ProgramFiles"), "FSharp*" );
List<FileInfo> files = new List<FileInfo>();
foreach (string dir in dirs) {
FileInfo file = new FileInfo(Path.Combine(Path.Combine(dir, "bin"), ToolName));
@ -128,9 +128,10 @@ namespace FSharp.Build.Tasks @@ -128,9 +128,10 @@ namespace FSharp.Build.Tasks
if (files.Count > 0) {
files.Sort(delegate(FileInfo x, FileInfo y) { return DateTime.Compare(x.CreationTime, y.CreationTime); });
path = files[0].FullName;
} else {
throw new Exception("can not find the fsi.exe, ensure a version of the F# compiler is installed");
}
}
//else {
// throw new Exception("can not find the fsi.exe, ensure a version of the F# compiler is installed");
//}
}
}
return path;
@ -236,6 +237,7 @@ namespace FSharp.Build.Tasks @@ -236,6 +237,7 @@ namespace FSharp.Build.Tasks
} else if (matchNoLine.Success) {
CompilerError error = new CompilerError();
error.Column = Int32.Parse(matchNoLine.Result("${column}"));
error.Line = Int32.Parse(matchNoLine.Result("${line}"));
error.FileName = Path.GetFullPath(matchNoLine.Result("${file}"));
error.IsWarning = matchNoLine.Result("${error}") == "warning";
error.ErrorNumber = matchNoLine.Result("${number}");

107
src/AddIns/BackendBindings/FSharp/FSharpBinding/Project/Src/fsi.fs

@ -42,57 +42,66 @@ module TheControl = @@ -42,57 +42,66 @@ module TheControl =
Anchor = (AnchorStyles.Left ||| AnchorStyles.Top ||| AnchorStyles.Right ||| AnchorStyles.Bottom))
panel.Controls.Add(input)
panel.Controls.Add(output)
if ConfigurationManager.AppSettings.AllKeys |> Array.exists (fun x -> x = "alt_fs_bin_path") then
let path = Path.Combine(ConfigurationManager.AppSettings.get_Item("alt_fs_bin_path"), "fsi.exe")
if File.Exists(path) then
fsiProcess.StartInfo.FileName <- path
else
failwith "you are trying to use the app setting alt_fs_bin_path, but fsi.exe is not localed in the given directory"
else
let path = Environment.GetEnvironmentVariable("PATH")
let paths = path.Split([|';'|])
let path = paths |> Array.tryfind (fun x -> File.Exists(Path.Combine(x, "fsi.exe")))
match path with
| Some x -> fsiProcess.StartInfo.FileName <- Path.Combine(x, "fsi.exe")
| None ->
let programFiles = Environment.GetEnvironmentVariable("ProgramFiles")
let fsdirs = Directory.GetDirectories(programFiles, "FSharp*")
let possibleFiles =
fsdirs |> Array.choose
(fun x ->
let fileInfo = new FileInfo(Path.Combine(x, "bin\fsi.exe"))
if fileInfo.Exists then
Some fileInfo
else
None)
possibleFiles |> Array.sort (fun x y -> DateTime.Compare(x.CreationTime, y.CreationTime))
if possibleFiles.Length > 0 then
fsiProcess.StartInfo.FileName <- possibleFiles.[0].FullName
let foundCompiler =
if ConfigurationManager.AppSettings.AllKeys |> Array.exists (fun x -> x = "alt_fs_bin_path") then
let path = Path.Combine(ConfigurationManager.AppSettings.get_Item("alt_fs_bin_path"), "fsi.exe")
if File.Exists(path) then
fsiProcess.StartInfo.FileName <- path
true
else
output.Text <-
"Can not find the fsi.exe, ensure a version of the F# compiler is installed." + Environment.NewLine +
"Please see http://research.microsoft.com/fsharp for details of how to install the compiler"
fsiProcess.StartInfo.UseShellExecute <- false
fsiProcess.StartInfo.RedirectStandardError <- true
fsiProcess.StartInfo.RedirectStandardInput <- true
fsiProcess.StartInfo.RedirectStandardOutput <- true
fsiProcess.ErrorDataReceived.Add(fun ea -> lock errorQueue (fun () -> errorQueue.Enqueue(ea.Data)) )
fsiProcess.OutputDataReceived.Add(fun ea -> lock outputQueue (fun () -> outputQueue.Enqueue(ea.Data)) )
fsiProcess.Exited.Add(fun ea ->
output.AppendText("fsi.exe died" + Environment.NewLine)
output.AppendText("restarting ..." + Environment.NewLine)
fsiProcess.Start() |> ignore)
fsiProcess.Start() |> ignore
fsiProcess.BeginErrorReadLine()
fsiProcess.BeginOutputReadLine()
let timer = new Timer(Interval = 1000)
let readAll (q : Queue<string>) =
while q.Count > 0 do
output.AppendText(q.Dequeue() + Environment.NewLine)
timer.Tick.Add(fun _ ->
lock errorQueue (fun () -> readAll errorQueue)
lock outputQueue (fun () -> readAll outputQueue))
timer.Start()
"you are trying to use the app setting alt_fs_bin_path, but fsi.exe is not localed in the given directory"
false
else
let path = Environment.GetEnvironmentVariable("PATH")
let paths = path.Split([|';'|])
let path = paths |> Array.tryfind (fun x -> File.Exists(Path.Combine(x, "fsi.exe")))
match path with
| Some x ->
fsiProcess.StartInfo.FileName <- Path.Combine(x, "fsi.exe")
true
| None ->
let programFiles = Environment.GetEnvironmentVariable("ProgramFiles")
let fsdirs = Directory.GetDirectories(programFiles, "FSharp*")
let possibleFiles =
fsdirs |> Array.choose
(fun x ->
let fileInfo = new FileInfo(Path.Combine(x, "bin\fsi.exe"))
if fileInfo.Exists then
Some fileInfo
else
None)
possibleFiles |> Array.sort (fun x y -> DateTime.Compare(x.CreationTime, y.CreationTime))
if possibleFiles.Length > 0 then
fsiProcess.StartInfo.FileName <- possibleFiles.[0].FullName
true
else
output.Text <-
"Can not find the fsi.exe, ensure a version of the F# compiler is installed." + Environment.NewLine +
"Please see http://research.microsoft.com/fsharp for details of how to install the compiler"
false
if foundCompiler then
fsiProcess.StartInfo.UseShellExecute <- false
fsiProcess.StartInfo.RedirectStandardError <- true
fsiProcess.StartInfo.RedirectStandardInput <- true
fsiProcess.StartInfo.RedirectStandardOutput <- true
fsiProcess.ErrorDataReceived.Add(fun ea -> lock errorQueue (fun () -> errorQueue.Enqueue(ea.Data)) )
fsiProcess.OutputDataReceived.Add(fun ea -> lock outputQueue (fun () -> outputQueue.Enqueue(ea.Data)) )
fsiProcess.Exited.Add(fun ea ->
output.AppendText("fsi.exe died" + Environment.NewLine)
output.AppendText("restarting ..." + Environment.NewLine)
fsiProcess.Start() |> ignore)
fsiProcess.Start() |> ignore
fsiProcess.BeginErrorReadLine()
fsiProcess.BeginOutputReadLine()
let timer = new Timer(Interval = 1000)
let readAll (q : Queue<string>) =
while q.Count > 0 do
output.AppendText(q.Dequeue() + Environment.NewLine)
timer.Tick.Add(fun _ ->
lock errorQueue (fun () -> readAll errorQueue)
lock outputQueue (fun () -> readAll outputQueue))
timer.Start()
type FSharpInteractive = class
inherit AbstractPadContent

BIN
src/AddIns/BackendBindings/FSharp/RequiredLibraries/FSharp.Build.Tasks.dll

Binary file not shown.
Loading…
Cancel
Save