Search code examples
haskellshake-build-system

"One-way" dependencies in shake-build?


My brain might be fried right now (have been hacking on this Shakefile for 3 days straight), but I just can't figure out how to express a "one-way" dependency in Shake?

I am building (generating) hundreds of HTML files, and for them to work properly, they need one common CSS file to be generated. If I say something like...

"**.rst" %> \out -> do
  need [cssFile, templateFile]
  -- compile RST => HTML

... it results in ALL HTML files being re-built if the common CSS file changes!

How do I express the following in shake:

  • if x is built, make sure y is also built
  • however, if y changes, x does NOT need to be re-built.

Solution

  • You might be looking for orderOnly, from the docs:

    Define order-only dependencies, these are dependencies that will always be built before continuing, but which aren't dependencies of this action. Mostly useful for defining generated dependencies you think might be real dependencies. If they turn out to be real dependencies, you should add an explicit dependency afterwards.

    It doesn't perfectly match what you are after (you don't really need it to be built before the rule continues), but it should be close enough for what you want.