2023-08-30 07:01:04 +08:00
|
|
|
#!/usr/bin/env bash
|
2022-01-08 07:15:18 +08:00
|
|
|
|
|
|
|
set -e
|
2020-08-10 15:44:24 +08:00
|
|
|
|
2023-09-16 10:05:32 +08:00
|
|
|
if [ -z "$SKIP_PROMPT" ]; then
|
|
|
|
echo "--------------- macOS support ---------------"
|
|
|
|
echo "Running openpilot natively on macOS is not officially supported."
|
|
|
|
echo "It might build, some parts of it might work, but it's not fully tested, so there might be some issues."
|
|
|
|
echo
|
|
|
|
echo "Check out devcontainers for a seamless experience (see tools/README.md)."
|
|
|
|
echo "-------------------------------------------------"
|
|
|
|
echo -n "Are you sure you want to continue? [y/N] "
|
|
|
|
read -r response
|
|
|
|
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-01-01 11:29:38 +08:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
|
|
|
ROOT="$(cd $DIR/../ && pwd)"
|
2022-02-23 20:04:50 +08:00
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
|
|
|
if [[ $SHELL == "/bin/zsh" ]]; then
|
|
|
|
RC_FILE="$HOME/.zshrc"
|
|
|
|
elif [[ $SHELL == "/bin/bash" ]]; then
|
2023-07-27 15:31:42 +08:00
|
|
|
RC_FILE="$HOME/.bash_profile"
|
2022-02-23 20:04:50 +08:00
|
|
|
fi
|
2021-10-11 07:03:56 +08:00
|
|
|
|
2021-01-19 09:28:30 +08:00
|
|
|
# Install brew if required
|
2020-10-17 02:12:44 +08:00
|
|
|
if [[ $(command -v brew) == "" ]]; then
|
2020-10-29 05:12:56 +08:00
|
|
|
echo "Installing Hombrew"
|
|
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
2022-01-08 07:15:18 +08:00
|
|
|
echo "[ ] installed brew t=$SECONDS"
|
2022-02-23 20:04:50 +08:00
|
|
|
|
|
|
|
# make brew available now
|
|
|
|
if [[ $ARCH == "x86_64" ]]; then
|
|
|
|
echo 'eval "$(/usr/local/homebrew/bin/brew shellenv)"' >> $RC_FILE
|
|
|
|
eval "$(/usr/local/homebrew/bin/brew shellenv)"
|
|
|
|
else
|
|
|
|
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $RC_FILE
|
|
|
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
|
|
fi
|
2020-10-17 02:12:44 +08:00
|
|
|
fi
|
2020-08-10 15:44:24 +08:00
|
|
|
|
2021-01-19 09:28:30 +08:00
|
|
|
brew bundle --file=- <<-EOS
|
2022-03-06 07:29:06 +08:00
|
|
|
brew "catch2"
|
2021-03-31 06:45:28 +08:00
|
|
|
brew "cmake"
|
2022-01-08 07:15:18 +08:00
|
|
|
brew "cppcheck"
|
2022-01-01 02:08:34 +08:00
|
|
|
brew "git-lfs"
|
2021-03-31 06:45:28 +08:00
|
|
|
brew "zlib"
|
|
|
|
brew "bzip2"
|
2021-01-19 09:28:30 +08:00
|
|
|
brew "capnp"
|
|
|
|
brew "coreutils"
|
|
|
|
brew "eigen"
|
|
|
|
brew "ffmpeg"
|
|
|
|
brew "glfw"
|
|
|
|
brew "libarchive"
|
|
|
|
brew "libusb"
|
|
|
|
brew "libtool"
|
|
|
|
brew "llvm"
|
2023-04-20 04:31:19 +08:00
|
|
|
brew "openssl@3.0"
|
2021-01-19 09:28:30 +08:00
|
|
|
brew "pyenv"
|
2023-08-22 04:30:48 +08:00
|
|
|
brew "pyenv-virtualenv"
|
2021-03-10 11:37:17 +08:00
|
|
|
brew "qt@5"
|
2021-01-19 09:28:30 +08:00
|
|
|
brew "zeromq"
|
2023-09-11 07:26:27 +08:00
|
|
|
brew "gcc@13"
|
2023-01-10 02:30:30 +08:00
|
|
|
cask "gcc-arm-embedded"
|
2023-07-27 14:08:23 +08:00
|
|
|
brew "portaudio"
|
2021-01-19 09:28:30 +08:00
|
|
|
EOS
|
2021-01-18 23:17:23 +08:00
|
|
|
|
2022-01-08 07:15:18 +08:00
|
|
|
echo "[ ] finished brew install t=$SECONDS"
|
|
|
|
|
2022-02-23 20:04:50 +08:00
|
|
|
BREW_PREFIX=$(brew --prefix)
|
|
|
|
|
|
|
|
# archive backend tools for pip dependencies
|
|
|
|
export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/zlib/lib"
|
|
|
|
export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/bzip2/lib"
|
|
|
|
export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/zlib/include"
|
|
|
|
export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/bzip2/include"
|
2020-08-15 09:03:55 +08:00
|
|
|
|
2022-02-23 20:04:50 +08:00
|
|
|
# pycurl curl/openssl backend dependencies
|
|
|
|
export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/openssl@3/lib"
|
|
|
|
export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/openssl@3/include"
|
2023-06-22 04:14:20 +08:00
|
|
|
export PYCURL_CURL_CONFIG=/usr/bin/curl-config
|
2022-02-23 20:04:50 +08:00
|
|
|
export PYCURL_SSL_LIBRARY=openssl
|
2021-03-31 06:45:28 +08:00
|
|
|
|
2022-01-03 06:47:16 +08:00
|
|
|
# install python dependencies
|
2023-08-12 11:05:44 +08:00
|
|
|
$DIR/install_python_dependencies.sh
|
2022-01-08 07:15:18 +08:00
|
|
|
echo "[ ] installed python dependencies t=$SECONDS"
|
|
|
|
|
2023-09-12 08:00:08 +08:00
|
|
|
# brew does not link qt5 by default
|
|
|
|
# check if qt5 can be linked, if not, prompt the user to link it
|
|
|
|
QT_BIN_LOCATION="$(command -v lupdate || :)"
|
|
|
|
if [ -n "$QT_BIN_LOCATION" ]; then
|
|
|
|
# if qt6 is linked, prompt the user to unlink it and link the right version
|
|
|
|
QT_BIN_VERSION="$(lupdate -version | awk '{print $NF}')"
|
|
|
|
if [[ ! "$QT_BIN_VERSION" =~ 5\.[0-9]+\.[0-9]+ ]]; then
|
|
|
|
echo
|
|
|
|
echo "lupdate/lrelease available at PATH is $QT_BIN_VERSION"
|
|
|
|
if [[ "$QT_BIN_LOCATION" == "$(brew --prefix)/"* ]]; then
|
|
|
|
echo "Run the following command to link qt5:"
|
|
|
|
echo "brew unlink qt@6 && brew link qt@5"
|
|
|
|
else
|
|
|
|
echo "Remove conflicting qt entries from PATH and run the following command to link qt5:"
|
|
|
|
echo "brew link qt@5"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
brew link qt@5
|
|
|
|
fi
|
|
|
|
|
2021-04-21 08:28:10 +08:00
|
|
|
echo
|
2022-01-08 07:15:18 +08:00
|
|
|
echo "---- OPENPILOT SETUP DONE ----"
|
|
|
|
echo "Open a new shell or configure your active shell env by running:"
|
2021-10-31 23:37:07 +08:00
|
|
|
echo "source $RC_FILE"
|