-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_and_test.sh
executable file
·83 lines (68 loc) · 2.61 KB
/
build_and_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# HAL
#
# Copyright (c) 2014 by Appcelerator, Inc. All Rights Reserved.
# Licensed under the terms of the Apache Public License.
# Please see the LICENSE included with this distribution for details.
set -e
# check and see if we already have it installed in our local directory
if test -d "`pwd`/gtest-1.7.0"; then
echo "Found local gtest-1.7.0, setting GTEST_ROOT"
declare -x GTEST_ROOT="`pwd`/gtest-1.7.0"
fi
# if not found, install it
if ! test -d "${GTEST_ROOT}"; then
if [[ ${CMAKE_HOST_WIN32} != 0 ]]; then
echo "Installing GTest ... one moment"
echo
curl -O http://timobile.appcelerator.com.s3.amazonaws.com/gtest-1.7.0-osx.zip
unzip gtest-1.7.0-osx.zip
rm -rf gtest-1.7.0-osx.zip
declare -x GTEST_ROOT="`pwd`/gtest-1.7.0"
else
echo "GTEST_ROOT must point to your Google Test installation."
exit 1
fi
fi
declare -rx VERBOSE=1
declare -r HAL_DISABLE_TESTS="OFF"
cmd+="cmake"
cmd+=" -DHAL_DISABLE_TESTS=${HAL_DISABLE_TESTS}"
declare -r CMAKE_HOST_WIN32=$(cmake -P cmake/IsWin32.cmake 2>&1 | tr -d '\r\n')
if [[ x"${CMAKE_HOST_WIN32}" == "x1" ]]; then
declare -r project_name=$(grep -E '^\s*project[(][^)]+[)]\s*$' CMakeLists.txt | awk 'BEGIN {FS="[()]"} {printf "%s", $2}')
declare -r solution_file_name="${project_name}.sln"
declare -r MSBUILD_PATH="c:/Program Files (x86)/MSBuild/12.0/Bin/MSBuild.exe"
declare -r BUILD_DIR="build"
cmd+=" ../"
cmd+=" && \"${MSBUILD_PATH}\" ${solution_file_name}"
else
declare -r CMAKE_BUILD_TYPE=Debug
declare -r BUILD_DIR=build.$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')
cmd+=" -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
cmd+=" ../"
cmd+=" && make -j 4"
fi
function echo_and_eval {
local -r cmd="${1:?}"
echo "${cmd}" && eval "${cmd}"
}
echo_and_eval "rm -rf \"${BUILD_DIR}\""
echo_and_eval "mkdir -p \"${BUILD_DIR}\""
echo_and_eval "pushd \"${BUILD_DIR}\""
echo_and_eval "${cmd}"
if [[ x"${CMAKE_HOST_WIN32}" == "x1" ]]; then
# On Windows we need to copy the DLL to the location of the
# executables.
declare -r dll_paths=$(find . -type f -name "*.dll" | sort | uniq | awk '{printf "\"%s\" ", $1}')
declare -r exe_directories=$(find ./test ./examples -type f -name "*.exe" -exec dirname {} \; | sort | uniq | awk '{printf "\"%s\" ", $0}')
for exe_directory in ${exe_directories}; do
for dll_path in ${dll_paths}; do
echo_and_eval "cp -p ${dll_path} ${exe_directory}"
done
done
fi
if [[ "${HAL_DISABLE_TESTS}" != "ON" ]]; then
echo_and_eval "ctest -VV --output-on-failure"
fi
echo_and_eval "popd"