Skip to content

Commit

Permalink
Merge pull request #1083 from matthid/fsharp_scripting
Browse files Browse the repository at this point in the history
General FAKE improvements
  • Loading branch information
forki committed Jan 19, 2016
2 parents 8ebc375 + c488c27 commit e0bf214
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 183 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ release.cmd
Samples/typescript/out/
help/RELEASE_NOTES.md
paket.exe
paket-files/

# Ignore the Vagrant local directories
.vagrant/*
Expand Down
51 changes: 50 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,43 @@ Target "Test" (fun _ ->
|> xUnit id
)

Target "Bootstrap" (fun _ ->
let buildScript = "build.fsx"
let testScript = "testbuild.fsx"
// Check if we can build ourself with the new binaries.
let test clearCache script =
let clear () =
// Will make sure the test call actually compiles the script.
// Note: We cannot just clean .fake here as it might be locked by the currently executing code :)
if Directory.Exists ".fake" then
Directory.EnumerateFiles(".fake")
|> Seq.filter (fun s -> (Path.GetFileName s).StartsWith script)
|> Seq.iter File.Delete
let executeTarget target =
if clearCache then clear ()
ExecProcess (fun info ->
info.FileName <- "build/FAKE.exe"
info.WorkingDirectory <- "."
info.Arguments <- sprintf "%s %s -pd" script target) (System.TimeSpan.FromMinutes 3.0)

let result = executeTarget "PrintColors"
if result <> 0 then failwith "Bootstrapping failed"

let result = executeTarget "FailFast"
if result = 0 then failwith "Bootstrapping failed"

File.ReadAllText buildScript
|> fun s -> s.Replace("#I @\"packages/build/FAKE/tools/\"", "#I @\"build/\"")
|> fun text -> File.WriteAllText(testScript, text)

try
// Will compile the script.
test true testScript
// Will use the compiled/cached version.
test false testScript
finally File.Delete(testScript)
)

Target "SourceLink" (fun _ ->
!! "src/app/**/*.fsproj"
|> Seq.iter (fun f ->
Expand Down Expand Up @@ -287,7 +324,18 @@ Target "Release" (fun _ ->
Branches.tag "" release.NugetVersion
Branches.pushTag "" "origin" release.NugetVersion
)

open System
Target "PrintColors" (fun s ->
let color (color: ConsoleColor) (code : unit -> _) =
let before = Console.ForegroundColor
try
Console.ForegroundColor <- color
code ()
finally
Console.ForegroundColor <- before
color ConsoleColor.Magenta (fun _ -> printfn "TestMagenta")
)
Target "FailFast" (fun _ -> failwith "fail fast")
Target "Default" DoNothing

// Dependencies
Expand All @@ -296,6 +344,7 @@ Target "Default" DoNothing
==> "BuildSolution"
//==> "ILRepack"
==> "Test"
==> "Bootstrap"
==> "Default"
==> "CopyLicense"
=?> ("GenerateDocs", isLocalBuild && not isLinux)
Expand Down
2 changes: 2 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ nuget FluentMigrator.Runner
nuget HashLib
nuget FSharp.Compiler.Service

github matthid/Yaaf.FSharp.Scripting src/source/Yaaf.FSharp.Scripting/YaafFSharpScripting.fs

group Build
content: none
source http://nuget.org/api/v2
Expand Down
5 changes: 4 additions & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ NUGET
xunit.extensions (1.9.2)
xunit (1.9.2)
xunit.runners (1.9.2)

GITHUB
remote: matthid/Yaaf.FSharp.Scripting
specs:
src/source/Yaaf.FSharp.Scripting/YaafFSharpScripting.fs (48789eeb63382a6934966472e270e87880cb49ed)
GROUP Build
CONTENT: NONE
NUGET
Expand Down
6 changes: 5 additions & 1 deletion src/app/FAKE/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ try
| Choice1Of2(fakeArgs) ->

//Break to allow a debugger to be attached here
if fakeArgs.Contains <@ Cli.Break @> then Diagnostics.Debugger.Break()
if fakeArgs.Contains <@ Cli.Break @> then
Diagnostics.Debugger.Launch() |> ignore
Diagnostics.Debugger.Break() |> ignore

//Boot and version force us to ignore other args, so check for them and handle.
let isBoot, bootArgs = fakeArgs.Contains <@ Cli.Boot @>, fakeArgs.GetResults <@ Cli.Boot @>
Expand Down Expand Up @@ -162,3 +164,5 @@ try

finally
traceEndBuild()
if !TargetHelper.ExitCode.exitCode <> 0 then exit !TargetHelper.ExitCode.exitCode
if Environment.ExitCode <> 0 then exit Environment.ExitCode
Loading

0 comments on commit e0bf214

Please sign in to comment.