2022-01-08 07:15:18 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
2020-08-10 15:44:24 +08:00
|
|
|
|
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
|
|
|
|
RC_FILE="$HOME/.bashrc"
|
|
|
|
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
|
|
|
|
2022-01-08 07:15:18 +08:00
|
|
|
# TODO: remove protobuf,protobuf-c,swig when casadi can be pip installed
|
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"
|
|
|
|
brew "openssl"
|
|
|
|
brew "pyenv"
|
2021-03-10 11:37:17 +08:00
|
|
|
brew "qt@5"
|
2021-01-19 09:28:30 +08:00
|
|
|
brew "zeromq"
|
2022-01-08 07:15:18 +08:00
|
|
|
brew "protobuf"
|
|
|
|
brew "protobuf-c"
|
|
|
|
brew "swig"
|
2021-01-19 09:28:30 +08:00
|
|
|
EOS
|
2021-01-18 23:17:23 +08:00
|
|
|
|
2022-05-13 17:12:59 +08:00
|
|
|
# Install gcc-arm-embedded 10.3-2021.10. 11.x is broken on M1 Macs with Xcode 13.3~
|
|
|
|
brew uninstall gcc-arm-embedded || true
|
|
|
|
curl -L https://github.com/Homebrew/homebrew-cask/raw/d407663b8017a0a062c7fc0b929faf2e16abd1ff/Casks/gcc-arm-embedded.rb > /tmp/gcc-arm-embedded.rb
|
|
|
|
brew install --cask /tmp/gcc-arm-embedded.rb
|
|
|
|
rm /tmp/gcc-arm-embedded.rb
|
|
|
|
|
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"
|
|
|
|
export PYCURL_SSL_LIBRARY=openssl
|
2021-03-31 06:45:28 +08:00
|
|
|
|
2022-01-03 06:47:16 +08:00
|
|
|
# openpilot environment
|
2020-08-15 09:03:55 +08:00
|
|
|
if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then
|
2022-01-01 11:29:38 +08:00
|
|
|
echo "source $ROOT/tools/openpilot_env.sh" >> $RC_FILE
|
|
|
|
source "$ROOT/tools/openpilot_env.sh"
|
2020-08-15 09:03:55 +08:00
|
|
|
echo "Added openpilot_env to RC file: $RC_FILE"
|
|
|
|
fi
|
|
|
|
|
2022-01-03 06:47:16 +08:00
|
|
|
# install python dependencies
|
|
|
|
$ROOT/update_requirements.sh
|
2022-01-08 07:15:18 +08:00
|
|
|
eval "$(pyenv init --path)"
|
|
|
|
echo "[ ] installed python dependencies t=$SECONDS"
|
|
|
|
|
|
|
|
# install casadi
|
|
|
|
VENV=`pipenv --venv`
|
|
|
|
PYTHON_VER=3.8
|
|
|
|
PYTHON_VERSION=$(cat $ROOT/.python-version)
|
|
|
|
if [ ! -f "$VENV/include/casadi/casadi.hpp" ]; then
|
|
|
|
echo "-- casadi manual install"
|
|
|
|
cd /tmp/ && curl -L https://github.com/casadi/casadi/archive/refs/tags/ge6.tar.gz --output casadi.tar.gz
|
|
|
|
tar -xzf casadi.tar.gz
|
|
|
|
cd casadi-ge6/ && mkdir -p build && cd build
|
|
|
|
cmake .. \
|
|
|
|
-DWITH_PYTHON=ON \
|
|
|
|
-DWITH_EXAMPLES=OFF \
|
|
|
|
-DCMAKE_INSTALL_PREFIX:PATH=$VENV \
|
|
|
|
-DPYTHON_PREFIX:PATH=$VENV/lib/python$PYTHON_VER/site-packages \
|
|
|
|
-DPYTHON_LIBRARY:FILEPATH=$HOME/.pyenv/versions/$PYTHON_VERSION/lib/libpython$PYTHON_VER.dylib \
|
|
|
|
-DPYTHON_EXECUTABLE:FILEPATH=$HOME/.pyenv/versions/$PYTHON_VERSION/bin/python \
|
|
|
|
-DPYTHON_INCLUDE_DIR:PATH=$HOME/.pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_VER \
|
|
|
|
-DCMAKE_CXX_FLAGS="-ferror-limit=0" -DCMAKE_C_FLAGS="-ferror-limit=0"
|
|
|
|
CFLAGS="-ferror-limit=0" make -j$(nproc) && make install
|
|
|
|
else
|
|
|
|
echo "---- casadi found in venv. skipping build ----"
|
|
|
|
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"
|