fakedrake
fakedrake

Reputation: 6856

Stack cache builds with various flags

I have two different build commands that I use for my project

stack build -j8 --profile

and

stack build -j8  --ghc-options -DVERBOSE_SOLVING

There are hundreds of files in my projects. Whenever I change from one to the other command everything is rebuilt. Is there a way to keep the build increments of both?

Upvotes: 2

Views: 114

Answers (1)

Fyodor Soikin
Fyodor Soikin

Reputation: 80744

You can tell stack where to keep the cache via --work-dir. The default is <project root>/.stack-work, but you can specify separate directories for your different build modes:

stack build -j8 --profile --work-dir .stack-work-profile

stack build -j8 --ghc-options -DVERBOSE_SOLVING --work-dir .stack-work-verbose-solving

I don't think there is a way to have stack automatically figure out different caches based on flags. If you really need this, you could whip up a script that would take a hash of the flag combination and redirect work-dir to .stack-work-<hash> or something.

Upvotes: 2

Related Questions