forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_all_examples.sh
executable file
·58 lines (50 loc) · 1.3 KB
/
build_all_examples.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
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# Build the AWS example code for C++ .
CMAKE_FILES=$(ls example_code/*/CMakeLists.txt)
HELLO_CMAKE_FILES=$(ls example_code/*/hello_*/CMakeLists.txt)
CMAKE_FILES="$CMAKE_FILES $HELLO_CMAKE_FILES"
CMAKE_FILES=($CMAKE_FILES)
echo "CMAKE_FILES ${CMAKE_FILES[@]}"
len=${#CMAKE_FILES[@]}
echo "len ${len}"
if [[ ${len} == 0 ]]; then
echo "No CMake files found!"
usage
fi
BASE_DIR=$(pwd)
echo "BASE_DIR ${BASE_DIR}"
BUILD_DIR="${BASE_DIR}/build"
echo "BUILD_DIR ${BUILD_DIR}"
mkdir -pv ${BUILD_DIR}
HAD_ERROR=false
for MAKE_FILE in "${CMAKE_FILES[@]}"
do
SOURCE_DIR="${MAKE_FILE%CMakeLists.txt}"
MODULE_BUILD_DIR="${BUILD_DIR}/${SOURCE_DIR}"
echo "MODULE_BUILD_DIR ${MODULE_BUILD_DIR}"
mkdir -pv "${MODULE_BUILD_DIR}"
cd "${MODULE_BUILD_DIR}"
echo "cmake ${BASE_DIR}/${SOURCE_DIR}"
cmake "${BASE_DIR}/${SOURCE_DIR}" -DBUILD_TESTS=ON
if [ $? != 0 ]; then
echo "ERROR with cmake ${$?}"
HAD_ERROR=true
continue
fi
cmake --build .
if [ $? != 0 ]; then
echo "ERROR with make ${$?}"
HAD_ERROR=true
continue
fi
done
echo
if [ $HAD_ERROR = true ]; then
echo "The build had errors."
exit 1
else
echo "The build was successful with no errors."
exit 0
fi