Skip to content

Commit f63b850

Browse files
paldepindCopilot
andcommitted
Build: Support architecture overrides for imported ZIP archives
Allow imported ZIP prefixes in arch_overrides so native dependencies can be distributed separately from architecture-independent files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9f12f7cb-26aa-405b-a1f0-9dcc239778cb
1 parent 079a05f commit f63b850

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎misc/bazel/pkg.bzl‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CodeQLPackInfo = provider(
8484
"pack_prefix": "A prefix to add to all paths, IF the user requests so. We omit it for local installation targets of single packs (but not pack groups)",
8585
"files": "PackageFilegroupInfo provider with list of all files in this pack (CODEQL_PLATFORM in paths unresolved)",
8686
"zips": "A _ZipInfo provider to include in the pack, (CODEQL_PLATFORM unresolved).",
87-
"arch_overrides": "A list of files that should be included in the arch-specific bit, even though the path doesn't contain CODEQL_PLATFORM.",
87+
"arch_overrides": "Files or imported zip prefixes to include in the arch-specific bit, even without CODEQL_PLATFORM in their paths.",
8888
},
8989
)
9090

@@ -220,7 +220,7 @@ _codeql_pack_info = rule(
220220
allow_files = [".zip"],
221221
),
222222
"prefix": attr.string(doc = "Prefix to add to all files."),
223-
"arch_overrides": attr.string_list(doc = "A list of files that should be included in the arch package regardless of the path, specify the path _without_ `prefix`."),
223+
"arch_overrides": attr.string_list(doc = "Files or imported zip prefixes to include in the arch package regardless of the path, specified _without_ `prefix`."),
224224
},
225225
provides = [CodeQLPackInfo],
226226
)
@@ -293,6 +293,8 @@ def _codeql_pack_group_extract_zips_impl(ctx):
293293
# for each zip file, resolve whether it's filtered out or not by the current kind, and add the pack prefix
294294
for zip, zip_prefix in src.zips.zips_to_prefixes.items():
295295
zip_kind, expanded_prefix = _expand_path(paths.join(prefix, zip_prefix), platform)
296+
if zip_kind == "common" and zip_prefix in src.arch_overrides:
297+
zip_kind = "arch"
296298
if include_all_files or zip_kind == ctx.attr.kind:
297299
zips_to_prefixes[zip] = expanded_prefix
298300

@@ -465,13 +467,13 @@ def codeql_pack(
465467
The distinction between arch-specific and common contents is made based on whether the paths (including possible
466468
prefixes added by rules) contain the special `{CODEQL_PLATFORM}` placeholder, which in case it is present will also
467469
be replaced by the appropriate platform (`linux64`, `linux-arm64`, `win64` or `osx64`).
468-
Specific file paths can be placed in the arch-specific package by adding them to `arch_overrides`, even if their
469-
path doesn't contain the `CODEQL_PLATFORM` placeholder.
470+
Specific file paths or imported zip prefixes can be placed in the arch-specific package by adding them to
471+
`arch_overrides`, even if their path doesn't contain the `CODEQL_PLATFORM` placeholder.
470472
471473
The codeql pack rules will expand the `{CODEQL_PLATFORM}` marker in paths, and use that to split the files into a common and an arch-specific part.
472474
This placeholder will be replaced by the appropriate platform (`linux64`, `linux-arm64`, `win64` or `osx64`).
473-
`arch_overrides` is a list of files that should be included in the arch-specific bits of the pack, even if their path doesn't
474-
contain the `{CODEQL_PLATFORM}` marker.
475+
`arch_overrides` is a list of files or imported zip prefixes that should be included in the arch-specific bits of the
476+
pack, even if their path doesn't contain the `{CODEQL_PLATFORM}` marker.
475477
All files in the pack will be prefixed with `name`, unless `pack_prefix` is set, then is used instead.
476478
477479
This rule also provides a convenient installer target named `<name>-installer`, with a path governed by `install_dest`,

0 commit comments

Comments
 (0)