Skip to content

Commit 6b97161

Browse files
committed
Bazel: rename _process_path to _expand_path, and make its use clearer
1 parent 76fbb52 commit 6b97161

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

misc/bazel/pkg.bzl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _PLAT_DETECTION_ATTRS = {
2121

2222
_PLAT_PLACEHOLDER = "{CODEQL_PLATFORM}"
2323

24-
def _process_path(path, platform):
24+
def _expand_path(path, platform):
2525
if _PLAT_PLACEHOLDER in path:
2626
path = path.replace(_PLAT_PLACEHOLDER, platform)
2727
return ("arch", path)
@@ -89,9 +89,9 @@ def _extract_pkg_filegroup_impl(ctx):
8989
for pfi, origin in src.pkg_files:
9090
dest_src_map = {}
9191
for dest, file in pfi.dest_src_map.items():
92-
file_kind, dest = _process_path(dest, platform)
92+
file_kind, expanded_dest = _expand_path(dest, platform)
9393
if file_kind == ctx.attr.kind:
94-
dest_src_map[dest] = file
94+
dest_src_map[expanded_dest] = file
9595
if dest_src_map:
9696
pkg_files.append((PackageFilesInfo(dest_src_map = dest_src_map, attributes = pfi.attributes), origin))
9797

@@ -124,9 +124,10 @@ def _imported_zips_manifest_impl(ctx):
124124
manifest = []
125125
files = []
126126
for zip, prefix in ctx.attr.zips.items():
127-
_, prefix = _process_path(prefix, platform)
127+
# we don't care about the kind here, as we're taking all zips together
128+
_, expanded_prefix = _expand_path(prefix, platform)
128129
zip_files = zip.files.to_list()
129-
manifest += ["%s:%s" % (prefix, f.short_path) for f in zip_files]
130+
manifest += ["%s:%s" % (expanded_prefix, f.short_path) for f in zip_files]
130131
files += zip_files
131132

132133
output = ctx.actions.declare_file(ctx.label.name + ".params")
@@ -158,9 +159,9 @@ def _zipmerge_impl(ctx):
158159
output = ctx.actions.declare_file(filename)
159160
args = [output.path, "--prefix=%s" % ctx.attr.zip_prefix, ctx.file.base.path]
160161
for zip, prefix in ctx.attr.zips.items():
161-
zip_kind, prefix = _process_path(prefix, platform)
162+
zip_kind, expanded_prefix = _expand_path(prefix, platform)
162163
if zip_kind == ctx.attr.kind:
163-
args.append("--prefix=%s/%s" % (ctx.attr.zip_prefix, prefix.rstrip("/")))
164+
args.append("--prefix=%s/%s" % (ctx.attr.zip_prefix, expanded_prefix.rstrip("/")))
164165
args += [f.path for f in zip.files.to_list()]
165166
zips.append(zip.files)
166167
ctx.actions.run(

0 commit comments

Comments
 (0)