-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add compile_data argument for data required at compile time #516
Conversation
Nit: maybe |
Build was my first choice actually, but I thought it might be confused with the cargo build script functionality, and the tool we're calling is 'rustc' rather than 'rustb' :-) |
I think because in these rules https://github.com/bazelbuild/rules_rust/blob/master/cargo/cargo_build_script.bzl handles the |
I don't feel strongly about it, but think compile might be the slightly better choice - there are various direct and indirect (eg rustc_flags) references to compiling already, and build feels more like it's talking about the building process as a whole more than a single step. |
Maybe |
Maybe someone else can chime in with their thoughts? I went looking for precedent, but there doesn't appear to be much. The Java/Scala rules use 'resources' which I presume is a Javarism, and Go has a separate rule for embedding data rather than an argument to an existing rule. |
Yeah, more thoughts sound good. And yeah, I think Java (gradle?) has it's own terminology. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally agree with the feature being necessary, so that part looks good to me. In terms of the name, the best reference I would have for this is textual_hdrs, so I would lean towards That would indicate to me:
|
This seems less discoverable than |
I find textual_data a bit confusing - it makes me think of text-based data , rather than data being referenced by source code. The user may want to include binary data with include_bytes!(), and textual_data may not be obvious in that case. textual_srcs also seems to be inconsistent with srcs, as only .rs files are accepted for the latter, and this feature would be useful for more than just include!() |
I agree that
Though honestly I think I'm happy enough with |
compile_data seems clear enough. |
I've rebased this on master, and the subsequent change to cargo raze is waiting over on google/cargo-raze#308 |
Are there any examples on how this would get practically used? I'm currently trying to include the output of bindgen, passing it through |
There are some examples in https://github.com/bazelbuild/rules_rust/blob/dd7e458de8d6921f274ee91664b326460d5d9d4c/examples/env_locations/BUILD - in short, you need to set an environment variable using the |
Using the existing data argument for build-time data dependencies causes the files to also show up in the runfiles. This can be seen when using rules_docker's rust_image() for example - the files are included in the image twice; once in the binary and once in their original form.
If this is accepted I'll send through a PR to cargo-raze to expose this for third-party crates similar to data_attr.
Closes #222