diff --git a/misc/bazel/os.bzl b/misc/bazel/os.bzl index f8e5c13cfe1..a3fee479dbc 100644 --- a/misc/bazel/os.bzl +++ b/misc/bazel/os.bzl @@ -19,11 +19,15 @@ def codeql_platform_select( This works both in a macro context (`ctx = None`, returning a `select`) and in a rule context (passing `ctx`, which then needs `OS_DETECTION_ATTRS` on the rule attributes). """ + + def _or_otherwise(value): + return value if value != None else otherwise + choices = { - "//misc/bazel:linux_arm64": linux_arm64 or otherwise, - "@platforms//os:linux": linux64 or otherwise, - "@platforms//os:macos": osx64 or otherwise, - "@platforms//os:windows": win64 or otherwise, + "//misc/bazel:linux_arm64": _or_otherwise(linux_arm64), + "@platforms//os:linux": _or_otherwise(linux64), + "@platforms//os:macos": _or_otherwise(osx64), + "@platforms//os:windows": _or_otherwise(win64), } if not ctx: return select({ diff --git a/misc/bazel/pkg.bzl b/misc/bazel/pkg.bzl index efec21e761f..684bcbb8c3b 100644 --- a/misc/bazel/pkg.bzl +++ b/misc/bazel/pkg.bzl @@ -464,12 +464,12 @@ def codeql_pack( `zips` is a map from `.zip` files to prefixes to import. The distinction between arch-specific and common contents is made based on whether the paths (including possible prefixes added by rules) contain the special `{CODEQL_PLATFORM}` placeholder, which in case it is present will also - be replaced by the appropriate platform (`linux64`, `win64` or `osx64`). + be replaced by the appropriate platform (`linux64`, `linux-arm64`, `win64` or `osx64`). Specific file paths can be placed in the arch-specific package by adding them to `arch_overrides`, even if their path doesn't contain the `CODEQL_PLATFORM` placeholder. 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. - This placeholder will be replaced by the appropriate platform (`linux64`, `win64` or `osx64`). + This placeholder will be replaced by the appropriate platform (`linux64`, `linux-arm64`, `win64` or `osx64`). `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 contain the `{CODEQL_PLATFORM}` marker. All files in the pack will be prefixed with `name`, unless `pack_prefix` is set, then is used instead.