install.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. set -ex
  2. . $(dirname $0)/env.sh
  3. install_qemu() {
  4. case $TRAVIS_OS_NAME in
  5. linux)
  6. apt-get update
  7. apt-get install -y --no-install-recommends \
  8. binfmt-support qemu-user-static
  9. ;;
  10. esac
  11. }
  12. install_binutils() {
  13. if [[ $TRAVIS_OS_NAME == "osx" ]]; then
  14. brew install binutils
  15. fi
  16. }
  17. install_rust() {
  18. if [[ $TRAVIS_OS_NAME == "osx" ]]; then
  19. curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly
  20. else
  21. rustup default nightly
  22. fi
  23. rustc -V
  24. cargo -V
  25. }
  26. add_rustup_target() {
  27. if [[ $TARGET != $HOST && ${CARGO:-cargo} == "cargo" ]]; then
  28. rustup target add $TARGET
  29. fi
  30. }
  31. install_xargo() {
  32. if [[ $CARGO == "xargo" ]]; then
  33. curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
  34. bash -s -- --from japaric/xargo --at /root/.cargo/bin
  35. fi
  36. }
  37. main() {
  38. if [[ $TRAVIS_OS_NAME == "osx" || ${IN_DOCKER_CONTAINER:-n} == "y" ]]; then
  39. install_qemu
  40. install_binutils
  41. install_rust
  42. add_rustup_target
  43. install_xargo
  44. fi
  45. }
  46. main