Generated file persistence

296 views
Skip to first unread message

balas...@gmail.com

unread,
Mar 30, 2015, 2:07:24 AM3/30/15
to bazel-...@googlegroups.com
Hi,

I wrote a custom `latex_pdf' rule to compile some documentation in our project. It looks something like this: https://gist.github.com/balasanjay/efc7a59d658aef6533d2

pdflatex will generate some extra files during compilation. The Makefile I wrote for this purpose deleted and recreated the output directory to ensure that intermediate files don't leak between compilations.

So, I was wondering: does bazel clean up intermediate files from previous executions before running the command again?

Thanks,
Sanjay

Ulf Adams

unread,
Mar 30, 2015, 9:07:53 AM3/30/15
to balas...@gmail.com, bazel-...@googlegroups.com
Hi Sanjay,

yes and no. Bazel cleans up the output files that it knows about before it runs an action. However:

Back at University I also had my own Makefile for use with pdflatex & bibtex. I seem to remember that it was very painful to make it work properly (especially for incremental builds), because of how these tools work. I ended up writing some wrappers to make it slightly less painful.

Deleting and recreating the output directory seems the best thing you can do, but I expect it to be painful with Bazel as well. If you have any magic sauce to make it better, I'd be interested to hear about it.

Cheers,

-- Ulf


--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To post to this group, send email to bazel-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/ee00303a-6a2b-441a-b518-b15de7d10217%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Han-Wen Nienhuys

unread,
Mar 31, 2015, 6:55:53 AM3/31/15
to balas...@gmail.com, bazel-...@googlegroups.com
On Mon, Mar 30, 2015 at 8:07 AM, <balas...@gmail.com> wrote:
> Hi,
>
> I wrote a custom `latex_pdf' rule to compile some documentation in our project. It looks something like this: https://gist.github.com/balasanjay/efc7a59d658aef6533d2

to get an output directory, rather than stripping the filename from
your output, I'd recommend to do this:

output_dir = ctx.outputs.output_pdf.path + ".dir"

otherwise, your rule wil share output dirs if there are 2 .tex files
in the same directory.

You can do

"rm -rf %s && mkdir -p %s" % (output_dir, output_dir)

to create the directory.

> pdflatex will generate some extra files during compilation. The Makefile I wrote for this purpose deleted and recreated the output directory to ensure that intermediate files don't leak between compilations.
>
> So, I was wondering: does bazel clean up intermediate files from previous executions before running the command again?
>
> Thanks,
> Sanjay
>
> --
> You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
> To post to this group, send email to bazel-...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/ee00303a-6a2b-441a-b518-b15de7d10217%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Han-Wen Nienhuys
Google Munich
han...@google.com

Sanjay Menakuru

unread,
Mar 31, 2015, 2:02:28 PM3/31/15
to Han-Wen Nienhuys, bazel-...@googlegroups.com

No magic sauce unfortunately. I'll switch to deleting and creating an output directory with a suffix.

Thanks for your help,
Sanjay


On Tue, Mar 31, 2015, 06:55 Han-Wen Nienhuys <han...@google.com> wrote:
On Mon, Mar 30, 2015 at 8:07 AM,  <balas...@gmail.com> wrote:
> Hi,
>
> I wrote a custom `latex_pdf' rule to compile some documentation in our project. It looks something like this: https://gist.github.com/balasanjay/efc7a59d658aef6533d2

to get an output directory, rather than stripping the filename from
your output, I'd recommend to do this:

  output_dir = ctx.outputs.output_pdf.path + ".dir"

otherwise, your rule wil share output dirs if there are 2 .tex files
in the same directory.

You can do

 "rm -rf %s && mkdir -p %s" % (output_dir, output_dir)

to create the directory.

> pdflatex will generate some extra files during compilation. The Makefile I wrote for this purpose deleted and recreated the output directory to ensure that intermediate files don't leak between compilations.
>
> So, I was wondering: does bazel clean up intermediate files from previous executions before running the command again?
>
> Thanks,
> Sanjay
>
> --
> You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages