Skip to content

Commit b723433

Browse files
committed
enable specify nightly version
Signed-off-by: Yang Hongbo <[email protected]>
1 parent 237a43c commit b723433

File tree

4 files changed

+64
-9
lines changed

4 files changed

+64
-9
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ This will create two new recipes:
130130
release of rust itself (using the published channel data consumed by other
131131
tools like rustup).
132132

133+
For latest nightly version:
134+
135+
./build-new-version.sh nightly
136+
137+
For specified nightly version:
138+
139+
./build-new-version.sh nightly 2019-07-08
140+
141+
133142
## Copyright
134143

135144
```

build-new-version.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ if [ -z "$TARGET_VERSION" ]; then
1414
exit 1
1515
fi
1616

17+
# if NIGHTLY_DATE is empty, it should download latest nightly version
18+
NIGHTLY_DATE="$2"
19+
1720
CHANNEL_FILE="channel-rust-$TARGET_VERSION.toml"
1821

1922
TMPDIR=`mktemp -p "$PWD" -d`
@@ -52,7 +55,11 @@ download() {
5255
dlfile() {
5356
component="$1"
5457
triple="$2"
55-
download "https://static.rust-lang.org/dist/$component-$TARGET_VERSION-$triple.tar.gz"
58+
if [ x"$TARGET_VERSION" == x"nightly" -a "$NIGHTLY_DATE" ]; then
59+
download "https://static.rust-lang.org/dist/$NIGHTLY_DATE/$component-$TARGET_VERSION-$triple.tar.gz"
60+
else
61+
download "https://static.rust-lang.org/dist/$component-$TARGET_VERSION-$triple.tar.gz"
62+
fi
5663
}
5764

5865
get_md5sum() {
@@ -93,7 +100,11 @@ cargo_filename() {
93100
}
94101

95102
download_files() {
96-
download "https://static.rust-lang.org/dist/$CHANNEL_FILE"
103+
if [ x"$TARGET_VERSION" == x"nightly" -a "$NIGHTLY_DATE" ]; then
104+
download "https://static.rust-lang.org/dist/$NIGHTLY_DATE/$CHANNEL_FILE"
105+
else
106+
download "https://static.rust-lang.org/dist/$CHANNEL_FILE"
107+
fi
97108

98109
# cargo for each supported host triple
99110
for triple in "${RUSTC_TRIPLES[@]}"; do
@@ -275,7 +286,7 @@ EOF
275286
}
276287
return get_by_triple(URLS, triple)
277288
278-
DEPENDS += "rust-bin-cross-\${TARGET_ARCH} (= ${TARGET_VERSION})"
289+
DEPENDS += "rust-bin-cross-\${TARGET_ARCH} (= ${TARGET_VERSION}-${NIGHTLY_DATE})"
279290
LIC_FILES_CHKSUM = "\\
280291
file://LICENSE-APACHE;md5=${CARGO_APACHE_EXPECTED} \\
281292
file://LICENSE-MIT;md5=${CARGO_MIT_EXPECTED} \\
@@ -290,8 +301,13 @@ download_files
290301
# validate extracted cargo license
291302
check_cargo_license
292303

293-
RUST_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/rust-bin-cross_$TARGET_VERSION.bb"
294-
CARGO_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/cargo-bin-cross_$TARGET_VERSION.bb"
304+
if [ x"$TARGET_VERSION" == x"nightly" -a "$NIGHTLY_DATE" ]; then
305+
RUST_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/rust-bin-cross_${TARGET_VERSION}-${NIGHTLY_DATE}.bb"
306+
CARGO_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/cargo-bin-cross_${TARGET_VERSION}-${NIGHTLY_DATE}.bb"
307+
else
308+
RUST_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/rust-bin-cross_$TARGET_VERSION.bb"
309+
CARGO_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/cargo-bin-cross_$TARGET_VERSION.bb"
310+
fi
295311

296312
# create/clear files
297313
echo "" >"$RUST_BIN_RECIPE"

recipes-devtools/rust/cargo-bin-cross.inc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ do_install[depends] += "virtual/fakeroot-native:do_populate_sysroot"
3131

3232
python () {
3333
pv = d.getVar("PV", True)
34-
pv_uri = pv[0:4] + '-' + pv[4:6] + '-' + pv[6:8]
34+
35+
# only specified nightly needs another branch
36+
nightly = pv.startswith("nightly-")
37+
38+
if nightly:
39+
pv = "nightly"
40+
3541
target = d.getVar("CARGO_HOST_TARGET", True)
3642
cargo_uri = ("%s;md5sum=%s;sha256sum=%s;downloadname=%s" %
3743
(cargo_url(target), cargo_md5(target), cargo_sha256(target),

recipes-devtools/rust/rust-bin-cross.inc

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ RUST_BUILD_TARGET = "${@rust_target(d, 'BUILD')}"
2020
RUST_TARGET_TARGET = "${@rust_target(d, 'TARGET')}"
2121
RUST_ALL_TARGETS = "${RUST_BUILD_TARGET} ${RUST_TARGET_TARGET} ${EXTRA_RUST_TARGETS}"
2222

23-
S = "${WORKDIR}/rustc-${PV}-${RUST_BUILD_TARGET}"
23+
def get_s(d):
24+
pv = d.getVar("PV", True)
25+
nightly = pv.startswith("nightly-")
26+
27+
if nightly:
28+
return "${WORKDIR}/rustc-nightly-${RUST_BUILD_TARGET}"
29+
else:
30+
return "${WORKDIR}/rustc-${PV}-${RUST_BUILD_TARGET}"
31+
32+
S = "${@get_s(d)}"
2433

2534
# Relocating WORKDIR doesn't matter to installer
2635
S[vardepsexclude] += "WORKDIR"
@@ -55,12 +64,27 @@ do_install[depends] += "virtual/fakeroot-native:do_populate_sysroot"
5564

5665
python () {
5766
pv = d.getVar("PV", True)
67+
nightly = pv.startswith("nightly-")
68+
69+
if nightly:
70+
pv = pv.partition("-")[2]
71+
target_version = "nightly"
72+
5873
base_uri = d.getVar("RUST_BASE_URI", True)
5974
targets = d.getVar("RUST_ALL_TARGETS", True).split()
6075
build_target = d.getVar("RUST_BUILD_TARGET", True)
61-
rustc_src_uri = ("%s/dist/rustc-%s-%s.tar.gz;md5sum=%s;sha256sum=%s" %
76+
if nightly:
77+
rustc_src_uri = ("%s/dist/%s/rustc-%s-%s.tar.gz;md5sum=%s;sha256sum=%s" %
78+
(base_uri, pv, target_version, build_target, rustc_md5(build_target), rustc_sha256(build_target)))
79+
else:
80+
rustc_src_uri = ("%s/dist/rustc-%s-%s.tar.gz;md5sum=%s;sha256sum=%s" %
6281
(base_uri, pv, build_target, rustc_md5(build_target), rustc_sha256(build_target)))
63-
std_src_uris = ["%s/dist/rust-std-${PV}-%s.tar.gz;md5sum=%s;sha256sum=%s;subdir=rust-std" %
82+
83+
if nightly:
84+
std_src_uris = ["%s/dist/%s/rust-std-%s-%s.tar.gz;md5sum=%s;sha256sum=%s;subdir=rust-std" %
85+
(base_uri, pv, target_version, target, rust_std_md5(target), rust_std_sha256(target)) for target in targets]
86+
else:
87+
std_src_uris = ["%s/dist/rust-std-${PV}-%s.tar.gz;md5sum=%s;sha256sum=%s;subdir=rust-std" %
6488
(base_uri, target, rust_std_md5(target), rust_std_sha256(target)) for target in targets]
6589
src_uri = d.getVar("SRC_URI", True).split()
6690
d.setVar("SRC_URI", ' '.join(src_uri + [rustc_src_uri] + std_src_uris))

0 commit comments

Comments
 (0)