[prev in list] [next in list] [prev in thread] [next in thread]
List: openembedded-core
Subject: [OE-Core][PATCH] rust: Add `update_snapshot` task to generate `rust-snapshot.inc`
From: "Alex Kiernan" <alex.kiernan () gmail ! com>
Date: 2023-01-30 14:01:40
Message-ID: 20230130140140.9883-1-alex.kiernan () gmail ! com
[Download RAW message or body]
Content-Transfer-Encoding: 8bit
Everything we need for `rust-snapshot.inc` exists in `src/stage0.json`,
so just read that to generate it.
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---
meta/recipes-devtools/rust/rust_1.67.0.bb | 60 +++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/meta/recipes-devtools/rust/rust_1.67.0.bb \
b/meta/recipes-devtools/rust/rust_1.67.0.bb index f4ac8bc6350b..148e60153996 100644
--- a/meta/recipes-devtools/rust/rust_1.67.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.67.0.bb
@@ -289,6 +289,66 @@ rust_do_install:class-target() {
rm ${D}${libdir}/rustlib/manifest*
}
+addtask do_update_snapshot after do_patch
+do_update_snapshot[nostamp] = "1"
+
+# Run with `bitbake -c update_snapshot rust` to update `rust-snapshot.inc`
+# with the checksums for the rust snapshot associated with this rustc-src
+# tarball.
+python do_update_snapshot() {
+ import json
+ import re
+ import sys
+
+ from collections import defaultdict
+
+ with open(os.path.join(d.getVar("S"), "src", "stage0.json")) as f:
+ j = json.load(f)
+
+ config_dist_server = j['config']['dist_server']
+ compiler_date = j['compiler']['date']
+ compiler_version = j['compiler']['version']
+
+ src_uri = defaultdict(list)
+ for k, v in j['checksums_sha256'].items():
+ m = re.search(f"dist/{compiler_date}/(?P<component>.*)-{compiler_version}-(?P<arch>.*)-unknown-linux-gnu\\.tar\\.xz", \
k) + if m:
+ component = m.group('component')
+ arch = m.group('arch')
+ src_uri[arch].append(f"SRC_URI[{component}-snapshot-{arch}.sha256sum] = \
\"{v}\"") +
+ snapshot = """\
+## This is information on the rust-snapshot (binary) used to build our current \
release. +## snapshot info is taken from rust/src/stage0.json
+## Rust is self-hosting and bootstraps itself with a pre-built previous version of \
itself. +## The exact (previous) version that has been used is specified in the \
source tarball. +## The version is replicated here.
+
+SNAPSHOT_VERSION = "%s"
+
+""" % compiler_version
+
+ for arch, components in src_uri.items():
+ snapshot += "\n".join(components) + "\n\n"
+
+ snapshot += """\
+SRC_URI += " \\
+ ${RUST_DIST_SERVER}/dist/${RUST_STD_SNAPSHOT}.tar.xz;name=rust-std-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \
\\ + ${RUST_DIST_SERVER}/dist/${RUSTC_SNAPSHOT}.tar.xz;name=rustc-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \
\\ + ${RUST_DIST_SERVER}/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \
\\ +"
+
+RUST_DIST_SERVER = "%s"
+
+RUST_STD_SNAPSHOT = \
"rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUSTC_SNAPSHOT = \
"rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +CARGO_SNAPSHOT = \
"cargo-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +""" % \
config_dist_server +
+ with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f:
+ f.write(snapshot)
+}
+
RUSTLIB_DEP:class-nativesdk = ""
# musl builds include libunwind.a
--
2.39.0
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#176494): https://lists.openembedded.org/g/openembedded-core/message/176494
Mute This Topic: https://lists.openembedded.org/mt/96628078/4454766
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [openembedded-core@marc.info]
-=-=-=-=-=-=-=-=-=-=-=-
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic