| 1 |
#!/bin/bash |
| 2 |
#set -o pipefail |
| 3 |
# |
| 4 |
# Copyright (c) Microsoft. All rights reserved. |
| 5 |
# Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 6 |
|
| 7 |
set -e |
| 8 |
|
| 9 |
cat /etc/*release | grep VERSION* |
| 10 |
gcc --version |
| 11 |
openssl version |
| 12 |
|
| 13 |
script_dir=$(cd "$(dirname "$0")" && pwd) |
| 14 |
build_root=$(cd "${script_dir}/.." && pwd) |
| 15 |
build_folder=$build_root"/cmake" |
| 16 |
|
| 17 |
# Set the default cores |
| 18 |
MAKE_CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu) |
| 19 |
|
| 20 |
echo "Initial MAKE_CORES=$MAKE_CORES" |
| 21 |
|
| 22 |
# Make sure there is enough virtual memory on the device to handle more than one job |
| 23 |
MINVSPACE="1500000" |
| 24 |
|
| 25 |
# Acquire total memory and total swap space setting them to zero in the event the command fails |
| 26 |
MEMAR=( $(sed -n -e 's/^MemTotal:[^0-9]*\([0-9][0-9]*\).*/\1/p' -e 's/^SwapTotal:[^0-9]*\([0-9][0-9]*\).*/\1/p' /proc/meminfo) ) |
| 27 |
[ -z "${MEMAR[0]##*[!0-9]*}" ] && MEMAR[0]=0 |
| 28 |
[ -z "${MEMAR[1]##*[!0-9]*}" ] && MEMAR[1]=0 |
| 29 |
|
| 30 |
let VSPACE=${MEMAR[0]}+${MEMAR[1]} |
| 31 |
|
| 32 |
if [ "$VSPACE" -lt "$MINVSPACE" ] ; then |
| 33 |
echo "WARNING: Not enough space. Setting MAKE_CORES=1" |
| 34 |
MAKE_CORES=1 |
| 35 |
fi |
| 36 |
|
| 37 |
declare -a arr=( |
| 38 |
"-Dskip_samples=ON" |
| 39 |
"-Dno_logging=ON" |
| 40 |
"-Denable_raw_logging=ON" |
| 41 |
"-Denable_raw_logging=ON -Dno_logging=ON" |
| 42 |
"-Duse_builtin_httpapi=ON" |
| 43 |
"-Duse_default_uuid=ON" |
| 44 |
"-Dno_openssl_engine=ON" |
| 45 |
"-Duse_http=OFF" |
| 46 |
) |
| 47 |
|
| 48 |
for item in "${arr[@]}" |
| 49 |
do |
| 50 |
rm -r -f $build_folder |
| 51 |
mkdir -p $build_folder |
| 52 |
pushd $build_folder |
| 53 |
|
| 54 |
echo "executing cmake/make with options <<$item>>" |
| 55 |
cmake $build_root "$item" |
| 56 |
|
| 57 |
make --jobs=$MAKE_CORES |
| 58 |
done |
| 59 |
popd |