Temporary folder for action?

1,528 views
Skip to first unread message

Derek Perez

unread,
Jul 30, 2017, 11:18:22 PM7/30/17
to bazel-discuss
Is there a way in bazel to create a random temporary folder that is deleted when a target is finished being built?

Marcel Hlopko

unread,
Jul 31, 2017, 5:38:57 AM7/31/17
to Derek Perez, bazel-discuss, laur...@google.com
In a custom skylark rule? +Laurent Le Brun 

On Mon, Jul 31, 2017 at 5:18 AM Derek Perez <de...@perez.earth> wrote:
Is there a way in bazel to create a random temporary folder that is deleted when a target is finished being built?

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAD7-yft3VZ3G4F9wbVGvXshYW9HW3o6quEoQDbFqB3%2BVOx03bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
-- 
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle | Registergericht und -nummer: Hamburg, HRB 86891

Dmitry Lomov

unread,
Jul 31, 2017, 7:03:18 AM7/31/17
to Marcel Hlopko, Derek Perez, bazel-discuss, laur...@google.com
On Mon, Jul 31, 2017 at 11:38 AM, 'Marcel Hlopko' via bazel-discuss <bazel-...@googlegroups.com> wrote:
In a custom skylark rule? +Laurent Le Brun 

On Mon, Jul 31, 2017 at 5:18 AM Derek Perez <de...@perez.earth> wrote:
Is there a way in bazel to create a random temporary folder that is deleted when a target is finished being built?

No. Why do you need that?
In general, every file a rule creates is declared using ctx.actions.declare_file.
Bazel keeps all intermediate files to be as incremental as it can.

--
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.
--
-- 
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle | Registergericht und -nummer: Hamburg, HRB 86891

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAFuL9Gkp%2BJMjmZR8Vs0-SLKpcBiGr746T-r5-EAoqOJR%3DgM%2BSw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Google Germany GmbH
Erika-Mann-Straße 33, 80636 München, Germany

Derek Perez

unread,
Jul 31, 2017, 11:36:48 PM7/31/17
to Dmitry Lomov, Marcel Hlopko, bazel-discuss, laur...@google.com
I am using this http://www.benf.org/other/cfr/ which has an --outputdir flag that generates a subtree that mirrors the classes it finds in a given jar. I then want to zip those up into a single output artifact, but I don't need to keep the cfr output dir tree.

What is the best way to do this?

On Mon, Jul 31, 2017 at 4:03 AM Dmitry Lomov <dsl...@google.com> wrote:
On Mon, Jul 31, 2017 at 11:38 AM, 'Marcel Hlopko' via bazel-discuss <bazel-...@googlegroups.com> wrote:
In a custom skylark rule? +Laurent Le Brun 

On Mon, Jul 31, 2017 at 5:18 AM Derek Perez <de...@perez.earth> wrote:
Is there a way in bazel to create a random temporary folder that is deleted when a target is finished being built?

No. Why do you need that?
In general, every file a rule creates is declared using ctx.actions.declare_file.
Bazel keeps all intermediate files to be as incremental as it can.

--
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.
--
-- 
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle | Registergericht und -nummer: Hamburg, HRB 86891

--
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.

Austin Schuh

unread,
Jul 31, 2017, 11:42:49 PM7/31/17
to Derek Perez, Dmitry Lomov, Marcel Hlopko, bazel-discuss, laur...@google.com
mktemp -d ?  Blow it away when you are done, though the sandbox should (or can be configured) to map a tmpfs to /tmp/ so it goes away automatically.

Austin

Derek Perez

unread,
Jul 31, 2017, 11:52:17 PM7/31/17
to Austin Schuh, Dmitry Lomov, Marcel Hlopko, bazel-discuss, laur...@google.com
OK That should be fine, Just wasn't sure if we had a better strategy that was builtin. I'm noticing sandboxing on MacOS is resulting in the files surviving across builds without explicitly rming the dir.

Austin Schuh

unread,
Aug 1, 2017, 12:03:57 AM8/1/17
to Derek Perez, Dmitry Lomov, Marcel Hlopko, bazel-discuss, laur...@google.com
That is expected with sandboxing disabled.  Probably best to create the temporary data in ${TMPDIR} to be OS agnostic rather than /tmp/.

Austin

Dmitry Lomov

unread,
Aug 1, 2017, 3:27:36 AM8/1/17
to Derek Perez, Marcel Hlopko, bazel-discuss, laur...@google.com
On Tue, Aug 1, 2017 at 5:36 AM, Derek Perez <de...@perez.earth> wrote:
I am using this http://www.benf.org/other/cfr/ which has an --outputdir flag that generates a subtree that mirrors the classes it finds in a given jar. I then want to zip those up into a single output artifact, but I don't need to keep the cfr output dir tree.

What is the best way to do this?

Another avenue you can try is ctx.actions.declare_directory. 

On Mon, Jul 31, 2017 at 4:03 AM Dmitry Lomov <dsl...@google.com> wrote:
On Mon, Jul 31, 2017 at 11:38 AM, 'Marcel Hlopko' via bazel-discuss <bazel-discuss@googlegroups.com> wrote:
In a custom skylark rule? +Laurent Le Brun 

On Mon, Jul 31, 2017 at 5:18 AM Derek Perez <de...@perez.earth> wrote:
Is there a way in bazel to create a random temporary folder that is deleted when a target is finished being built?

No. Why do you need that?
In general, every file a rule creates is declared using ctx.actions.declare_file.
Bazel keeps all intermediate files to be as incremental as it can.

--
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.
--
-- 
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle | Registergericht und -nummer: Hamburg, HRB 86891

--
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.

For more options, visit https://groups.google.com/d/optout.



--
Google Germany GmbH
Erika-Mann-Straße 33, 80636 München, Germany

Konstantin Solomatov

unread,
Nov 9, 2018, 6:06:55 PM11/9/18
to bazel-discuss

Another avenue you can try is ctx.actions.declare_directory. 

And how does it work? Documentation doesn't provide all explanations. I have the following questions:
  • Can other rules write there?
  • Do I understand correctly that all rules which depend on files inside of it, will depend on the rule?
Thanks,
Kostya 
Reply all
Reply to author
Forward
0 new messages