0

Say I have a target A that depends on B, but I can run A and B in parallel. Is this possible with Shake? It seems like need ... makes actions sequential which totally makes sense, of course, but this is a "special" case.

insitu
  • 4,488
  • 3
  • 25
  • 42
  • Why is it safe to run `A` and `B` in parallel even though `A` depends on `B`? In what sense does it depend on `B`? – Neil Mitchell May 20 '19 at 10:19
  • (apologies for late reply) Those files go through a validation process that checks whatever is imported so if A imports B, when A is checked B will also be checked, so both "actions" can run in parallel. However, I would like to ensure that A gets "rebuilt" whenever B changes. – insitu May 23 '19 at 20:02
  • Great, sounds like a `need` at the end is sufficient - so the answer below should work. – Neil Mitchell May 24 '19 at 08:10

1 Answers1

0

Given:

"A" %> \_ -> do need ["B"]; ...
"B" %> \_ -> ...

If you do need ["A","B"] then it will start A and B in parallel, but the A action will immediately pause until B is complete. For what reason is it safe to run A and B in parallel? If the action computed by A needs to rerun when B changes, but doesn't actually use B itself you can reorder to be:

"A" %> \_ -> do ...; need ["B"]

However, if the action in A actually uses B then there is no real way to run them in parallel.

Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85