Skip to content

Commit fb4c1bd

Browse files
authored
continuous integration (#36)
Add continuous integration to ensure builds are working
1 parent 2a615fc commit fb4c1bd

17 files changed

+253
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ cmake -DCMAKE_INSTALL_PREFIX="<path to where you install>" -DCMAKE_PREFIX_PATH="
4444
cmake --build . --target install
4545
```
4646

47+
Note: If you are updating an existing installation of `aws-crt-cpp`, you must delete and recreate `aws-crt-cpp-build` or it will not build correctly.
48+
4749
# Samples
4850

4951
## Shadow

codebuild/common-posix.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Using CC=$CC CXX=$CXX"
6+
7+
BUILD_PATH=/tmp/builds
8+
mkdir -p $BUILD_PATH
9+
INSTALL_PATH=$BUILD_PATH/install
10+
mkdir -p $INSTALL_PATH
11+
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=$INSTALL_PATH -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH $@"
12+
13+
# If TRAVIS_OS_NAME is OSX, skip this step (will resolve to empty string on CodeBuild)
14+
if [ "$TRAVIS_OS_NAME" != "osx" ]; then
15+
sudo apt-get install libssl-dev -y
16+
fi
17+
18+
# build aws-crt-cpp
19+
pushd $BUILD_PATH
20+
git clone --branch v0.4.0 https://github.com/awslabs/aws-crt-cpp.git
21+
cd aws-crt-cpp
22+
cmake $CMAKE_ARGS -DBUILD_DEPS=ON ./
23+
cmake --build . --target install
24+
popd
25+
26+
# build SDK
27+
mkdir -p build
28+
pushd build
29+
cmake $CMAKE_ARGS ../
30+
cmake --build . --target install
31+
popd

codebuild/common-windows.bat

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set CMAKE_ARGS=%*
2+
3+
set BUILDS_DIR=%TEMP%\builds
4+
set INSTALL_DIR=%BUILDS_DIR%\install
5+
mkdir %BUILDS_DIR%
6+
mkdir %INSTALL_DIR%
7+
8+
@rem build aws-crt-cpp
9+
mkdir %BUILDS_DIR%\aws-crt-cpp-build
10+
cd %BUILDS_DIR%\aws-crt-cpp-build
11+
git clone --branch v0.4.0 https://github.com/awslabs/aws-crt-cpp.git
12+
cmake %CMAKE_ARGS% -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%" -DCMAKE_PREFIX_PATH="%INSTALL_DIR%" -DCMAKE_BUILD_TYPE="Release" -DBUILD_DEPS=ON aws-crt-cpp || goto error
13+
cmake --build . --target install || goto error
14+
15+
@rem build SDK
16+
mkdir %BUILDS_DIR%\aws-iot-device-sdk-cpp-v2-build
17+
cd %BUILDS_DIR%\aws-iot-device-sdk-cpp-v2-build
18+
cmake %CMAKE_ARGS% -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%" -DCMAKE_PREFIX_PATH="%INSTALL_DIR%" -DCMAKE_BUILD_TYPE="Release" %CODEBUILD_SRC_DIR% || goto error
19+
cmake --build . || goto error
20+
21+
goto :EOF
22+
23+
:error
24+
echo Failed with error #%errorlevel%.
25+
exit /b %errorlevel%

codebuild/linux-clang3-x64.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 0.2
2+
#this buildspec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- sudo apt-get update -y
7+
- sudo apt-get update
8+
- sudo apt-get install clang-3.9 clang-tidy-3.9 -y
9+
10+
pre_build:
11+
commands:
12+
- export CC=clang-3.9
13+
- export CXX=clang++-3.9
14+
build:
15+
commands:
16+
- echo Build started on `date`
17+
- ./codebuild/common-posix.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
18+
- clang-tidy-3.9 -p=build **/*.c
19+
post_build:
20+
commands:
21+
- echo Build completed on `date`
22+

codebuild/linux-clang6-x64.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 0.2
2+
#this buildspec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
7+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
8+
- sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
9+
- sudo apt-get update -y
10+
- sudo apt-get install clang-6.0 clang-tidy-6.0 clang-format-6.0 -y -f
11+
12+
pre_build:
13+
commands:
14+
- export CC=clang-6.0
15+
- export CXX=clang++-6.0
16+
- export CLANG_FORMAT=clang-format-6.0
17+
build:
18+
commands:
19+
- echo Build started on `date`
20+
- ./codebuild/common-posix.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
21+
- ./format-check.sh
22+
post_build:
23+
commands:
24+
- echo Build completed on `date`
25+

codebuild/linux-gcc-4x-x64.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 0.2
2+
#this build spec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- sudo apt-get update -y
7+
- sudo apt-get install gcc g++ -y
8+
pre_build:
9+
commands:
10+
- export CC=gcc
11+
- export CXX=g++
12+
build:
13+
commands:
14+
- echo Build started on `date`
15+
- ./codebuild/common-posix.sh
16+
post_build:
17+
commands:
18+
- echo Build completed on `date`
19+

codebuild/linux-gcc-4x-x86.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 0.2
2+
#this build spec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- sudo apt-get update -y
7+
- sudo apt-get install gcc gcc-multilib g++ g++-multilib -y
8+
# Build OpenSSL from source
9+
- mkdir libcrypto-build
10+
- cd libcrypto-build
11+
- curl -LO https://www.openssl.org/source/openssl-1.1.0j.tar.gz
12+
- tar -xzvf openssl-1.1.0j.tar.gz
13+
- cd openssl-1.1.0j
14+
- setarch i386 ./config -fPIC no-shared \
15+
-m32 no-md2 no-rc5 no-rfc3779 no-sctp no-ssl-trace no-zlib \
16+
no-hw no-mdc2 no-seed no-idea no-camellia\
17+
no-bf no-ripemd no-dsa no-ssl2 no-ssl3 no-capieng \
18+
-DSSL_FORBID_ENULL -DOPENSSL_NO_DTLS1 -DOPENSSL_NO_HEARTBEATS \
19+
--prefix=/tmp/builds/install
20+
- make -j 12
21+
- make install_sw
22+
- cd $CODEBUILD_SRC_DIR
23+
24+
pre_build:
25+
commands:
26+
- export CC=gcc
27+
- export CXX=g++
28+
build:
29+
commands:
30+
- echo Build started on `date`
31+
- ./codebuild/common-posix.sh -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"
32+
33+
post_build:
34+
commands:
35+
- echo Build completed on `date`
36+

codebuild/linux-gcc-5x-x64.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 0.2
2+
#this build spec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
7+
- sudo apt-get update -y
8+
- sudo apt-get install gcc-5 g++-5 -y
9+
pre_build:
10+
commands:
11+
- export CC=gcc-5
12+
- export CXX=g++-5
13+
build:
14+
commands:
15+
- echo Build started on `date`
16+
- ./codebuild/common-posix.sh
17+
post_build:
18+
commands:
19+
- echo Build completed on `date`
20+

codebuild/linux-gcc-6x-x64.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 0.2
2+
#this build spec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
7+
- sudo apt-get update -y
8+
- sudo apt-get install gcc-6 g++-6 -y
9+
pre_build:
10+
commands:
11+
- export CC=gcc-6
12+
- export CXX=g++-6
13+
build:
14+
commands:
15+
- echo Build started on `date`
16+
- ./codebuild/common-posix.sh
17+
post_build:
18+
commands:
19+
- echo Build completed on `date`
20+

codebuild/linux-gcc-7x-x64.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 0.2
2+
#this build spec assumes the ubuntu 14.04 trusty image
3+
phases:
4+
install:
5+
commands:
6+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
7+
- sudo apt-get update -y
8+
- sudo apt-get install gcc-7 g++-7 -y
9+
pre_build:
10+
commands:
11+
- export CC=gcc-7
12+
- export CXX=g++-7
13+
build:
14+
commands:
15+
- echo Build started on `date`
16+
- ./codebuild/common-posix.sh
17+
post_build:
18+
commands:
19+
- echo Build completed on `date`
20+

codebuild/windows-msvc-2015-x86.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 0.2
2+
3+
phases:
4+
build:
5+
commands:
6+
- .\codebuild\common-windows.bat -G "Visual Studio 14 2015"
7+

codebuild/windows-msvc-2015.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 0.2
2+
3+
phases:
4+
build:
5+
commands:
6+
- .\codebuild\common-windows.bat -G "Visual Studio 14 2015 Win64"
7+

codebuild/windows-msvc-2017.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 0.2
2+
3+
phases:
4+
build:
5+
commands:
6+
- .\codebuild\common-windows.bat -G "Visual Studio 15 2017 Win64"
7+

format-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if NOT type $CLANG_FORMAT 2> /dev/null ; then
1010
fi
1111

1212
FAIL=0
13-
SOURCE_FILES=`find discovery jobs shadow -type f \( -name '*.h' -o -name '*.cpp' \)`
13+
SOURCE_FILES=`find discovery jobs shadow samples -type f \( -name '*.h' -o -name '*.cpp' \)`
1414
for i in $SOURCE_FILES
1515
do
1616
$CLANG_FORMAT -output-replacements-xml $i | grep -c "<replacement " > /dev/null

samples/greengrass/basic_discovery/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,12 @@ int main(int argc, char *argv[])
291291
}
292292
else
293293
{
294-
fprintf(stderr, "Discover failed with error: %s, and http response code %d\n",
295-
aws_error_debug_str(error), httpResponseCode);
294+
fprintf(
295+
stderr,
296+
"Discover failed with error: %s, and http response code %d\n",
297+
aws_error_debug_str(error),
298+
httpResponseCode);
296299
exit(-1);
297-
298300
}
299301
});
300302

samples/jobs/describe_job_execution/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ int main(int argc, char *argv[])
130130
}
131131

132132
auto clientConfig = Aws::Iot::MqttClientConnectionConfigBuilder(certificatePath.c_str(), keyPath.c_str())
133-
.WithEndpoint(endpoint)
134-
.WithCertificateAuthority(caFile.c_str())
135-
.Build();
133+
.WithEndpoint(endpoint)
134+
.WithCertificateAuthority(caFile.c_str())
135+
.Build();
136136

137137
if (!clientConfig)
138138
{

samples/shadow/shadow_sync/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ int main(int argc, char *argv[])
170170
}
171171

172172
auto clientConfig = Aws::Iot::MqttClientConnectionConfigBuilder(certificatePath.c_str(), keyPath.c_str())
173-
.WithEndpoint(endpoint)
174-
.WithCertificateAuthority(caFile.c_str())
175-
.Build();
173+
.WithEndpoint(endpoint)
174+
.WithCertificateAuthority(caFile.c_str())
175+
.Build();
176176

177177
if (!clientConfig)
178178
{

0 commit comments

Comments
 (0)