[7.4.0] Allow all characters in runfile source and target paths (#23912)
(contains the refactor in f311efc5 to reduce merge conflicts) Adds support for spaces and newlines in source and target paths of runfiles symlinks to `build-runfiles` as well as to the Bash, C++, and Java runfiles libraries (the Python runfiles library has moved out of the repo). If a symlink has spaces or newlines in its source path, it is prefixed with a space in the manifest and spaces, newlines, and backslashes in the source path are escaped with `\s`, `\n`, and `\b` respectively. This scheme has been chosen as it has the following properties: 1. There is no change to the format of manifest lines for entries whose source and target paths don't contain a space. This ensures compatibility with existing runfiles libraries. 2. There is even no change to the format of manifest lines for entries whose target path contains spaces but whose source path does not. These manifests previously failed in `build-runfiles`, but were usable on Windows and supported by the official runfiles libraries. This also ensures that the initialization snippet for the Bash runfiles library doesn't need to change, even when used on Unix with a space in the output base path. 3. The scheme is fully reversible and only depends on the source path, which gives runfiles libraries a choice between reversing the escaping when parsing the manifest (C++, Java) or applying the escaping when searching the manifest (Bash). Fixes https://github.com/bazelbuild/bazel/issues/4327 RELNOTES: Bazel now supports all characters in the rlocation and target paths of runfiles and can be run from workspaces with a space in their full path. Closes https://github.com/bazelbuild/bazel/pull/23331. PiperOrigin-RevId: 683362776 Change-Id: I1eb79217dcd53cef0089d62a7ba477b1d8f52c21 (cherry picked from commits https://github.com/bazelbuild/bazel/commit/7407cef3837b4fe14e48e1a925f9b886c0cc945d and f311efc5 ) Closes #23715 --------- Co-authored-by:Googler <jhorvitz@google.com>
Showing
- src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java 58 additions, 11 deletions...gle/devtools/build/lib/analysis/SourceManifestAction.java
- src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java 0 additions, 12 deletions...google/devtools/build/lib/runtime/BlazeOptionHandler.java
- src/main/protobuf/failure_details.proto 1 addition, 1 deletionsrc/main/protobuf/failure_details.proto
- src/main/tools/build-runfiles-windows.cc 51 additions, 17 deletionssrc/main/tools/build-runfiles-windows.cc
- src/main/tools/build-runfiles.cc 52 additions, 8 deletionssrc/main/tools/build-runfiles.cc
- src/test/java/com/google/devtools/build/lib/analysis/BUILD 1 addition, 1 deletionsrc/test/java/com/google/devtools/build/lib/analysis/BUILD
- src/test/java/com/google/devtools/build/lib/analysis/SourceManifestActionTest.java 117 additions, 45 deletions...devtools/build/lib/analysis/SourceManifestActionTest.java
- src/test/shell/bazel/bazel_determinism_test.sh 2 additions, 1 deletionsrc/test/shell/bazel/bazel_determinism_test.sh
- src/test/shell/bazel/workspace_test.sh 1 addition, 1 deletionsrc/test/shell/bazel/workspace_test.sh
- src/test/shell/integration/runfiles_test.sh 268 additions, 0 deletionssrc/test/shell/integration/runfiles_test.sh
- tools/bash/runfiles/runfiles.bash 44 additions, 2 deletionstools/bash/runfiles/runfiles.bash
- tools/bash/runfiles/runfiles_test.bash 34 additions, 1 deletiontools/bash/runfiles/runfiles_test.bash
- tools/cpp/runfiles/runfiles_src.cc 64 additions, 10 deletionstools/cpp/runfiles/runfiles_src.cc
- tools/cpp/runfiles/runfiles_test.cc 19 additions, 2 deletionstools/cpp/runfiles/runfiles_test.cc
- tools/java/runfiles/Runfiles.java 29 additions, 4 deletionstools/java/runfiles/Runfiles.java
- tools/java/runfiles/testing/RunfilesTest.java 13 additions, 4 deletionstools/java/runfiles/testing/RunfilesTest.java
Please register or sign in to comment