Skip to content

Commit 703fd52

Browse files
authored
Merge pull request #109 from iotpi/nightly
Added specified nightly toolchain support
2 parents f349a36 + dcb1397 commit 703fd52

File tree

4 files changed

+81
-9
lines changed

4 files changed

+81
-9
lines changed

README.md

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

135+
For latest nightly version:
136+
137+
./build-new-version.sh nightly
138+
139+
For specified nightly version:
140+
141+
./build-new-version.sh nightly 2019-07-08
142+
143+
135144
## Copyright
136145

137146
```

build-new-version.sh

Lines changed: 38 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`
@@ -44,6 +47,14 @@ RUSTC_TRIPLES=(
4447
x86_64-unknown-linux-gnu
4548
)
4649

50+
is_nightly() {
51+
if [ x"$TARGET_VERSION" == x"nightly" -a "$NIGHTLY_DATE" ]; then
52+
true
53+
else
54+
false
55+
fi
56+
}
57+
4758
download() {
4859
echo "download $@"
4960
curl --fail -# -O $@
@@ -52,7 +63,11 @@ download() {
5263
dlfile() {
5364
component="$1"
5465
triple="$2"
55-
download "https://static.rust-lang.org/dist/$component-$TARGET_VERSION-$triple.tar.gz"
66+
if is_nightly; then
67+
download "https://static.rust-lang.org/dist/$NIGHTLY_DATE/$component-$TARGET_VERSION-$triple.tar.gz"
68+
else
69+
download "https://static.rust-lang.org/dist/$component-$TARGET_VERSION-$triple.tar.gz"
70+
fi
5671
}
5772

5873
get_md5sum() {
@@ -93,7 +108,11 @@ cargo_filename() {
93108
}
94109

95110
download_files() {
96-
download "https://static.rust-lang.org/dist/$CHANNEL_FILE"
111+
if is_nightly; then
112+
download "https://static.rust-lang.org/dist/$NIGHTLY_DATE/$CHANNEL_FILE"
113+
else
114+
download "https://static.rust-lang.org/dist/$CHANNEL_FILE"
115+
fi
97116

98117
# cargo for each supported host triple
99118
for triple in "${RUSTC_TRIPLES[@]}"; do
@@ -275,7 +294,16 @@ EOF
275294
}
276295
return get_by_triple(URLS, triple)
277296
278-
DEPENDS += "rust-bin-cross-\${TARGET_ARCH} (= ${TARGET_VERSION})"
297+
EOF
298+
299+
if is_nightly; then
300+
echo >> "$CARGO_BIN_RECIPE" "DEPENDS += \"rust-bin-cross-\${TARGET_ARCH} (= ${TARGET_VERSION}-${NIGHTLY_DATE})\""
301+
else
302+
echo >> "$CARGO_BIN_RECIPE" "DEPENDS += \"rust-bin-cross-\${TARGET_ARCH} (= ${TARGET_VERSION})\""
303+
fi
304+
305+
cat <<EOF >>${CARGO_BIN_RECIPE}
306+
279307
LIC_FILES_CHKSUM = "\\
280308
file://LICENSE-APACHE;md5=${CARGO_APACHE_EXPECTED} \\
281309
file://LICENSE-MIT;md5=${CARGO_MIT_EXPECTED} \\
@@ -290,8 +318,13 @@ download_files
290318
# validate extracted cargo license
291319
check_cargo_license
292320

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"
321+
if [ x"$TARGET_VERSION" == x"nightly" -a "$NIGHTLY_DATE" ]; then
322+
RUST_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/rust-bin-cross_${TARGET_VERSION}-${NIGHTLY_DATE}.bb"
323+
CARGO_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/cargo-bin-cross_${TARGET_VERSION}-${NIGHTLY_DATE}.bb"
324+
else
325+
RUST_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/rust-bin-cross_$TARGET_VERSION.bb"
326+
CARGO_BIN_RECIPE="$ROOT_DIR/recipes-devtools/rust/cargo-bin-cross_$TARGET_VERSION.bb"
327+
fi
295328

296329
# create/clear files
297330
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)