Bazel Question: `filegroup` to `declare_directory`

444 views
Skip to first unread message

Yanjun Zhu

unread,
Dec 29, 2021, 8:48:14 PM12/29/21
to bazel-discuss
Hi team,

I want to know is there any graceful way to do this transition?

Thanks!

Derek Perez

unread,
Dec 29, 2021, 8:49:19 PM12/29/21
to Yanjun Zhu, bazel-discuss
This is a public/external mailing list.

--
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/5ef446ef-6771-402f-85b8-578517a04976n%40googlegroups.com.

Yanjun Zhu

unread,
Dec 29, 2021, 8:51:15 PM12/29/21
to Derek Perez, bazel-discuss
ooops...I'm sorry...let me copy and paste the question here:

 I have a general question about how to make filegroup into a declare_directory.
So what I can think about is like,  filegroup -> pkg_tar -> untar_to_dir(A rule to untar the tarball into the declare_directory)
 
It would work, and I already proved it. However, I want to know whether any other more graceful method to avoid tar and untar the filegroup?
 
One idea I tried, but much complicated, is to copy them into the declare_directory file by file. But the tricky point is, it could not gracefully deal with keeping the same dir structure in the new dir. (like I have to mkdir a lot of sub-directory before cp)
Thanks!

Alex Eagle

unread,
Jan 2, 2022, 2:53:25 PM1/2/22
to bazel-discuss
You can just use `cp` instead of `tar`, like this rule does https://github.com/aspect-build/bazel-lib/blob/main/docs/copy_to_directory.md
it takes sources which can include filegroup, and outputs a TreeArtifact (ctx.actions_declare_directory)

Yanjun Zhu

unread,
Jan 3, 2022, 9:42:31 PM1/3/22
to Alex Eagle, bazel-discuss
nice! Thanks for sharing. Actually I finally tried this way, and it worked.

You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/5CwuRqz2LUM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/d5679048-187d-4a22-85af-996d49e5e599n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages