-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to emit *.runfiles_manifest as JSON
The *.runfiles_manifest files currently use a pretty simple format: two pathnames separated by a space character. This can be problematic at times. On Windows, usernames may contain spaces, meaning home directories with spaces are not uncommon. If you look at the macOS ecosystem, it's also not uncommon to have applications or packages containing files with spaces in their names. The goal of this change is to start addressing this issue, by moving *.runfiles_manifest to newline delimited JSON. Runfiles libraries for each programming language will need to be adjusted to support this new format. Because not all runfiles libraries are bundled/versioned together with Bazel, those libraries will need to seamlessly support both formats. Tuples are encoded as lists, JSON entries will always start with an opening square bracket. Because paths are generally prefixed with a workspace name, it's extremely unlikely that this causes any conflict. Runfiles libraries can thus distinguish both formats as follows: if (line[0] == '[') { // Parse as JSON. } else { // Parse as legacy format. } To prevent any breakage, we place this feature behind a flag named --incompatible_json_source_manifests. Even if this flag is disabled, we emit JSON entries for paths that are not representable in the legacy format. This should at least make it possible to build targets and instantiate their runfiles directories with build-runfiles, regardless of whether the manifest can be parsed at runtime. Before considering JSON, I experimented with CSV instead. Though easier to parse, RFC 4180 requires the use of carriage return newlines. Because both Bazel and runfiles libraries tend to open runfiles manifests in text mode, this turned out to be hard to get right. Given the fact that Bazel does not permit non-printable characters and backslashes in pathnames, parsing the resulting JSON turns out to be remarkably easy. If it's not realistic to let a given runfiles library depend on a third-party library to do the JSON parsing, it's most likely acceptable to handroll a simplified parser. This PR already contains updates to build-runfiles, the Bash runfiles library and the Python runfiles library to support the new format. Updates to the C++ and Java runfiles libraries remain to be done. Issue: #4327
- Loading branch information
1 parent
464bac3
commit 2ec1149
Showing
13 changed files
with
236 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.