Fix issues with GenerateBindings target
authorFraser Waters <frassle@gmail.com>
Sat, 30 Dec 2017 18:43:26 +0000 (18:43 +0000)
committerFraser Waters <frassle@gmail.com>
Mon, 1 Jan 2018 19:33:25 +0000 (19:33 +0000)
generateBindings was let bound as a value and thus ran at startup before
any other target. Changed so all the code for generating the bindings is
in the target and the target is added a build dependency.

build.fsx

index ee8eb0a..44d90d1 100644 (file)
--- a/build.fsx
+++ b/build.fsx
@@ -99,17 +99,6 @@ let runtimeProjects =
 let activeProjects =
     Seq.concat [buildProjects; runtimeProjects]
 
-let generateBindings =
-    if not (File.Exists(".bindingsGenerated")) then
-        buildProjects
-            |> MSBuildRelease "" "Build"
-            |> ignore
-        let bindingProcess = new Process()
-        bindingProcess.StartInfo.FileName <- Path.Combine("src", "Generator.Bind", "bin", "Release", "Bind.exe")
-        bindingProcess.Start() |> ignore
-        bindingProcess.WaitForExit() |> ignore
-        File.Create(".bindingsGenerated").Close() |> ignore
-
 
 // Generate assembly info files with the right version & up-to-date information
 Target "AssemblyInfo" (fun _ ->
@@ -165,15 +154,23 @@ Target "Clean" (fun _ ->
 // --------------------------------------------------------------------------------------
 // Build generator projects, and generate bindings if neccesary
 Target "GenerateBindings" (fun _ ->
-    generateBindings
-    |> ignore
+    if not (File.Exists(".bindingsGenerated")) then
+        buildProjects
+            |> MSBuildRelease "" "Build"
+            |> ignore
+        let bindingProcess = new Process()
+        bindingProcess.StartInfo.FileName <- Path.Combine("src", "Generator.Bind", "bin", "Release", "Bind.exe")
+        if bindingProcess.Start() then
+            bindingProcess.WaitForExit()
+            File.Create(".bindingsGenerated").Close()
+        else
+            failwith "Could not start Bind.exe"
 )
 
 // --------------------------------------------------------------------------------------
 // Build library & test project
 
 Target "Build" (fun _ ->
-    generateBindings
     activeProjects
     |> MSBuildRelease "" "Build"
     |> ignore
@@ -221,6 +218,7 @@ Target "All" DoNothing
 
 "Clean"
   ==> "AssemblyInfo"
+  ==> "GenerateBindings"
   ==> "Build"
   ==> "CopyBinaries"
   ==> "RunTests"