2018-03-31 03:05:05 +03:00
|
|
|
#!/bin/bash
|
2018-09-07 01:07:01 +03:00
|
|
|
|
|
|
|
export PATH=/usr/local/bin:$PATH
|
|
|
|
|
2019-09-07 18:51:27 +03:00
|
|
|
if [[ ! -z "${GIT_PULL_TOKEN}" ]]; then
|
|
|
|
rm -rf lib/modules
|
|
|
|
echo Git local settings:
|
|
|
|
git config -l
|
|
|
|
echo Git system settings:
|
|
|
|
git config --system --list
|
|
|
|
git config credential.helper store
|
|
|
|
git clone https://${GIT_PULL_TOKEN}:x-oauth-basic@github.com/microsoft/cpp_client_telemetry_modules.git lib/modules
|
|
|
|
fi
|
|
|
|
|
2018-03-31 03:05:05 +03:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
echo "Current directory: $DIR"
|
|
|
|
cd $DIR
|
|
|
|
|
2019-06-20 00:34:04 +03:00
|
|
|
export NOROOT=$NOROOT
|
|
|
|
|
2018-03-31 03:05:05 +03:00
|
|
|
if [ "$1" == "clean" ]; then
|
|
|
|
rm -f CMakeCache.txt *.cmake
|
|
|
|
rm -rf out
|
|
|
|
rm -rf .buildtools
|
|
|
|
# make clean
|
|
|
|
fi
|
|
|
|
|
2019-06-20 00:34:04 +03:00
|
|
|
if [ "$1" == "noroot" ] || [ "$2" == "noroot" ]; then
|
|
|
|
export NOROOT=true
|
|
|
|
fi
|
|
|
|
|
2019-08-07 01:40:28 +03:00
|
|
|
if [ "$1" == "release" ] || [ "$2" == "release" ]; then
|
|
|
|
BUILD_TYPE="Release"
|
|
|
|
else
|
|
|
|
BUILD_TYPE="Debug"
|
|
|
|
fi
|
|
|
|
|
2019-09-12 03:23:28 +03:00
|
|
|
# Set target MacOS minver
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.10
|
|
|
|
|
2018-03-31 03:05:05 +03:00
|
|
|
# Install build tools and recent sqlite3
|
|
|
|
FILE=.buildtools
|
2018-11-07 09:39:27 +03:00
|
|
|
OS_NAME=`uname -a`
|
|
|
|
if [ ! -f $FILE ]; then
|
|
|
|
case "$OS_NAME" in
|
2019-02-26 11:41:48 +03:00
|
|
|
*Darwin*) tools/setup-buildtools-mac.sh ;;
|
2019-06-20 00:34:04 +03:00
|
|
|
*Linux*) [[ -z "$NOROOT" ]] && sudo tools/setup-buildtools.sh || echo "No root: skipping build tools installation." ;;
|
2018-11-07 09:39:27 +03:00
|
|
|
*) 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
|
2018-11-07 09:39:27 +03:00
|
|
|
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
|
|
|
|
|
2019-03-08 08:24:15 +03:00
|
|
|
# Skip Version.hpp changes
|
2019-04-23 01:18:05 +03:00
|
|
|
# git update-index --skip-worktree lib/include/public/Version.hpp
|
2019-03-08 08:24:15 +03:00
|
|
|
|
2018-03-31 03:05:05 +03:00
|
|
|
#rm -rf out
|
|
|
|
mkdir -p out
|
|
|
|
cd out
|
|
|
|
|
2018-11-07 09:39:27 +03:00
|
|
|
# .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
|
|
|
|
|
2019-04-16 23:51:09 +03:00
|
|
|
|
|
|
|
# Fail on error
|
|
|
|
set -e
|
|
|
|
|
2019-08-07 01:40:28 +03:00
|
|
|
|
2018-03-31 03:05:05 +03:00
|
|
|
# TODO: pass custom build flags?
|
2019-08-07 01:40:28 +03:00
|
|
|
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE ..
|
|
|
|
# TODO: strip symbols to minimize (release-only)
|
2018-03-31 03:05:05 +03:00
|
|
|
|
|
|
|
# Build all
|
2018-11-07 09:39:27 +03:00
|
|
|
# TODO: what are the pros and cons of using 'make' vs 'cmake --build' ?
|
|
|
|
#make
|
|
|
|
cmake --build .
|
2018-03-31 03:05:05 +03:00
|
|
|
|
2019-04-16 23:51:09 +03:00
|
|
|
# No fail on error
|
|
|
|
set +e
|
|
|
|
|
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
|
|
|
|
|
2018-11-07 09:39:27 +03:00
|
|
|
# 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
|
2019-06-20 00:34:04 +03:00
|
|
|
[[ -z "$NOROOT" ]] && sudo dpkg -i *.deb || echo "No root: skipping package deployment."
|
2018-11-07 09:39:27 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# RedHat / CentOS
|
|
|
|
if [ -f /usr/bin/rpmbuild ]; then
|
2019-06-20 00:34:04 +03:00
|
|
|
[[ -z "$NOROOT" ]] && sudo rpm -i --force -v *.rpm || echo "No root: skipping package deployment."
|
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
|
|
|
|
#
|
2018-11-07 09:39:27 +03:00
|
|
|
## 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
|
2018-11-07 09:39:27 +03:00
|
|
|
|
|
|
|
if [ "$CMAKE_PACKAGE_TYPE" == "tgz" ]; then
|
|
|
|
cd ..
|
2019-03-29 02:40:31 +03:00
|
|
|
MATSDK_INSTALL_DIR="${MATSDK_INSTALL_DIR:-/usr/local}"
|
2019-03-08 08:24:15 +03:00
|
|
|
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 "
|
2019-03-08 08:24:15 +03:00
|
|
|
echo "+-----------------------------------------------------------------------------------+"
|
2019-09-18 10:53:25 +03:00
|
|
|
[[ -z "$NOROOT" ]] && sudo ./install.sh $MATSDK_INSTALL_DIR || echo "No root: skipping package deployment."
|
2018-11-07 09:39:27 +03:00
|
|
|
fi
|