-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16544 from github/redsun82/bazel-csharp-2
Bazel/C#: avoid zipmerge
- Loading branch information
Showing
3 changed files
with
48 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
load("@rules_pkg//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo") | ||
|
||
def _pkg_overlay_impl(ctx): | ||
destinations = {} | ||
files = [] | ||
depsets = [] | ||
|
||
for src in reversed(ctx.attr.srcs): | ||
pfi = src[PackageFilesInfo] | ||
dest_src_map = {k: v for k, v in pfi.dest_src_map.items() if k not in destinations} | ||
destinations.update({k: True for k in dest_src_map}) | ||
if dest_src_map: | ||
new_pfi = PackageFilesInfo( | ||
dest_src_map = dest_src_map, | ||
attributes = pfi.attributes, | ||
) | ||
files.append((new_pfi, src.label)) | ||
depsets.append(depset(dest_src_map.values())) | ||
return [ | ||
PackageFilegroupInfo( | ||
pkg_files = reversed(files), | ||
pkg_dirs = [], | ||
pkg_symlinks = [], | ||
), | ||
DefaultInfo( | ||
files = depset(transitive = reversed(depsets)), | ||
), | ||
] | ||
|
||
codeql_pkg_files_overlay = rule( | ||
implementation = _pkg_overlay_impl, | ||
doc = "Combine `pkg_files` targets so that later targets overwrite earlier ones without warnings", | ||
attrs = { | ||
# this could be updated to handle PackageFilegroupInfo as well if we ever need it | ||
"srcs": attr.label_list(providers = [PackageFilesInfo, DefaultInfo]), | ||
}, | ||
) |