Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FAKE patterns to separate target build order from dependencies

In VS there is usually a distinction between Build (incremental) and Rebuild, where the latter would first clean but then do the same as Build. Can I provide similar behavior with FAKE?

Let's assume the following targets:

Target "Clean" DoNothing
Target "Work" DoNothing
Target "All" DoNothing

RunTargetOrDefault "All"

Normally I want to run all of them, Clean before Work, so I end up with:

"Clean" ==> "Work" ==> "All"

However, Work is not really depending on Clean - it is only that if both are to be run, Clean must run first. With the dependency chain above, I cannot run Work without Clean being run first. Is there way or common pattern to support this?

What I've considered so far:

A)

"Clean" ==> "All"
"Work" ==> "All"

This correctly represents the dependencies from All, but the order that Clean should be before Work - if both are run - is missing.

B)

Target "WorkOnly" DoNothing
"WorkOnly" ==> "Work"
"Clean" ==> "Work" ==> "All"

This is a bit closer, but it still does not guarantee that when building All that Clean will run before WorkOnly

C)

Target "Start" DoNothing
"Start"
  =?> ("Clean", not (hasBuildParam "noclean"))
  ==> "Work"
  ==> "All"

This way, Clean would always run, except when I specify "noclean" as parameter. This seems to fully support my scenario and is actually quite flexible, but can get a bit complicated if there are multiple optional phases.

Is this the intended way and how others do it as well, or am I missing something obvious?

like image 800
Christoph Rüegg Avatar asked Jan 24 '14 13:01

Christoph Rüegg


People also ask

How to run a target from a fake build?

This means you can - for example - run fake run build.fsx --list or fake build --list to list your targets. To run a target MyTarget you could use fake run build.fsx -t MyTarget or fake build target MyTarget (or the other way around fake run build.fsx target MyTarget) All parameters after -- or target <target> are given to the target as paramters.

How do I add a target dependency in Xcode?

Xcode builds all explicit dependencies before the dependent target. To introduce explicit dependency, add a new item to the “Target Dependencies” list in the target’s build phases. Figure 2. Target Dependencies Build Phase. 1 - Add or remove items.

What is the difference between teardown and build failure targets?

Final targets can be used for TearDown functionality. These targets will be executed even if the build fails but have to be activated via Target.ActivateFinal (). Build failure targets can be used to execute tasks after a build failure. These targets will be executed only after a build failure but have to be activated via activateBuildFailure ().

How do I build unlocked packages with complex dependencies?

There are two general approaches to building unlocked packages with complex dependencies: building org-dependent unlocked packages (which are tightly coupled to an installing organization) or building loosely coupled unlocked packages and designing to manage dependencies.


2 Answers

No, there is no operator for this at the moment. You might want to create a pull request with a new operator.

We also have a prototype implementation for a future target dependency runtime. You can also try to add a new operator there.

like image 24
forki23 Avatar answered Oct 28 '22 20:10

forki23


I'm a bit late to the party.... But I've recently run into this kind of requirement myself.

I finally settled on the following:

  • All tasks are independent
  • Create multiple end state targets that define different dependencies.

In your case that would leave you with

Target "Clean" DoNothing
Target "Work" DoNothing
Target "Build" (fun _ ->
    Run "Work"
)
Target "Rebuild" (fun _ ->
    "Clean"
        ==> "Work"

    Run "Work"
)
like image 178
pms1969 Avatar answered Oct 28 '22 20:10

pms1969