From 4cd40c7f19c2ae93f8409daa6500fc12dec53cf3 Mon Sep 17 00:00:00 2001 From: "mike@arpaia.co" Date: Thu, 25 Sep 2014 01:45:13 -0700 Subject: [PATCH] central build script --- .gitignore | 2 +- .travis.yml | 16 +++------------- tools/build.sh | 14 ++++++++++++++ tools/lib.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tools/provision.sh | 40 ++-------------------------------------- 5 files changed, 66 insertions(+), 52 deletions(-) create mode 100755 tools/build.sh create mode 100755 tools/lib.sh diff --git a/.gitignore b/.gitignore index 3f5b9b58..ef2e118f 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ *.app # Build Artifacts -build* +build/ osquery/tables/generated # Vagrant Artifacts diff --git a/.travis.yml b/.travis.yml index 5b181cbf..7ea825c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,4 @@ language: cpp - -os: - - osx - -compiler: - - clang - -before_install: - - make deps - -script: - - make - - make test +os: osx +compiler: clang +script: ./tools/build.sh diff --git a/tools/build.sh b/tools/build.sh new file mode 100755 index 00000000..1e007307 --- /dev/null +++ b/tools/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +. $SCRIPT_DIR/lib.sh + +threads THREADS + +cd $SCRIPT_DIR/../ + +make deps +make -j$THREADS +make test diff --git a/tools/lib.sh b/tools/lib.sh new file mode 100755 index 00000000..7bf810d4 --- /dev/null +++ b/tools/lib.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +function platform() { + local __resultvar=$1 + if [[ -f "/etc/yum.conf" ]]; then + eval $__resultvar="centos" + elif [[ -f "/etc/dpkg/dpkg.cfg" ]]; then + eval $__resultvar="ubuntu" + elif [[ -f "/etc/pf.conf" ]]; then + eval $__resultvar="darwin" + fi +} + +function threads() { + local __resultvar=$1 + platform OS + if [ $OS = "centos" ] || [ $OS = "ubuntu" ]; then + eval $__resultvar=`cat /proc/cpuinfo | grep processor | wc -l` + elif [[ $OS = "darwin" ]]; then + eval $__resultvar=`sysctl hw.ncpu | awk '{print $2}'` + fi +} + +function log() { + echo "[+] $1" +} + +function fatal() { + echo "[!] $1" + exit 1 +} + +function set_cxx() { + export CXX=$1 + export CMAKE_CXX_COMPILER=$1 +} + +function add_cxx_flag() { + export CXXFLAGS="$CXXFLAGS $1" + export CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS $1" +} + +function set_cc() { + export CC=$1 + export CMAKE_C_COMPILER=$1 +} diff --git a/tools/provision.sh b/tools/provision.sh index 4e074fa0..53d1722b 100755 --- a/tools/provision.sh +++ b/tools/provision.sh @@ -6,40 +6,8 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" WORKING_DIR="$SCRIPT_DIR/../.sources" export PATH="$PATH:/usr/local/bin" -function platform() { - local __resultvar=$1 - if [[ -f "/etc/yum.conf" ]]; then - eval $__resultvar="centos" - elif [[ -f "/etc/dpkg/dpkg.cfg" ]]; then - eval $__resultvar="ubuntu" - elif [[ -f "/etc/pf.conf" ]]; then - eval $__resultvar="darwin" - fi -} +. $SCRIPT_DIR/lib.sh -function log() { - echo "[+] $1" -} - -function fatal() { - echo "[!] $1" - exit 1 -} - -function set_cxx() { - export CXX=$1 - export CMAKE_CXX_COMPILER=$1 -} - -function add_cxx_flag() { - export CXXFLAGS="$CXXFLAGS $1" - export CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS $1" -} - -function set_cc() { - export CC=$1 - export CMAKE_C_COMPILER=$1 -} # cmake # downloads: http://www.cmake.org/download/ @@ -178,11 +146,7 @@ function main() { fatal "could not detect the current operating system. exiting." fi - if [ $OS = "centos" ] || [ $OS = "ubuntu" ]; then - THREADS=`cat /proc/cpuinfo | grep processor | wc -l` - elif [[ $OS = "darwin" ]]; then - THREADS=`sysctl hw.ncpu | awk '{print $2}'` - fi + threads THREADS if [[ $OS = "ubuntu" ]]; then