Merge pull request #172 from facebook/ci-script

central build script
This commit is contained in:
Mike Arpaia 2014-09-25 02:18:47 -07:00
commit 4411969959
5 changed files with 66 additions and 52 deletions

2
.gitignore vendored
View File

@ -21,7 +21,7 @@
*.app
# Build Artifacts
build*
build/
osquery/tables/generated
# Vagrant Artifacts

View File

@ -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

14
tools/build.sh Executable file
View File

@ -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

46
tools/lib.sh Executable file
View File

@ -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
}

View File

@ -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