diff mbox series

[1/4] rust: Move RUST_DIST_SERVER to rust-config.inc

Message ID 20231230154953.8135-1-alex.kiernan@gmail.com
State New
Headers show
Series [1/4] rust: Move RUST_DIST_SERVER to rust-config.inc | expand

Commit Message

Alex Kiernan Dec. 30, 2023, 3:49 p.m. UTC
Overriding the location of RUST_DIST_SERVER is useful for testing rust
pre-releases, but we need it in rust-source and rust-snapshot; move
RUST_DIST_SERVER to rust-config.inc so we can set it to
`dev-static.rust-lang.org` and use it from both locations.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

 meta/recipes-devtools/rust/rust-config.inc   |  1 +
 meta/recipes-devtools/rust/rust-snapshot.inc |  2 --
 meta/recipes-devtools/rust/rust-source.inc   |  4 +++-
 meta/recipes-devtools/rust/rust_1.74.1.bb    | 11 ++++++++---
 4 files changed, 12 insertions(+), 6 deletions(-)
 create mode 100644 meta/recipes-devtools/rust/rust-config.inc
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/rust-config.inc b/meta/recipes-devtools/rust/rust-config.inc
new file mode 100644
index 000000000000..9fd360616bc4
--- /dev/null
+++ b/meta/recipes-devtools/rust/rust-config.inc
@@ -0,0 +1 @@ 
+RUST_DIST_SERVER ??= "https://static.rust-lang.org"
diff --git a/meta/recipes-devtools/rust/rust-snapshot.inc b/meta/recipes-devtools/rust/rust-snapshot.inc
index ffc1aed2957c..b67e42d27063 100644
--- a/meta/recipes-devtools/rust/rust-snapshot.inc
+++ b/meta/recipes-devtools/rust/rust-snapshot.inc
@@ -52,8 +52,6 @@  SRC_URI += " \
     ${RUST_DIST_SERVER}/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \
 "
 
-RUST_DIST_SERVER = "https://static.rust-lang.org"
-
 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"
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 83a0dbc15fae..fdac009c6d20 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -1,6 +1,8 @@ 
+require rust-config.inc
+
 RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}"
 
-SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust \
+SRC_URI += "${RUST_DIST_SERVER}/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust \
             file://hardcodepaths.patch;patchdir=${RUSTSRC} \
             file://0001-Don-t-use-LFS64-symbols-on-musl.patch;patchdir=${RUSTSRC} \
             file://zlib-off64_t.patch;patchdir=${RUSTSRC} \
diff --git a/meta/recipes-devtools/rust/rust_1.74.1.bb b/meta/recipes-devtools/rust/rust_1.74.1.bb
index 30543ada7dbc..dd931a42717c 100644
--- a/meta/recipes-devtools/rust/rust_1.74.1.bb
+++ b/meta/recipes-devtools/rust/rust_1.74.1.bb
@@ -316,6 +316,10 @@  python do_update_snapshot() {
             arch = m.group('arch')
             src_uri[arch].append(f"SRC_URI[{component}-snapshot-{arch}.sha256sum] = \"{v}\"")
 
+    config = """\
+RUST_DIST_SERVER ??= "%s"
+""" % config_dist_server
+
     snapshot = """\
 ## This is information on the rust-snapshot (binary) used to build our current release.
 ## snapshot info is taken from rust/src/stage0.json
@@ -337,12 +341,13 @@  SRC_URI += " \\
     ${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-config.inc"), "w") as f:
+        f.write(config)
 
     with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f:
         f.write(snapshot)