Skip to content

Replace copy genrules with copy_file - #30122

Closed
dzbarsky wants to merge 0 commit into
bazelbuild:masterfrom
dzbarsky:codex/replace-copy-genrules
Closed

Replace copy genrules with copy_file#30122
dzbarsky wants to merge 0 commit into
bazelbuild:masterfrom
dzbarsky:codex/replace-copy-genrules

Conversation

@dzbarsky

@dzbarsky dzbarsky commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace copy-only genrule targets with bazel_skylib copy_file targets for:

  • Bazel executable .exe aliases
  • the builtins zip resource redirect
  • the Starlark CPU profiler JNI library alias
  • JNI header and native library aliases

Each target permits symlinking, so copy_file creates a declared symlink action instead of invoking an ambient cp executable through a shell. This PR contains no third-party patch or dependency update.

This focused change is extracted from #30121 for independent review.

Motivation

The existing genrule targets assume the execution environment provides cp and a compatible shell. That assumption fails when Bazel runs on Windows while actions execute remotely on Linux. The dedicated copy_file rule also states the operation directly and removes repeated command strings.

Build API Changes

No.

Validation

  • buildifier -mode=check src/BUILD src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD src/main/java/net/starlark/java/eval/BUILD src/main/native/BUILD
  • bazel aquery confirmed the expected Symlink or ExecutableSymlink action, input, and output for all nine generated targets
  • bazel build --jobs=2 //src/main/java/com/google/devtools/build/lib/bazel/rules:builtins_bzl_zip //src/main/java/net/starlark/java/eval:cpu_profiler_jni_darwin //src/main/native:copy_link_jni_header //src/main/native:copy_link_jni_md_header //src/main/native:mac-compat

Release Notes

RELNOTES: None

@dzbarsky
dzbarsky marked this pull request as ready for review July 21, 2026 12:57
@github-actions github-actions Bot added team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel awaiting-review PR is awaiting review from an assigned reviewer labels Jul 21, 2026
@dzbarsky dzbarsky closed this Jul 21, 2026
@dzbarsky
dzbarsky force-pushed the codex/replace-copy-genrules branch from 83c9b66 to 69f9ae8 Compare July 21, 2026 13:03
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant