From e84469f2c6a6dae035dffdfd74e1560e185107f8 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Henson" Date: Mon, 11 Feb 2019 16:14:23 -0800 Subject: [PATCH] Fix downstream build script. (#246) Fix codebuild scripts to not need relative paths and use out of source builds. --- CMakeLists.txt | 15 ++++++--------- codebuild/ancient-linux-x64.yml | 6 +++--- codebuild/ancient-linux-x86.yml | 6 +++--- codebuild/common-posix.sh | 8 +++----- codebuild/common-windows.bat | 6 +++--- codebuild/downstream-posix.sh | 8 ++++---- codebuild/linux-clang3-x64.yml | 2 +- codebuild/linux-clang6-x64.yml | 2 +- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d44d2c81f..66e02b057 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" @@ -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 @@ -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) diff --git a/codebuild/ancient-linux-x64.yml b/codebuild/ancient-linux-x64.yml index f35bc136a..9c7de5ebd 100644 --- a/codebuild/ancient-linux-x64.yml +++ b/codebuild/ancient-linux-x64.yml @@ -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: diff --git a/codebuild/ancient-linux-x86.yml b/codebuild/ancient-linux-x86.yml index 6fdf8b7c6..c7a1d2d9c 100644 --- a/codebuild/ancient-linux-x86.yml +++ b/codebuild/ancient-linux-x86.yml @@ -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: diff --git a/codebuild/common-posix.sh b/codebuild/common-posix.sh index 08a928e36..a8f8b5571 100755 --- a/codebuild/common-posix.sh +++ b/codebuild/common-posix.sh @@ -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 .. diff --git a/codebuild/common-windows.bat b/codebuild/common-windows.bat index 0643e771f..aa3fc7357 100644 --- a/codebuild/common-windows.bat +++ b/codebuild/common-windows.bat @@ -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 diff --git a/codebuild/downstream-posix.sh b/codebuild/downstream-posix.sh index a48e4d340..cdac4aed0 100755 --- a/codebuild/downstream-posix.sh +++ b/codebuild/downstream-posix.sh @@ -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 @@ -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 @@ -72,7 +72,6 @@ do esac done -cd $home_dir if [ $clean ]; then rm -rf $build_dir fi @@ -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 diff --git a/codebuild/linux-clang3-x64.yml b/codebuild/linux-clang3-x64.yml index 895d03117..0fcb559f7 100644 --- a/codebuild/linux-clang3-x64.yml +++ b/codebuild/linux-clang3-x64.yml @@ -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` diff --git a/codebuild/linux-clang6-x64.yml b/codebuild/linux-clang6-x64.yml index ea851758a..7b5246c09 100644 --- a/codebuild/linux-clang6-x64.yml +++ b/codebuild/linux-clang6-x64.yml @@ -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: