Skip to content

Commit

Permalink
Add Ubuntu Azure Pipelines jobs. Add some caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmhofmann committed Nov 24, 2019
1 parent 5667166 commit aed3109
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 92 deletions.
8 changes: 8 additions & 0 deletions .azure-pipelines/macos_clone_vcpkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

vcpkg_base_dir=$1
vcpkg_tag=$2

cd ${vcpkg_base_dir}
git clone https://github.com/Microsoft/vcpkg.git
git -C ${vcpkg_base_dir}/vcpkg checkout ${vcpkg_tag}
18 changes: 18 additions & 0 deletions .azure-pipelines/macos_install_vcpkg_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

vcpkg_base_dir=$1
shift
vcpkg_libraries=$@

echo "vcpkg_base_dir=${vcpkg_base_dir}"
echo "vcpkg_libraries=${vcpkg_libraries}"

export BOOST_MODULAR_CMAKE="${vcpkg_base_dir}/vcpkg/ports/boost-modular-build-helper/CMakeLists.txt"
export LN=$(grep -n "WORKING_DIRECTORY" ${BOOST_MODULAR_CMAKE} | awk -F ":" '{print $1}')
gsed -i "${LN}i\ cxxstd=17" ${BOOST_MODULAR_CMAKE}

${vcpkg_base_dir}/vcpkg/bootstrap-vcpkg.sh
${vcpkg_base_dir}/vcpkg/vcpkg install ${vcpkg_libraries}
rm -rf ${vcpkg_base_dir}/vcpkg/buildtrees
rm -rf ${vcpkg_base_dir}/vcpkg/downloads
rm -rf ${vcpkg_base_dir}/vcpkg/packages
105 changes: 105 additions & 0 deletions .azure-pipelines/ubuntu-18.04_build_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env bash

set -e
selene_dir=$(pwd)

echo "--------------------------------------------------"
echo "COMMIT $(git rev-parse HEAD)"
echo "--------------------------------------------------"
echo "CC = ${CC}"
echo "CXX = ${CXX}"
echo "CXXFLAGS = ${CXXFLAGS}"
echo "LDFLAGS = ${LDFLAGS}"
echo ""
echo "VCPKG_DIR = ${VCPKG_DIR}"
echo "BUILD_TYPE = " ${BUILD_TYPE}
echo "ASAN = ${ASAN}"
echo "--------------------------------------------------"
cmake --version;
echo "--------------------------------------------------"
${CC} --version;
echo "--------------------------------------------------"
${CXX} --version;
echo "--------------------------------------------------"

local_build_benchmarks="-DSELENE_BUILD_BENCHMARKS=OFF"

if [[ -n "${VCPKG_DIR}" ]]; then
echo "Building using vcpkg..."
local_vcpkg_toolchain="-DCMAKE_TOOLCHAIN_FILE=${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake"
full_vcpkg_dir=${VCPKG_DIR}
local_build_benchmarks="-DSELENE_BUILD_BENCHMARKS=ON"
fi

if [[ -n "${BUILD_TYPE}" ]]; then
echo "Build type: ${BUILD_TYPE}"
local_build_type="-DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
fi

if [[ -n "${ASAN}" ]]; then
echo "Building with AddressSanitizer enabled..."
local_enable_sanitizers="-DSELENE_ENABLE_SANITIZERS=ON"
fi

# CMake invocation
rm -rf build && mkdir -p build && cd build
cmake -G Ninja \
${local_vcpkg_toolchain} \
${local_build_type} \
${local_enable_sanitizers} \
-DSELENE_BUILD_TESTS=ON \
-DSELENE_BUILD_EXAMPLES=ON \
${local_build_benchmarks} \
-DSELENE_WARNINGS_AS_ERRORS=ON \
..

echo "--------------------------------------------------"
echo "Build all targets..."

cmake --build . -j
export SELENE_DATA_PATH=${selene_dir}/data

echo "--------------------------------------------------"
echo "Run tests..."

./test/selene_tests -d yes

echo "--------------------------------------------------"
echo "Run all example binaries..."

# Run all example binaries
# https://stackoverflow.com/questions/4458120/unix-find-search-for-executable-files
example_binaries=$(find -L ./examples/ -maxdepth 1 -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \))
for file in ${example_binaries}
do
echo "EXECUTING ${file}..."
${file}
done

echo "--------------------------------------------------"

if [[ -n "${VCPKG_DIR}" ]]; then
echo "Build an example project using a vcpkg-installed version of Selene..."
echo "- Copying portfiles"
cp ${selene_dir}/package/vcpkg/* ${full_vcpkg_dir}/ports/selene

echo "- Removing selene (shouldn't exist)"
${full_vcpkg_dir}/vcpkg remove selene
echo "- Installing selene from HEAD"
${full_vcpkg_dir}/vcpkg install --head selene

echo "- Invoking CMake on test project"
cd ${selene_dir}/package/test_vcpkg
rm -rf build && mkdir -p build && cd build
cmake -G Ninja ${local_vcpkg_toolchain} ..

echo "- Building test project"
cmake --build . -j

echo "- Running test project"
./example
fi

echo "--------------------------------------------------"

echo "FINISHED."
8 changes: 8 additions & 0 deletions .azure-pipelines/ubuntu-18.04_clone_vcpkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

vcpkg_base_dir=$1
vcpkg_tag=$2

cd ${vcpkg_base_dir}
git clone https://github.com/Microsoft/vcpkg.git
git -C ${vcpkg_base_dir}/vcpkg checkout ${vcpkg_tag}
18 changes: 18 additions & 0 deletions .azure-pipelines/ubuntu-18.04_install_vcpkg_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

vcpkg_base_dir=$1
shift
vcpkg_libraries=$@

echo "vcpkg_base_dir=${vcpkg_base_dir}"
echo "vcpkg_libraries=${vcpkg_libraries}"
echo "CC=${CC}"
echo "CXX=${CXX}"
echo "CXXFLAGS=${CXXFLAGS}"
echo "LDFLAGS=${LDFLAGS}"

CC=gcc-8 CXX=g++-8 CXXFLAGS="" LDFLAGS="" ${vcpkg_base_dir}/vcpkg/bootstrap-vcpkg.sh
${vcpkg_base_dir}/vcpkg/vcpkg install ${vcpkg_libraries}
rm -rf ${vcpkg_base_dir}/vcpkg/buildtrees
rm -rf ${vcpkg_base_dir}/vcpkg/downloads
rm -rf ${vcpkg_base_dir}/vcpkg/packages
Loading

0 comments on commit aed3109

Please sign in to comment.