mac_setup.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env bash
  2. set -e
  3. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
  4. ROOT="$(cd $DIR/../ && pwd)"
  5. ARCH=$(uname -m)
  6. if [[ $SHELL == "/bin/zsh" ]]; then
  7. RC_FILE="$HOME/.zshrc"
  8. elif [[ $SHELL == "/bin/bash" ]]; then
  9. RC_FILE="$HOME/.bash_profile"
  10. fi
  11. # Install brew if required
  12. if [[ $(command -v brew) == "" ]]; then
  13. echo "Installing Homebrew"
  14. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  15. echo "[ ] installed brew t=$SECONDS"
  16. # make brew available now
  17. if [[ $ARCH == "x86_64" ]]; then
  18. echo 'eval "$(/usr/local/bin/brew shellenv)"' >> $RC_FILE
  19. eval "$(/usr/local/bin/brew shellenv)"
  20. else
  21. echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $RC_FILE
  22. eval "$(/opt/homebrew/bin/brew shellenv)"
  23. fi
  24. fi
  25. brew bundle --file=- <<-EOS
  26. brew "cppcheck"
  27. brew "git-lfs"
  28. brew "zlib"
  29. brew "capnp"
  30. brew "coreutils"
  31. brew "eigen"
  32. brew "ffmpeg"
  33. brew "glfw"
  34. brew "libarchive"
  35. brew "libusb"
  36. brew "libtool"
  37. brew "llvm"
  38. brew "openssl@3.0"
  39. brew "qt@5"
  40. brew "zeromq"
  41. cask "gcc-arm-embedded"
  42. brew "portaudio"
  43. brew "gcc@13"
  44. EOS
  45. echo "[ ] finished brew install t=$SECONDS"
  46. BREW_PREFIX=$(brew --prefix)
  47. # archive backend tools for pip dependencies
  48. export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/zlib/lib"
  49. export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/bzip2/lib"
  50. export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/zlib/include"
  51. export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/bzip2/include"
  52. # pycurl curl/openssl backend dependencies
  53. export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/openssl@3/lib"
  54. export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/openssl@3/include"
  55. export PYCURL_CURL_CONFIG=/usr/bin/curl-config
  56. export PYCURL_SSL_LIBRARY=openssl
  57. # install python dependencies
  58. $DIR/install_python_dependencies.sh
  59. echo "[ ] installed python dependencies t=$SECONDS"
  60. # brew does not link qt5 by default
  61. # check if qt5 can be linked, if not, prompt the user to link it
  62. QT_BIN_LOCATION="$(command -v lupdate || :)"
  63. if [ -n "$QT_BIN_LOCATION" ]; then
  64. # if qt6 is linked, prompt the user to unlink it and link the right version
  65. QT_BIN_VERSION="$(lupdate -version | awk '{print $NF}')"
  66. if [[ ! "$QT_BIN_VERSION" =~ 5\.[0-9]+\.[0-9]+ ]]; then
  67. echo
  68. echo "lupdate/lrelease available at PATH is $QT_BIN_VERSION"
  69. if [[ "$QT_BIN_LOCATION" == "$(brew --prefix)/"* ]]; then
  70. echo "Run the following command to link qt5:"
  71. echo "brew unlink qt@6 && brew link qt@5"
  72. else
  73. echo "Remove conflicting qt entries from PATH and run the following command to link qt5:"
  74. echo "brew link qt@5"
  75. fi
  76. fi
  77. else
  78. brew link qt@5
  79. fi
  80. echo
  81. echo "---- OPENPILOT SETUP DONE ----"
  82. echo "Open a new shell or configure your active shell env by running:"
  83. echo "source $RC_FILE"