-
Notifications
You must be signed in to change notification settings - Fork 1.2k
build: consume Dash Platform CXX bindings from depends #7623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
0773caf
c2321d1
e0c5aed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Copyright (c) 2026 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| export LC_ALL=C.UTF-8 | ||
|
|
||
| # Builds depends with PLATFORM_GUI=1 so mbedtls and the Platform-owned CXX | ||
| # binding archive (libdash_platform_cxx.a, built offline from vendored crates) | ||
| # are produced, hash-verified and installed into the depends prefix, then | ||
| # builds dash-qt against that prefix. The --enable-platform-gui configure flag | ||
| # and the platform_* unit-test suites arrive with the Platform client library | ||
| # and are added to BITCOIN_CONFIG there; until then this lane proves the | ||
| # depends knob end to end and that the enriched prefix stays link-compatible. | ||
| # Functional tests are skipped: there is no dashd-only surface to drive. | ||
| export CONTAINER_NAME=ci_native_platform_gui | ||
| export HOST=x86_64-pc-linux-gnu | ||
| export PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libdbus-1-dev libharfbuzz-dev" | ||
| export DEP_OPTS="PLATFORM_GUI=1" | ||
| export RUN_UNIT_TESTS="true" | ||
| export RUN_UNIT_TESTS_SEQUENTIAL="false" | ||
| export RUN_FUNCTIONAL_TESTS="false" | ||
| export GOAL="install" | ||
| export BITCOIN_CONFIG="--with-gui=qt5 --enable-zmq --with-libs=no --enable-reduce-exports LDFLAGS=-static-libstdc++" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Copyright (c) 2021-2022 The Zcash developers | ||
| # Copyright (c) 2026 The Dash Core developers | ||
| # Distributed under the MIT software license, see the accompanying | ||
| # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| import hashlib | ||
| import re | ||
| import sys | ||
| import urllib.request | ||
| from pathlib import Path | ||
|
|
||
| # Rust standard libraries provisioned in rust_stdlib.mk. Confined to the | ||
| # hosts we validate (the Guix release set); see rust_stdlib.mk. | ||
| CROSS_TARGETS = [ | ||
| # Linux | ||
| "aarch64-unknown-linux-musl", | ||
| "riscv64gc-unknown-linux-musl", | ||
| "x86_64-unknown-linux-musl", | ||
| # Windows | ||
| "x86_64-pc-windows-gnu", | ||
| # macOS | ||
| "aarch64-apple-darwin", | ||
| "x86_64-apple-darwin", | ||
| ] | ||
|
|
||
| # Native compilers provisioned in native_rust.mk (build hosts for depends) | ||
| NATIVE_TARGETS = [ | ||
| # Linux | ||
| ("aarch64-unknown-linux-gnu", "aarch64_linux"), | ||
| ("x86_64-unknown-linux-gnu", "x86_64_linux"), | ||
| # macOS | ||
| ("aarch64-apple-darwin", "aarch64_darwin"), | ||
| ("x86_64-apple-darwin", "x86_64_darwin"), | ||
| ] | ||
|
|
||
|
|
||
| def get_rust_version(makefile_path: Path) -> str: | ||
| content = makefile_path.read_text() | ||
| match = re.search(r"\$\(package\)_version:=(.+)", content) | ||
| if not match: | ||
| raise RuntimeError("Could not find Rust version in makefile") | ||
| return match.group(1).strip() | ||
|
|
||
|
|
||
| def compute_sha256(url: str) -> str: | ||
| hasher = hashlib.sha256() | ||
| with urllib.request.urlopen(url) as response: | ||
| while chunk := response.read(8192): | ||
| hasher.update(chunk) | ||
| return hasher.hexdigest() | ||
|
|
||
|
|
||
| def update_hash_in_file(makefile_path: Path, pattern: str, new_hash: str) -> None: | ||
| content = makefile_path.read_text() | ||
| regex = re.compile(rf"^(\$\(package\)_{pattern}:=).*$", re.MULTILINE) | ||
| if not regex.search(content): | ||
| raise RuntimeError(f"Could not find pattern {pattern} in makefile") | ||
| new_content = regex.sub(rf"\g<1>{new_hash}", content) | ||
| makefile_path.write_text(new_content) | ||
|
|
||
|
|
||
| def update_version_in_file(path: Path, pattern: str, version: str) -> None: | ||
| content = path.read_text() | ||
| regex = re.compile(pattern, re.MULTILINE) | ||
| new_content, replacements = regex.subn( | ||
| lambda match: f"{match.group(1)}{version}{match.group(2) if match.lastindex == 2 else ''}", content | ||
| ) | ||
| if replacements != 1: | ||
| raise RuntimeError(f"Expected one version pin in {path}, found {replacements}") | ||
| path.write_text(new_content) | ||
|
|
||
|
|
||
| def compute_rust_hash(rust_version: str, rust_target: str) -> str: | ||
| url = f"https://static.rust-lang.org/dist/rust-{rust_version}-{rust_target}.tar.gz" | ||
| return compute_sha256(url) | ||
|
|
||
|
|
||
| def compute_stdlib_hash(rust_version: str, rust_target: str) -> str: | ||
| url = f"https://static.rust-lang.org/dist/rust-std-{rust_version}-{rust_target}.tar.gz" | ||
| return compute_sha256(url) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| script_dir = Path(__file__).resolve().parent | ||
| native_rust_path = script_dir / "../../depends/packages/native_rust.mk" | ||
| native_rust_path = native_rust_path.resolve() | ||
| rust_stdlib_path = script_dir / "../../depends/packages/rust_stdlib.mk" | ||
| rust_stdlib_path = rust_stdlib_path.resolve() | ||
| toolchain_path = (script_dir / "../../rust-toolchain.toml").resolve() | ||
| configure_path = (script_dir / "../../configure.ac").resolve() | ||
|
|
||
| for path in (native_rust_path, rust_stdlib_path, toolchain_path, configure_path): | ||
| if not path.exists(): | ||
| print(f"Error: {path} not found", file=sys.stderr) | ||
| return 1 | ||
|
Comment on lines
+91
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Do not require absent Rust consumer files The updater always exits here because this revision has no repository-level source: ['codex'] |
||
|
|
||
| rust_version = get_rust_version(native_rust_path) | ||
|
|
||
| print(f"Rust version: {rust_version}\n") | ||
| print("Downloading native compiler hashes:") | ||
|
|
||
| native_hashes = {} | ||
| for rust_target, makefile_id in NATIVE_TARGETS: | ||
| native_hashes[makefile_id] = compute_rust_hash(rust_version, rust_target) | ||
| print(f" Downloaded sha256_hash_{makefile_id}") | ||
|
|
||
| print("\nDownloading stdlib hashes:") | ||
| stdlib_hashes = {} | ||
| for rust_target in CROSS_TARGETS: | ||
| stdlib_hashes[rust_target] = compute_stdlib_hash(rust_version, rust_target) | ||
| print(f" Downloaded sha256_hash_{rust_target}") | ||
|
|
||
| for makefile_id, hash_value in native_hashes.items(): | ||
| update_hash_in_file(native_rust_path, f"sha256_hash_{makefile_id}", hash_value) | ||
| for rust_target, hash_value in stdlib_hashes.items(): | ||
| update_hash_in_file(rust_stdlib_path, f"sha256_hash_{rust_target}", hash_value) | ||
|
|
||
| update_version_in_file(rust_stdlib_path, r"^(\$\(package\)_version:=).*$", rust_version) | ||
| update_version_in_file(toolchain_path, r'^(channel = ")[^"]*(")$', rust_version) | ||
| update_version_in_file(configure_path, r'^(RUSTC_REQUIRED_VERSION=")[^"]*(")$', rust_version) | ||
| print("\nSynchronized rust_stdlib.mk, rust-toolchain.toml, and configure.ac") | ||
|
|
||
| print("\nDone!") | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the newly documented
contrib/devtools/update-rust-hashes.pyin this commit always exits here because the repository contains norust-toolchain.toml;configure.acalso has noRUSTC_REQUIRED_VERSIONassignment for the later update. As a result, maintainers cannot use the script to update either of the Rust depends pins it was added to maintain. Limit synchronization to files present in this change, or add the expected consumer files before making them mandatory.Useful? React with 👍 / 👎.