summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorAlex Kiernan <alex.kiernan@gmail.com>2023-01-30 14:01:40 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-02 10:27:30 +0000
commitc79127dcb17dc2ab4ebb8f07a86e33b02cec5bdb (patch)
treedc36c7a3e5256481a925a64d28d0554b041cb36a /meta/recipes-devtools
parent96c105622915a5a3176a559b09beb7af05e0aeea (diff)
downloadpoky-c79127dcb17dc2ab4ebb8f07a86e33b02cec5bdb.tar.gz
rust: Add `update_snapshot` task to generate `rust-snapshot.inc`
Everything we need for `rust-snapshot.inc` exists in `src/stage0.json`, so just read that to generate it. (From OE-Core rev: a07008da8b02165d271a457e4c215f35cb15b94c) Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/rust/rust_1.67.0.bb60
1 files changed, 60 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/rust_1.67.0.bb b/meta/recipes-devtools/rust/rust_1.67.0.bb
index 60f3daf464..2118faec8f 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() {
289 rm ${D}${libdir}/rustlib/manifest* 289 rm ${D}${libdir}/rustlib/manifest*
290} 290}
291 291
292addtask do_update_snapshot after do_patch
293do_update_snapshot[nostamp] = "1"
294
295# Run with `bitbake -c update_snapshot rust` to update `rust-snapshot.inc`
296# with the checksums for the rust snapshot associated with this rustc-src
297# tarball.
298python do_update_snapshot() {
299 import json
300 import re
301 import sys
302
303 from collections import defaultdict
304
305 with open(os.path.join(d.getVar("S"), "src", "stage0.json")) as f:
306 j = json.load(f)
307
308 config_dist_server = j['config']['dist_server']
309 compiler_date = j['compiler']['date']
310 compiler_version = j['compiler']['version']
311
312 src_uri = defaultdict(list)
313 for k, v in j['checksums_sha256'].items():
314 m = re.search(f"dist/{compiler_date}/(?P<component>.*)-{compiler_version}-(?P<arch>.*)-unknown-linux-gnu\\.tar\\.xz", k)
315 if m:
316 component = m.group('component')
317 arch = m.group('arch')
318 src_uri[arch].append(f"SRC_URI[{component}-snapshot-{arch}.sha256sum] = \"{v}\"")
319
320 snapshot = """\
321## This is information on the rust-snapshot (binary) used to build our current release.
322## snapshot info is taken from rust/src/stage0.json
323## Rust is self-hosting and bootstraps itself with a pre-built previous version of itself.
324## The exact (previous) version that has been used is specified in the source tarball.
325## The version is replicated here.
326
327SNAPSHOT_VERSION = "%s"
328
329""" % compiler_version
330
331 for arch, components in src_uri.items():
332 snapshot += "\n".join(components) + "\n\n"
333
334 snapshot += """\
335SRC_URI += " \\
336 ${RUST_DIST_SERVER}/dist/${RUST_STD_SNAPSHOT}.tar.xz;name=rust-std-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\
337 ${RUST_DIST_SERVER}/dist/${RUSTC_SNAPSHOT}.tar.xz;name=rustc-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\
338 ${RUST_DIST_SERVER}/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\
339"
340
341RUST_DIST_SERVER = "%s"
342
343RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
344RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
345CARGO_SNAPSHOT = "cargo-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
346""" % config_dist_server
347
348 with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f:
349 f.write(snapshot)
350}
351
292RUSTLIB_DEP:class-nativesdk = "" 352RUSTLIB_DEP:class-nativesdk = ""
293 353
294# musl builds include libunwind.a 354# musl builds include libunwind.a