You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bazel-discuss
Hi,
Is it possible to read source files (that is, the files in parameter 'srcs') and use their contents in a Starlark rule?
We are writing rules for a proprietary DSL. Some information about dependencies are defined in the source files, and we wonder if will need to duplicate this information in our rules.
Thanks,
Magnus
Paul Johnston
unread,
Nov 14, 2019, 8:27:46 PM11/14/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bazel-discuss
To my knowledge, not in a *build rule*. However, a *repository rule* can do arbitrary things that could include reading source files and generating starlark, which could then be consumed by build rules.
Austin Schuh
unread,
Nov 17, 2019, 12:41:26 AM11/17/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Paul Johnston, bazel-discuss
Magnus,
rules_go solves this problem with gazelle if you are looking for prior art.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Austin Schuh, Paul Johnston, bazel-discuss
To expand on this, gazelle is an extensible build file generating tool. It has built-in support for Go and proto, and it can be extended to generate rules for other languages.
In the rule implementation though, there's no way to access contents of source files. Only actions declared by rules may access files.