Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 929: #931

Merged
merged 1 commit into from
Aug 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions src/app/FakeLib/TargetHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ let PrintTargets() =
let private withDependencyType (depType:DependencyType) targets =
targets |> List.map (fun t -> depType, t)

// Helper function for visiting targets in a dependency tree
// Helper function for visiting targets in a dependency tree. Retutrns a set containing the names of the all the
// visited targets, and a list containing the targets visited ordered such that dependencies of a target appear earlier
// in the list than the target.
let private visitDependencies fVisit targetName =
let visit fGetDependencies fVisit targetName =
let visited = new HashSet<_>()
Expand All @@ -353,17 +355,17 @@ let private visitDependencies fVisit targetName =
// First pass is to accumulate targets in (hard) dependency graph
let visited, _ = visit (fun t -> t.Dependencies |> withDependencyType DependencyType.Hard) (fun _ -> ()) targetName

let getDependencies (t: TargetTemplate<unit>) =
if visited.Contains t.Name then
(t.Dependencies |> withDependencyType DependencyType.Hard) @
(t.SoftDependencies |> List.filter visited.Contains |> withDependencyType DependencyType.Soft)
else
t.Dependencies |> withDependencyType DependencyType.Hard

// Now make second pass, adding in soft depencencies if approrpriate
visit getDependencies fVisit targetName
let getAllDependencies (t: TargetTemplate<unit>) =
(t.Dependencies |> withDependencyType DependencyType.Hard) @
// Note that we only include the soft dependency if it is present in the set of targets that were
// visited.
(t.SoftDependencies |> List.filter visited.Contains |> withDependencyType DependencyType.Soft)

// Now make second pass, adding in soft depencencies if appropriate
visit getAllDependencies fVisit targetName



/// <summary>Writes a dependency graph.</summary>
/// <param name="verbose">Whether to print verbose output or not.</param>
/// <param name="target">The target for which the dependencies should be printed.</param>
Expand Down Expand Up @@ -515,21 +517,25 @@ let run targetName =
let parallelJobs = environVarOrDefault "parallel-jobs" "1" |> int

// Figure out the order in in which targets can be run, and which can be run in parallel.
let order = determineBuildOrder targetName

if parallelJobs > 1 then
tracefn "Running parallel build with %d workers" parallelJobs

// determine a parallel build order
let order = determineBuildOrder targetName

// run every level in parallel
for par in order do
runTargetsParallel parallelJobs par

else
// single threaded build. We flatten out the groupings of targets that determineBuildOrder
// returns, since we don't care about parallel execution.
// single threaded build.
PrintDependencyGraph false targetName
let flattenedOrder = order |> Seq.collect id |> Seq.toArray
runTargets flattenedOrder

// Note: we could use the ordering resulting from flattening the result of determineBuildOrder
// for a single threaded build (thereby centralizing the algorithm for build order), but that
// ordering is inconsistent with earlier versions of FAKE (and PrintDependencyGraph).
let _, ordered = visitDependencies ignore targetName
runTargets (ordered |> Seq.map getTarget |> Seq.toArray)

finally
if errors <> [] then
Expand Down