From 79a25ed4a606ed929b149a6e6bdbb2c65b620fd7 Mon Sep 17 00:00:00 2001 From: Martin Kuntz Jacobsen Date: Sat, 14 Nov 2026 04:46:51 +0100 Subject: [PATCH] qt: toolchain keeps its own 7-Zip extractor, host cell and cell settings (part of #12608) Drops core:seven_zip, core:host and core:platform_support loads from qt toolchain repos.bzl and pins.bzl. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xut2hws3L7Tg4oUvpSvuYD --- qt/private/cells.bzl | 4 +- qt/private/toolchain/BUILD.bazel | 2 + qt/private/toolchain/pins.bzl | 2 +- qt/private/toolchain/repos.bzl | 6 +-- qt/private/toolchain/seven_zip.bzl | 73 +++++++++++++++++++++++++++ tools/ci/rule_set_loads_allowlist.txt | 4 +- 6 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 qt/private/toolchain/seven_zip.bzl diff --git a/qt/private/cells.bzl b/qt/private/cells.bzl index 4b6d902d9f..197d74c9fe 100644 --- a/qt/private/cells.bzl +++ b/qt/private/cells.bzl @@ -1,7 +1,7 @@ """Qualified Qt cells as target compatibility and consumer archive settings.""" load("//qt/private/toolchain:pins.bzl", "CELLS", "IDENTITIES") -load("//qt/private/toolchain:repos.bzl", "PLATFORM_SUPPORT", "qualified_cells") +load("//qt/private/toolchain:repos.bzl", "qualified_cells") def qt_consumer_identity(cell): """Returns the consumer_archive arch, os and min_runtime of one qualified Qt cell.""" @@ -19,7 +19,7 @@ _INCOMPATIBLE = Label("@platforms//:incompatible") _UNSUPPORTED = Label("//qt/private:unsupported") QT_COMPATIBLE_WITH = select( - {setting: [] for setting in PLATFORM_SUPPORT.settings} | + {setting: [] for setting in [_cell_setting(cell) for cell in sorted(CELLS)]} | {"//conditions:default": [_INCOMPATIBLE, _UNSUPPORTED]}, ) diff --git a/qt/private/toolchain/BUILD.bazel b/qt/private/toolchain/BUILD.bazel index 4b4123a566..653fb7376d 100644 --- a/qt/private/toolchain/BUILD.bazel +++ b/qt/private/toolchain/BUILD.bazel @@ -19,6 +19,7 @@ exports_files([ "needs.bzl", "pins.bzl", "repos.bzl", + "seven_zip.bzl", "tool.bzl", "unsupported.bzl", "windows_arm64.bzl", @@ -56,6 +57,7 @@ real_source_target( "needs.bzl", "pins.bzl", "repos.bzl", + "seven_zip.bzl", "tool.bzl", "unsupported.bzl", "windows_arm64.bzl", diff --git a/qt/private/toolchain/pins.bzl b/qt/private/toolchain/pins.bzl index 183913afc0..68c025168e 100644 --- a/qt/private/toolchain/pins.bzl +++ b/qt/private/toolchain/pins.bzl @@ -1,7 +1,7 @@ """Pinned Qt SDK, runtime closure and extractor identities; versions, mirrors and license texts are in pins.json.""" load("@dx_pins_data//:pins.bzl", "DATA") -load("//core:seven_zip.bzl", "SEVEN_ZIP_EXTRACTORS") +load(":seven_zip.bzl", "SEVEN_ZIP_EXTRACTORS") load(":layout_linux.bzl", LINUX_LAYOUT = "LAYOUT") load(":layout_macos.bzl", MACOS_LAYOUT = "LAYOUT") load(":layout_windows.bzl", WINDOWS_LAYOUT = "LAYOUT") diff --git a/qt/private/toolchain/repos.bzl b/qt/private/toolchain/repos.bzl index 066f878750..81f363ec8d 100644 --- a/qt/private/toolchain/repos.bzl +++ b/qt/private/toolchain/repos.bzl @@ -1,9 +1,6 @@ """Opt-in hermetic Qt SDK acquisition.""" load("//cc/private/toolchain:pins.bzl", "VC_REDIST_VERSION") -load("//core:host.bzl", "host_cell_of") -load("//core:platform_support.bzl", "cells_support", "lang_cells") -load("//core:seven_zip.bzl", "seven_zip_fetch") load( ":pins.bzl", "CELLS", @@ -17,6 +14,7 @@ load( "RUNTIME_MIRROR", "RUNTIME_REPOSITORIES", ) +load(":seven_zip.bzl", "host_cell_of", "seven_zip_fetch") HUB_NAME = "dx_qt" @@ -140,8 +138,6 @@ def qualified_cells(cells = CELLS): """Returns the cells with pinned archives and probe evidence.""" return [cell for cell in sorted(cells.keys()) if cells[cell].blocker == ""] -PLATFORM_SUPPORT = cells_support("//qt:defs.bzl", "QT_COMPATIBLE_WITH", CELLS, lang_cells("qt"), "//qt/private", "constraints", settings = {cell: Label("//qt/private/platforms:cell_" + cell) for cell in CELLS}) - def hub_targets(): """Returns every target name the hub repository exposes.""" names = list(SHARED_TARGETS) diff --git a/qt/private/toolchain/seven_zip.bzl b/qt/private/toolchain/seven_zip.bzl new file mode 100644 index 0000000000..ec2f93fb90 --- /dev/null +++ b/qt/private/toolchain/seven_zip.bzl @@ -0,0 +1,73 @@ +"""Pinned 7-Zip extractors that unpack the Qt SDK .7z archives.""" + +_OSES = {"linux": "linux", "mac os x": "macos"} + +_ARCHES = {"aarch64": "arm64", "amd64": "x86_64", "arm64": "arm64", "x86_64": "x86_64"} + +_RELEASE = "https://github.com/ip7z/7zip/releases/download/26.06/" + +_WINDOWS = struct( + archive = None, + binary = "7zr.exe", + sha256 = "e80db2dad715a6c5adabe292d31ed54e11f4e9b99ca349827b50573b175891bc", + url = _RELEASE + "7zr.exe", +) + +SEVEN_ZIP_EXTRACTORS = { + "linux_arm64": struct( + archive = "7z2606-linux-arm64.tar.xz", + binary = "7zzs", + sha256 = "edcc408aacce77da5223728f2eceb5e9f6dc713b8a9df934ad21e2a7f7560627", + url = _RELEASE + "7z2606-linux-arm64.tar.xz", + ), + "linux_x86_64": struct( + archive = "7z2606-linux-x64.tar.xz", + binary = "7zzs", + sha256 = "2b539cf067b2ad48e1baa5093dbaa8818b73542d1222a0ffde9dc5f2922ea62e", + url = _RELEASE + "7z2606-linux-x64.tar.xz", + ), + "macos_arm64": struct( + archive = "7z2606-mac.tar.xz", + binary = "7zz", + sha256 = "b6f17920b4240940461dac8ef4009891881ac44d2a5ead625ede2ec8472185dd", + url = _RELEASE + "7z2606-mac.tar.xz", + ), + "windows_arm64": _WINDOWS, + "windows_x86_64": _WINDOWS, +} + +def host_cell_of(os_name, arch): + """Returns `linux|macos|windows` + `_` + `x86_64|arm64` from Bazel's os name and arch.""" + name = os_name.lower() + name = "windows" if name.startswith("windows") else _OSES.get(name, name) + return name + "_" + _ARCHES.get(arch, arch) + +def seven_zip_fetch(rctx, output): + """Downloads the pinned extractor of the repository host into output and returns its path.""" + host = host_cell_of(rctx.os.name, rctx.os.arch) + if host not in SEVEN_ZIP_EXTRACTORS: + fail("the pinned 7-Zip extractor runs on " + ", ".join(sorted(SEVEN_ZIP_EXTRACTORS.keys())) + " hosts only, not " + rctx.os.name + " " + rctx.os.arch) + extractor = SEVEN_ZIP_EXTRACTORS[host] + canonical_id = "dx-7zip:" + extractor.url + if extractor.archive == None: + rctx.download( + url = extractor.url, + output = output + "/" + extractor.binary, + sha256 = extractor.sha256, + executable = True, + canonical_id = canonical_id, + ) + else: + rctx.download_and_extract( + url = extractor.url, + output = output, + sha256 = extractor.sha256, + canonical_id = canonical_id, + ) + return str(rctx.path(output + "/" + extractor.binary)) + +def seven_zip_extract(rctx, binary, archive, output, args = []): + """Extracts one .7z archive into output with the fetched extractor, failing with its output.""" + result = rctx.execute([binary, "x", "-y", "-bd", "-o" + output] + args + [str(archive)]) + if result.return_code != 0: + fail("cannot extract '" + str(archive) + "': " + result.stdout + result.stderr) diff --git a/tools/ci/rule_set_loads_allowlist.txt b/tools/ci/rule_set_loads_allowlist.txt index cbe11a9e20..98c051117d 100644 --- a/tools/ci/rule_set_loads_allowlist.txt +++ b/tools/ci/rule_set_loads_allowlist.txt @@ -22,6 +22,6 @@ qt/private/platforms/BUILD.bazel foreign-load 1 qt/private/rust/BUILD.bazel foreign-load 1 qt/private/toolchain/BUILD.bazel foreign-load 2 qt/private/toolchain/cell_json.bzl foreign-load 2 -qt/private/toolchain/pins.bzl foreign-load 2 -qt/private/toolchain/repos.bzl foreign-load 4 +qt/private/toolchain/pins.bzl foreign-load 1 +qt/private/toolchain/repos.bzl foreign-load 1 qt/private/toolchain/tool.bzl foreign-load 2