Tarball Extraction DyncDep issue

48 views
Skip to first unread message

Muni Chandra

unread,
Nov 24, 2021, 2:21:48 AM11/24/21
to ninja-build
Hi,

As shown in the below build ninja content , we see two rules untar and scantar, followed by two build statements . Would like to know if this can be achieved with single build statement ?

rule untar
  command = tar xf $in && touch $out
rule scantar
  command = scantar --stamp=$stamp --dd=$out $in
build foo.tar.dd: scantar foo.tar
  stamp = foo.tar.stamp
build foo.tar.stamp: untar foo.tar || foo.tar.dd
  dyndep = foo.tar.dd


Holger Lamm

unread,
Nov 24, 2021, 8:44:50 AM11/24/21
to ninja-build
What we actually want to solve:

We have a code generator that is expensive to run, but running it is the only way to find out what it will generate.
If one of the outputs would be deleted, we have to re-run the generator; this is how we came to dyndeps and the "untar" example, which addresses this issue.

In the "untar" example, you have two rules; the inexpensive "scantar" that predicts what will be generated, and the expensive "untar" rule actually doing it.
We have no other prediction than running the generator, so:
- scantar could do the same as untar, and will both be expensive. Now the generator is run twice on the first ninja run.
- having "scantar" rule write a dummy .dd file; the actual content is updated when executing the "untar" rule.
But this update makes the rule dirty for the second run, since new inplicit outputs have come up.

Any idea how to have the generator only run once?

Best regards,
Holger
Reply all
Reply to author
Forward
0 new messages