Skip to content
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

copy_file allows directories as well #323

Closed
wants to merge 1 commit into from

Conversation

alexeagle
Copy link
Contributor

Fixes #322

@google-cla google-cla bot added the cla: yes label Oct 9, 2021
@alexeagle alexeagle force-pushed the copy_directory branch 4 times, most recently from 4e86ba4 to bbd442b Compare October 9, 2021 19:51
alexeagle added a commit to bazel-contrib/rules_nodejs that referenced this pull request Oct 10, 2021
bazelbuild/bazel-skylib#323 is patched into our vendored copy of copy_file rule.
That lets a tsc action run with just four inputs: [a.ts, bazel-out/host/bin/external/npm_typescript-3.5.3/out,
external/bazel_tools/tools/genrule/genrule-setup.sh, external/node16_linux_amd64/bin/nodejs/bin/node]

This is obviously not ergonomic for users yet, just a step in the right direction.
alexeagle added a commit to bazel-contrib/rules_nodejs that referenced this pull request Oct 10, 2021
bazelbuild/bazel-skylib#323 is patched into our vendored copy of copy_file rule.
That lets a tsc action run with just four inputs: [a.ts, bazel-out/host/bin/external/npm_typescript-3.5.3/out,
external/bazel_tools/tools/genrule/genrule-setup.sh, external/node16_linux_amd64/bin/nodejs/bin/node]

This is obviously not ergonomic for users yet, just a step in the right direction.
alexeagle added a commit to bazel-contrib/rules_nodejs that referenced this pull request Oct 11, 2021
bazelbuild/bazel-skylib#323 is patched into our vendored copy of copy_file rule.
That lets a tsc action run with just four inputs: [a.ts, bazel-out/host/bin/external/npm_typescript-3.5.3/out,
external/bazel_tools/tools/genrule/genrule-setup.sh, external/node16_linux_amd64/bin/nodejs/bin/node]

This is obviously not ergonomic for users yet, just a step in the right direction.
alexeagle added a commit to bazel-contrib/rules_nodejs that referenced this pull request Oct 11, 2021
bazelbuild/bazel-skylib#323 is patched into our vendored copy of copy_file rule.
That lets an action run with minimal inputs.

This is obviously not ergonomic for users yet, just a step in the right direction.
alexeagle added a commit to bazel-contrib/rules_nodejs that referenced this pull request Oct 11, 2021
bazelbuild/bazel-skylib#323 is patched into our vendored copy of copy_file rule.
That lets an action run with minimal inputs.

This is obviously not ergonomic for users yet, just a step in the right direction.
alexeagle added a commit to bazel-contrib/rules_nodejs that referenced this pull request Oct 11, 2021
bazelbuild/bazel-skylib#323 is patched into our vendored copy of copy_file rule.
That lets an action run with minimal inputs.

This is obviously not ergonomic for users yet, just a step in the right direction.
@lencioni
Copy link

@brandjon @tetromino do you have any feedback on this PR? I believe this will help unblock using rules_nodejs with remote build execution, which would be really nice to see!

@alexeagle
Copy link
Contributor Author

Ping! Is anyone triaging PRs in this repo?
If not we'll probably switch rules_nodejs to use https://github.com/aspect-build/bazel-lib where we can get fixes like this.

# https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/copy
# https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy
if dst.is_directory:
cmd_tmpl = "@xcopy \"%s\" \"%s\\\" /V /E /H /Y /Q >NUL"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use /v for xcopy, but not for copy?

Why delete the destination directory in the bash version, but not in the Windows version?

Copy link
Collaborator

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall - looks good; thank you for the patch!

However, I would prefer a separate copy_directory rule: less confusing name (files aren't directories), no confusing interaction between is_directory and allow_symlinks flags, more noticeable documentation of -DBAZEL_TRACK_SOURCE_DIRECTORIES.

The one new test is insufficient. Scenarios we'd probably want to test:

  • copying an empty directory
  • copying a directory whose content includes a symlink
  • copying a directory to a location which is an existing file
  • copying a directory to a location which is an existing directory

@alexeagle
Copy link
Contributor Author

replaced by #366

@alexeagle alexeagle closed this Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

copy_file doesn't work for directories
3 participants