22set -euxo
33source config.sh
44
5+ HOST_ARCH=" $( rustc -vV | sed -nE ' s/host: (.*)/\1/p' ) "
6+
57# The built toolchain that we are going to package
6- WORKING_DIR=" $( pwd) /build"
8+ WORKING_DIR=" ${PWD} /build"
9+ BUILT_TOOLCHAIN_DIR=" ${WORKING_DIR} /rust-build/build/${HOST_ARCH} "
710
811# The directory which will be added to the final zip file
9- DEST=" $( pwd ) /dist/rust-${RUST_TOOLCHAIN} "
12+ DEST=" ${PWD} /dist/rust-${RUST_TOOLCHAIN} "
1013
1114# The actual toolchain inside that, which will be installed to ~/.rustup/...
1215TOOLCHAIN_DEST=" ${DEST} /${RUST_TOOLCHAIN} "
@@ -15,22 +18,34 @@ rm -rf "$DEST"
1518mkdir -p " $TOOLCHAIN_DEST "
1619
1720# Remove unneeded files from output
18- rm -rf " $WORKING_DIR /rust-build/build/x86_64-apple-darwin /stage2/lib/rustlib/src"
21+ rm -rf " ${BUILT_TOOLCHAIN_DIR} /stage2/lib/rustlib/src"
1922
2023# Copy in toolchain artifacts
21- cp -r " $WORKING_DIR /rust-build/build/x86_64-apple-darwin/stage2" /* " $TOOLCHAIN_DEST "
22- cp -r " $WORKING_DIR /rust-build/build/x86_64-apple-darwin/stage2-tools/x86_64-apple-darwin/release/cargo" " $TOOLCHAIN_DEST /bin"
24+ cp -r \
25+ " ${BUILT_TOOLCHAIN_DIR} /stage2" /* \
26+ " $TOOLCHAIN_DEST " \
27+ ;
28+ cp -r \
29+ " ${BUILT_TOOLCHAIN_DIR} /stage2-tools/$HOST_ARCH /release/cargo" \
30+ " $TOOLCHAIN_DEST /bin" \
31+ ;
2332
2433# Copy in static files that need to be included in the distribution
2534cp LICENSE* README.md " $DEST "
2635
27- echo " #!/bin/bash" >> " $DEST /install.sh"
28- echo " DEST_TOOLCHAIN=\"\$ HOME/.rustup/toolchains/$RUST_TOOLCHAIN \" " >> " $DEST /install.sh"
29- echo " mkdir -p \"\$ DEST_TOOLCHAIN\" " >> $DEST /install.sh
30- echo " cp -r \" $RUST_TOOLCHAIN \" /* \"\$ DEST_TOOLCHAIN\" " >> " $DEST /install.sh"
31- chmod +x " $DEST /install.sh"
36+ sed ' s/^ //' > " $DEST /install.sh" << EOF
37+ #!/bin/bash
38+ set -euxo pipefail
39+
40+ DEST_TOOLCHAIN="\$ HOME/.rustup/toolchains/${RUST_TOOLCHAIN} "
41+ mkdir -p "\$ DEST_TOOLCHAIN"
42+ cp -r "${RUST_TOOLCHAIN} "/* "\$ DEST_TOOLCHAIN"
43+ chmod +x "${DEST} /install.sh"
44+
45+ echo "Installed bitcode-enabled Rust toolchain. Use with: +${RUST_TOOLCHAIN} "
46+ EOF
3247
33- cd dist
34- rm -f " rust-${RUST_TOOLCHAIN} .zip"
35- zip -r " rust-${RUST_TOOLCHAIN} .zip" " rust-${RUST_TOOLCHAIN} "
36- cd ..
48+ ( cd dist
49+ rm -f " rust-${RUST_TOOLCHAIN} .zip"
50+ zip -r " rust-${RUST_TOOLCHAIN} .zip" " rust-${RUST_TOOLCHAIN} "
51+ )
0 commit comments