Skip to content

Commit

Permalink
Fix downstream build script. (#246)
Browse files Browse the repository at this point in the history
Fix codebuild scripts to not need relative paths and use out of source builds.
  • Loading branch information
JonathanHenson authored Feb 12, 2019
1 parent 9d5644f commit e84469f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 29 deletions.
15 changes: 6 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ file(GLOB AWS_COMMON_HEADERS
"include/aws/common/*.h"
"include/aws/common/*.inl"
)
# The generated config header doesn't exist yet, so don't use GLOB to try to find it
# (as it'll skip the file if it doesn't exist yet)
set(AWS_COMMON_HEADERS ${AWS_COMMON_HEADERS} ${GENERATED_CONFIG_HEADER})

file(GLOB AWS_TEST_HEADERS
"include/aws/testing/*.h"
Expand Down Expand Up @@ -153,7 +150,7 @@ if (HAVE_AVX2_INTRINSICS AND HAVE_SIMD_CPUID)
endif()

# Preserve subdirectories when installing headers
foreach(HEADER_SRCPATH IN ITEMS ${AWS_COMMON_HEADERS} ${AWS_COMMON_OS_HEADERS} ${AWS_TEST_HEADERS})
foreach(HEADER_SRCPATH IN ITEMS ${AWS_COMMON_HEADERS} ${AWS_COMMON_OS_HEADERS} ${GENERATED_CONFIG_HEADER} ${AWS_TEST_HEADERS})
get_filename_component(HEADER_DIR ${HEADER_SRCPATH} DIRECTORY)
# Note: We need to replace the generated include directory component first, otherwise if the build
# directory is located inside the source tree, we'll partially rewrite the path and fail to replace it
Expand Down Expand Up @@ -210,14 +207,14 @@ install(FILES ${EXPORT_MODULES}
DESTINATION "${LIBRARY_DIRECTORY}/cmake"
COMPONENT Development)

# This should come last, to ensure all variables defined by cmake will be available for export
configure_file(${CONFIG_HEADER_TEMPLATE}
${GENERATED_CONFIG_HEADER}
ESCAPE_QUOTES)

if (NOT CMAKE_CROSSCOMPILING)
include(CTest)
add_subdirectory(tests)
endif()

# This should come last, to ensure all variables defined by cmake will be available for export
configure_file(${CONFIG_HEADER_TEMPLATE}
${GENERATED_CONFIG_HEADER}
ESCAPE_QUOTES)

include(CPackConfig)
6 changes: 3 additions & 3 deletions codebuild/ancient-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ phases:
build:
commands:
- echo Build started on `date`
- mkdir build
- cd build
- cmake ../
- mkdir /tmp/build
- cd /tmp/build
- cmake $CODEBUILD_SRC_DIR
- make
- ctest . --output-on-failure
post_build:
Expand Down
6 changes: 3 additions & 3 deletions codebuild/ancient-linux-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ phases:
build:
commands:
- echo Build started on `date`
- mkdir build
- cd build
- cmake ../
- mkdir /tmp/build
- cd /tmp/build
- cmake $CODEBUILD_SRC_DIR
- make
- ctest . --output-on-failure
post_build:
Expand Down
8 changes: 3 additions & 5 deletions codebuild/common-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

set -e

mkdir build
cd build
mkdir /tmp/build
cd /tmp/build

cmake -DPERFORM_HEADER_CHECK=ON -DENABLE_SANITIZERS=ON $@ ../
cmake -DPERFORM_HEADER_CHECK=ON -DENABLE_SANITIZERS=ON $@ $CODEBUILD_SRC_DIR
make
ctest . --output-on-failure

cd ..
6 changes: 3 additions & 3 deletions codebuild/common-windows.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

mkdir build
cd build
cmake %* -DPERFORM_HEADER_CHECK=ON -DCMAKE_BUILD_TYPE="Release" ../ || goto error
mkdir %TEMP%\build
cd %TEMP%\build
cmake %* -DPERFORM_HEADER_CHECK=ON -DCMAKE_BUILD_TYPE="Release" %CODEBUILD_SRC_DIR% || goto error
msbuild.exe aws-c-common.vcxproj /p:Configuration=Release || goto error
msbuild.exe tests/aws-c-common-assert-tests.vcxproj /p:Configuration=Release
msbuild.exe tests/aws-c-common-tests.vcxproj /p:Configuration=Release
Expand Down
8 changes: 4 additions & 4 deletions codebuild/downstream-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
set -e
set -x

# everything is relative to the project root, which should be above this directory
home_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null && pwd )"

home_dir="/tmp"

# where to have cmake put its binaries
build_dir=$home_dir/build/downstream
Expand All @@ -22,7 +22,7 @@ function cmake_project {
pushd $proj_dir
mkdir -p ci-build
cd ci-build
cmake -G"Unix Makefiles" $cmake_args -DCMAKE_INSTALL_PREFIX=$install_prefix ..
cmake -G"Unix Makefiles" $cmake_args -DCMAKE_PREFIX_PATH=$install_prefix -DCMAKE_INSTALL_PREFIX=$install_prefix ..
cmake --build . --target all
cmake --build . --target install
if [[ $cmake_args != *"-DBUILD_TESTING=OFF"* ]]; then
Expand Down Expand Up @@ -72,7 +72,6 @@ do
esac
done

cd $home_dir
if [ $clean ]; then
rm -rf $build_dir
fi
Expand All @@ -90,6 +89,7 @@ fi
cmake_project .

# build master head rev of downstream projects
cd $home_dir
build_project aws-checksums
build_project aws-c-event-stream
build_project aws-c-io
Expand Down
2 changes: 1 addition & 1 deletion codebuild/linux-clang3-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ phases:
commands:
- echo Build started on `date`
- ./codebuild/common-posix.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- clang-tidy-3.9 -p=build **/*.c
- clang-tidy-3.9 -p=/tmp/build **/*.c
post_build:
commands:
- echo Build completed on `date`
Expand Down
2 changes: 1 addition & 1 deletion codebuild/linux-clang6-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ phases:
commands:
- echo Build started on `date`
- ./codebuild/common-posix.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_FUZZ_TESTS=ON
- clang-tidy-6.0 -p=build **/*.c
- clang-tidy-6.0 -p=/tmp/build **/*.c
- ./format-check.sh
post_build:
commands:
Expand Down

0 comments on commit e84469f

Please sign in to comment.