<commit_before>#!/usr/bin/env bash


title() {
	echo
	echo
	echo
	echo
	echo "--- [ $1 ] ---"
	echo
}

die() {
	echo
	echo
	echo "   *** failed: ${1}"
	exit 1
}

local_pwd=$(dirname "$0")
root=$(cd "${local_pwd}" && pwd)
pushd "${root}/../../"


title "GENERAL"
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
	platform='linux'
elif [[ "$unamestr" == 'FreeBSD' ]]; then
	platform='freebsd'
elif [[ "$unamestr" == 'Darwin' ]]; then
	platform='macos'
fi
echo "platform: ${platform}"

export NPROC=1
[ $platform == linux ] && export NPROC=$(nproc)
[ $platform == macos ] && export NPROC=$(sysctl -n hw.ncpu)

[ "$BUILD_TYPE" == "" ] && export BUILD_TYPE="debug"



# update on TRAVIS
if [ "${TRAVIS_OS_NAME}" != "" -a $platform == linux ]; then
	if [ "$CC"  == "" ];    then export CC="gcc-4.9"; fi
	if [ "$CXX" == "" ];    then export CXX="g++-4.9"; fi
	if [ "$CC"  == "gcc" ]; then export CC="gcc-4.9"; fi
	if [ "$CXX" == "g++" ]; then export CXX="g++-4.9"; fi
fi
[ "$CC"  == "" ] && export CC="gcc";
[ "$CXX" == "" ] && export CXX="g++";


title "ENVIRONMENT"
cat ./build-settings.txt
echo
env


title "CLEANUP"
cd bootstrap
echo " - delete CMakeCache.txt" && rm -f CMakeCache.txt
echo " - delete CMakeFiles" && rm -rf CMakeFiles


title "CONFIGURE"
echo "# cmake . -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
cmake . -DCMAKE_BUILD_TYPE=${BUILD_TYPE} || die "bootstrap configure error"


title "BUILD"
echo "# make -j ${NPROC}"
make -j ${NPROC} || (title "MAKE ERROR"; make VERBOSE=1 ; exit 1) || die "build failed"
make check || die "check failed"


if [ $platform == linux ]; then
	title "PACKAGE DEB"
	make package-deb || die "package deb failed";
fi


title "OUTPUT"
ls -lh "${root}/../../distrib"
<commit_msg>travis-ci: simplify shell expressions<commit_after>#!/usr/bin/env bash


title() {
	echo
	echo
	echo
	echo
	echo "--- [ $1 ] ---"
	echo
}

die() {
	echo
	echo
	echo "   *** failed: ${1}"
	exit 1
}

local_pwd=$(dirname "$0")
root=$(cd "${local_pwd}" && pwd)
pushd "${root}/../../"


title "GENERAL"
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
	platform='linux'
elif [[ "$unamestr" == 'FreeBSD' ]]; then
	platform='freebsd'
elif [[ "$unamestr" == 'Darwin' ]]; then
	platform='macos'
fi
echo "platform: ${platform}"

export NPROC=1
[ $platform == linux ] && export NPROC=$(nproc)
[ $platform == macos ] && export NPROC=$(sysctl -n hw.ncpu)

[ "$BUILD_TYPE" == "" ] && export BUILD_TYPE="debug"



# update on TRAVIS
if [ -n "${TRAVIS_OS_NAME}" -a $platform == linux ]; then
	[ "$CC"  == "" ]    && export CC="gcc-4.9";
	[ "$CXX" == "" ]    && export CXX="g++-4.9";
	[ "$CC"  == "gcc" ] && export CC="gcc-4.9";
	[ "$CXX" == "g++" ] && export CXX="g++-4.9";
fi
[ -z "$CC" ]  && export CC="gcc";
[ -z "$CXX" ] && export CXX="g++";


title "ENVIRONMENT"
cat ./build-settings.txt
echo
env


title "CLEANUP"
cd bootstrap
echo " - delete CMakeCache.txt" && rm -f CMakeCache.txt
echo " - delete CMakeFiles" && rm -rf CMakeFiles


title "CONFIGURE"
echo "# cmake . -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
cmake . -DCMAKE_BUILD_TYPE=${BUILD_TYPE} || die "bootstrap configure error"


title "BUILD"
echo "# make -j ${NPROC}"
make -j ${NPROC} || (title "MAKE ERROR"; make VERBOSE=1 ; exit 1) || die "build failed"
make check || die "check failed"


if [ $platform == linux ]; then
	title "PACKAGE DEB"
	make package-deb || die "package deb failed";
fi


title "OUTPUT"
ls -lh "${root}/../../distrib"

{'fraction_non_alphanumeric': 0.2230299505670253, 'fraction_numerical': 0.008723466123873218, 'mean_word_length': 3.6930422919508867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7518162', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1318, 'n_words': 356}