cpp_client_telemetry/build.sh

101 строка
2.5 KiB
Bash
Исходник Обычный вид История

2018-03-31 03:05:05 +03:00
#!/bin/bash
2018-09-07 01:07:01 +03:00
export PATH=/usr/local/bin:$PATH
2018-03-31 03:05:05 +03:00
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Current directory: $DIR"
cd $DIR
if [ "$1" == "clean" ]; then
rm -f CMakeCache.txt *.cmake
rm -rf out
rm -rf .buildtools
# make clean
fi
# Install build tools and recent sqlite3
FILE=.buildtools
OS_NAME=`uname -a`
if [ ! -f $FILE ]; then
case "$OS_NAME" in
*Darwin*) tools/setup-buildtools-mac.sh ;;
*Linux*) sudo tools/setup-buildtools.sh ;;
*) echo "WARNING: unsupported OS $OS_NAME , skipping build tools installation.."
esac
# Assume that the build tools have been successfully installed
echo > $FILE
2018-03-31 03:05:05 +03:00
fi
2018-09-07 01:07:01 +03:00
if [ -f /usr/bin/gcc ]; then
echo "gcc version: `gcc --version`"
fi
if [ -f /usr/bin/clang ]; then
echo "clang version: `clang --version`"
2018-09-07 01:07:01 +03:00
fi
# Skip Version.hpp changes
git update-index --skip-worktree lib/include/public/Version.hpp
2018-03-31 03:05:05 +03:00
#rm -rf out
mkdir -p out
cd out
# .tgz package
CMAKE_PACKAGE_TYPE=tgz
# .deb package
if [ -f /usr/bin/dpkg ]; then
export CMAKE_PACKAGE_TYPE=deb
fi
# .rpm package
2018-09-07 01:07:01 +03:00
if [ -f /usr/bin/rpmbuild ]; then
export CMAKE_PACKAGE_TYPE=rpm
fi
2018-03-31 03:05:05 +03:00
if [ "$2" == "release" ]; then
# TODO: pass custom build flags?
2018-09-07 01:07:01 +03:00
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE ..
2018-03-31 03:05:05 +03:00
# TODO: strip symbols to minimize
else
2018-09-07 01:07:01 +03:00
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE ..
2018-03-31 03:05:05 +03:00
fi
# Build all
# TODO: what are the pros and cons of using 'make' vs 'cmake --build' ?
#make
cmake --build .
2018-03-31 03:05:05 +03:00
# Remove old package
2018-09-07 01:07:01 +03:00
rm -f *.deb *.rpm
2018-03-31 03:05:05 +03:00
# Build new package
make package
# Debian / Ubuntu / Raspbian
2018-09-07 01:07:01 +03:00
if [ -f /usr/bin/dpkg ]; then
2018-03-31 03:05:05 +03:00
# Install new package
sudo dpkg -i *.deb
fi
# RedHat / CentOS
if [ -f /usr/bin/rpmbuild ]; then
2018-09-07 01:20:22 +03:00
sudo rpm -i --force -v *.rpm
2018-09-07 01:07:01 +03:00
fi
2018-03-31 03:05:05 +03:00
# Install SDK headers and lib to /usr/local
#
## TODO: [MG] - fix this section for shared library
2019-03-29 02:40:31 +03:00
## strip --strip-unneeded out/lib/libmat.so
## strip -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag out/lib/libmat.so
if [ "$CMAKE_PACKAGE_TYPE" == "tgz" ]; then
cd ..
2019-03-29 02:40:31 +03:00
MATSDK_INSTALL_DIR="${MATSDK_INSTALL_DIR:-/usr/local}"
echo "+-----------------------------------------------------------------------------------+"
2019-03-29 02:40:31 +03:00
echo " This step may prompt for your sudo password to deploy SDK to $MATSDK_INSTALL_DIR "
echo "+-----------------------------------------------------------------------------------+"
2019-03-29 02:40:31 +03:00
sudo ./install.sh $MATSDK_INSTALL_DIR
fi