Input Negation or Set Subtraction?
I'm trying to convert images to both .eps and .pdf format. This works fine, until one of my input images is .eps or .pdf and I end up with errors where Tup is trying to create files that already exist. That is, if I have these rules:
: foreach *.eps |> epstopdf %f %o |> %B.pdf
: foreach *.pdf |> pdftoeps %f %o |> %B.eps
I get an error if I have an .eps file as a source image because the first rule creates a .pdf and then the second rule picks up the new .pdf in the glob and tries to regenerate the .eps, causing an error.
Is there a way to exclude the output of one rule in the input of another? I'm imagining something like:
: foreach *.eps |> epstopdf %f %o |> %B.pdf {pdfs}
: foreach *.pdf !{pdfs} |> pdftoeps %f %o |> %B.eps
- or -
: foreach *.pdf -{pdfs} |> pdftoeps %f %o |> %B.eps
Right now I'm using a run script to generate both the to-pdf and to-eps rules at the same time, so the output of the first rule isn't a problem.
Thanks, Brad
On Tue, Apr 16, 2013 at 3:26 PM, Brad Campbell [email protected]:
I'm trying to convert images to both .eps and .pdf format. This works fine, until one of my input images is .eps or .pdf and I end up with errors where Tup is trying to create files that already exist. That is, if I have these rules:
: foreach *.eps |> epstopdf %f %o |> %B.pdf : foreach *.pdf |> pdftoeps %f %o |> %B.eps
I get an error if I have an .eps file as a source image because the first rule creates a .pdf and then the second rule picks up the new .pdf in the glob and tries to regenerate the .eps, causing an error.
Is there a way to exclude the output of one rule in the input of another? I'm imagining something like:
: foreach *.eps |> epstopdf %f %o |> %B.pdf {pdfs} : foreach *.pdf !{pdfs} |> pdftoeps %f %o |> %B.eps
- or - : foreach *.pdf -{pdfs} |> pdftoeps %f %o |> %B.eps
Right now I'm using a run script to generate both the to-pdf and to-eps rules at the same time, so the output of the first rule isn't a problem.
Thanks, Brad
There isn't a way to to subtraction, but I think you can use an empty command to put the "original" pdfs in a {bin}. I don't think this is a properly tested/advertised feature (only t3017 uses it, I believe), so let me know if you experience any problems with it:
: foreach *.pdf |> |> {pdfs} : foreach *.eps |> epstopdf %f %o |> %B.pdf : foreach {pdfs} |> pdftoeps %f %o |> %B.eps
Tup doesn't actually store or run the empty command - it's just a parser trick to get the list of pdfs in the bin {pdfs}.
-Mike
Worked like a charm. Thanks.
I know this is an old issue, but I'm trying to find a way to reproduce this behavior with the lua parser and having a lot of trouble. Is this feature supported in lua, and if so, is there an example anywhere?