@@ -22,14 +22,19 @@ module XakeScript =
2222 /// Console output verbosity level. Default is Warn
2323 ConLogLevel: Verbosity
2424 /// Overrides "want", i.e. target list
25- Want: string list
25+ Targets: string list
26+
27+ /// Global script variables
2628 Vars: ( string * string ) list
2729
2830 /// Defines whether ` run ` should throw exception if script fails
2931 FailOnError: bool
3032
3133 /// Ignores command line swithes
3234 IgnoreCommandLine: bool
35+
36+ /// Disable logo message
37+ Nologo: bool
3338 }
3439
3540 type private ExecStatus = | Succeed | Skipped | JustFile
@@ -71,10 +76,11 @@ module XakeScript =
7176 CustomLogger = CustomLogger ( fun _ -> false ) ignore
7277 FileLog = " build.log"
7378 FileLogLevel = Chatty
74- Want = []
79+ Targets = []
7580 FailOnError = false
7681 Vars = List< string* string>. Empty
7782 IgnoreCommandLine = false
83+ Nologo = false
7884 }
7985
8086 module private Impl = begin
@@ -328,7 +334,7 @@ module XakeScript =
328334 /// <summary >
329335 /// Executes several artifacts in parallel.
330336 /// </summary >
331- and private execMany ctx = Seq.ofList >> Seq.map ( execOne ctx) >> Async.Parallel
337+ and private execParallel ctx = Seq.ofList >> Seq.map ( execOne ctx) >> Async.Parallel
332338
333339 /// <summary >
334340 /// Gets the status of dependency artifacts (obtained from 'need' calls).
@@ -341,7 +347,7 @@ module XakeScript =
341347 ctx.Tgt |> Option.iter ( Progress.TaskSuspend >> ctx.Progress.Post)
342348
343349 do ctx.Throttler.Release() |> ignore
344- let! statuses = targets |> execMany ctx
350+ let! statuses = targets |> execParallel ctx
345351 do ! ctx.Throttler.WaitAsync(- 1 ) |> Async.AwaitTask |> Async.Ignore
346352
347353 ctx.Tgt |> Option.iter ( Progress.TaskResume >> ctx.Progress.Post)
@@ -393,40 +399,39 @@ module XakeScript =
393399 NeedRebuild = fun _ -> false
394400 Tgt = None
395401 }
396- // TODO wrap more elegantly
397- let rec get_changed_deps = CommonLib.memoize ( getDepsImpl ctx ( fun x -> get_ changed_ deps x)) in
398-
399- let check_rebuild target =
400- get_ changed_ deps >>
401- function
402- | [] -> false , " "
403- | DepState.Other reason::_ -> true , reason
404- | DepState.Depends ( t,_) ::_ -> true , " Depends on target " + ( getFullName t)
405- | DepState.FilesChanged ( file::_) ::_ -> true , " File(s) changed " + file
406- | reasons -> true , sprintf " Some reason %A " reasons
407- >>
408- function
409- | false , _ -> false
410- | true , reason ->
411- do ctx.Logger.Log Info " Rebuild %A : %s " ( getShortname target) reason
412- true
413- <| target
414-
415- // define targets
416- let targets =
417- match options.Want with
418- | [] ->
419- do logger.Log Level.Message " No target(s) specified. Defaulting to 'main'"
420- [ " main" ]
421- | tt -> tt
422- |> List.map ( makeTarget ctx)
423-
424- let getDurationDeps t =
425- let collectTargets = List.collect ( function | Depends ( t,_) -> [ t] | _ -> [])
426- ( getExecTime ctx t) / 1000 < ms>, get_ changed_ deps t |> collectTargets
427- let progressSink = Progress.openProgress getDurationDeps options.Threads targets
428-
429- let ctx = { ctx with NeedRebuild = check_ rebuild; Progress = progressSink}
402+
403+ let runStep targetNames =
404+ // TODO wrap more elegantly
405+ let rec get_changed_deps = CommonLib.memoize ( getDepsImpl ctx ( fun x -> get_ changed_ deps x)) in
406+
407+ let check_rebuild target =
408+ get_ changed_ deps >>
409+ function
410+ | [] -> false , " "
411+ | DepState.Other reason::_ -> true , reason
412+ | DepState.Depends ( t,_) ::_ -> true , " Depends on target " + ( getFullName t)
413+ | DepState.FilesChanged ( file::_) ::_ -> true , " File(s) changed " + file
414+ | reasons -> true , sprintf " Some reason %A " reasons
415+ >>
416+ function
417+ | false , _ -> false
418+ | true , reason ->
419+ do ctx.Logger.Log Info " Rebuild %A : %s " ( getShortname target) reason
420+ true
421+ <| target
422+
423+ let targets = targetNames |> List.map ( makeTarget ctx)
424+ let getDurationDeps t =
425+ let collectTargets = List.collect ( function | Depends ( t,_) -> [ t] | _ -> [])
426+ ( getExecTime ctx t) / 1000 < ms>, get_ changed_ deps t |> collectTargets
427+ let progressSink = Progress.openProgress getDurationDeps options.Threads targets
428+
429+ let stepCtx = { ctx with NeedRebuild = check_ rebuild; Progress = progressSink}
430+
431+ try
432+ targets |> execParallel stepCtx |> Async.RunSynchronously |> ignore
433+ finally
434+ do Progress.Finish |> progressSink.Post
430435
431436 logger.Log Info " Options: %A " options
432437
@@ -436,9 +441,20 @@ module XakeScript =
436441 | a -> yield a
437442 }
438443
444+ // splits list of targets ["t1;t2"; "t3;t4"] into list of list.
445+ let targetLists =
446+ options.Targets
447+ |> function
448+ | [] ->
449+ do logger.Log Level.Message " No target(s) specified. Defaulting to 'main'"
450+ [[ " main" ]]
451+ | tt ->
452+ tt |> List.map ( fun s -> s.Split( ';' , '|' ) |> List.ofArray)
453+
439454 try
440455 try
441- targets |> execMany ctx |> Async.RunSynchronously |> ignore
456+ for list in targetLists do
457+ runStep list
442458 logger.Log Message " \n\n\t Build completed in %A \n " ( System.DateTime.Now - start)
443459 with
444460 | exn ->
@@ -448,7 +464,6 @@ module XakeScript =
448464 logger.Log Message " \n\n\t Build failed after running for %A \n " ( System.DateTime.Now - start)
449465 finally
450466 db.PostAndReply Storage.CloseWait
451- do Progress.Finish |> ctx.Progress.Post
452467
453468 /// <summary >
454469 /// "need" implementation
@@ -478,7 +493,7 @@ module XakeScript =
478493 type RulesBuilder ( options ) =
479494
480495 let updRules ( XakeScript ( options , rules )) f = XakeScript ( options, f( rules))
481- let updTargets ( XakeScript ( options , rules )) f = XakeScript ({ options with Want = f( options.Want )}, rules)
496+ let updTargets ( XakeScript ( options , rules )) f = XakeScript ({ options with Targets = f( options.Targets )}, rules)
482497
483498 member o.Bind ( x , f ) = f x
484499 member o.Zero () = XakeScript ( options, Rules [])
0 commit comments