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
feature request: repository_ctx.copy #11858
Comments
The Java implementation of Starlark has no datatype capable of holding byte strings, so A copy function seems reasonable, but I have very little experience with the repository_rule API; someone more knowledgeable should review it. Tony? @aiuto |
@guibou, as a workaround for the lack of the copy API, you can use the following to copy binary files without corrupting them.
However, it may not be efficient in case of very large files. |
I would also appreciate if this feature could be added, it would be a better way of copying binary files. |
@mai93 Thank you for your workaround. Is there a way to "copy" the executable flag of the source file, instead of setting it unconditionally at |
This closes #136 `repository_ctx` is meant to work on "text" files and does text encoding and decoding, which breaks in the context of a binary file. There is no `cp` API in repository_ctx, as suggested in bazelbuild/bazel#11858, but bazelbuild/bazel#11857 suggested to use this approach with `repository_ctx.file`.
I've found how to copy the executable bit, see https://github.com/tweag/rules_nixpkgs/pull/161/files |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
@bazelbuild/triage not stale |
Description of the problem / feature request:
I'd like a
repository_ctx.copy
function, to copy file. I'm currently usingrepository_ctx.template
, but that's an abuse of the API and it does not work with binariy files: #11857Feature requests: what underlying problem are you trying to solve with this feature?
Coping file in repository rules. I can use
execute(["cp", ...)
, but acopy
api can be more convenient and more robust as it does not depend on the availability of acp
command.The text was updated successfully, but these errors were encountered: