-
Notifications
You must be signed in to change notification settings - Fork 366
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
Add support for overlay in source.json #2046
Conversation
* Add support for overlay key in source.json * Automatically set BUILD.bazel and MODULE.bazel in the overlay key rather than creating patches for them. * Remove validation for MODULE.bazel in patches as this is no longer needed. Tested by building a new version of asio at 1.29.0 done locally. ```json { "url": "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-29-0.zip", "integrity": "sha256-RaeWfpu/6LevQE2urtS5IU/WY77wCtT1LDySOZKXRFs=", "overlay": { "MODULE.bazel": "sha256-GC9+wtNSPwyvW68p87iJ3AZSNJw9fm96hU0/CFnyfWg=", "BUILD.bazel": "sha256-+XSYvh+c3DMc1ypmCpO423qgidC0BnlH5stG+aRipBo=" }, "strip_prefix": "asio-asio-1-29-0/asio/include", "patch_strip": 0 } ``` ```console $ ../bazel/bazel-bin/src/bazel-dev build @asio//:asio --registry="file:///workspaces/bazel-central-registry" INFO: Analyzed target @@asio~//:asio (70 packages loaded, 940 targets configured). INFO: Found 1 target... Target @@asio~//:asio up-to-date (nothing to build) INFO: Elapsed time: 2.772s, Critical Path: 0.07s INFO: 1 process: 1 internal. INFO: Build completed successfully, 1 total action ```
This comment was marked as outdated.
This comment was marked as outdated.
source_module_dot_bazel = source_root.joinpath("MODULE.bazel") | ||
if source_module_dot_bazel.exists(): | ||
source_module_dot_bazel_content = open(source_module_dot_bazel, "r").readlines() | ||
else: | ||
source_module_dot_bazel_content = [] | ||
bcr_module_dot_bazel_content = open(self.registry.get_module_dot_bazel_path(module_name, version), "r").readlines() | ||
source_module_dot_bazel_content = fix_line_endings(source_module_dot_bazel_content) | ||
bcr_module_dot_bazel_content = fix_line_endings(bcr_module_dot_bazel_content) | ||
file_name = "a/" * int(source.get("patch_strip", 0)) + "MODULE.bazel" | ||
diff = list(unified_diff(source_module_dot_bazel_content, bcr_module_dot_bazel_content, fromfile=file_name, tofile=file_name)) | ||
|
||
if diff: | ||
self.report(BcrValidationResult.FAILED, | ||
"Checked in MODULE.bazel file doesn't match the one in the extracted and patched sources.\n" | ||
+ f"Please fix the MODULE.bazel file or you can add the following patch to {module_name}@{version}:\n" | ||
+ " " + " ".join(diff)) | ||
if self.should_fix: | ||
self.add_module_dot_bazel_patch(diff, module_name, version) | ||
else: | ||
self.report(BcrValidationResult.GOOD, "Checked in MODULE.bazel matches the sources.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we expect all new versions to include overlay -- I think it's simpler to remove this functionality entirely.
We don't need to support it for older versions as they are already "validated"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's reasonable to assume that all new versions will only support Bazel 7.2.0+.
Closing in favor of #2249 |
Tested by building a new version of asio at 1.29.0 done locally.
This change requires bazel#22349
fixed #1566