From 6e3989f0ee65772a1b5b8a1c692cd41f64a3eb8f Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Sat, 15 Jul 2023 16:57:19 -0700 Subject: [PATCH] Fix warnings in headers (#500) --- .builder/actions/build_crt.py | 3 -- .github/workflows/ci.yml | 35 +++++++++-------- CMakeLists.txt | 8 ++-- cmake/AwsCheckHeadersCxx.cmake | 71 ---------------------------------- 4 files changed, 24 insertions(+), 93 deletions(-) delete mode 100644 cmake/AwsCheckHeadersCxx.cmake diff --git a/.builder/actions/build_crt.py b/.builder/actions/build_crt.py index 0d14bfe03..6bc3703ad 100644 --- a/.builder/actions/build_crt.py +++ b/.builder/actions/build_crt.py @@ -26,9 +26,6 @@ def _transform_cmake_args(self, env, project, cmake_args): # remove or swap out flags that we don't want for C++ for arg in cmake_args: - # we want to use PERFORM_HEADER_CHECK_CXX instead of PERFORM_HEADER_CHECK - if arg == "-DPERFORM_HEADER_CHECK=ON": - arg = "-DPERFORM_HEADER_CHECK_CXX=ON" if (arg == "-DUSE_OPENSSL=ON"): is_using_openssl = True diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e73bb0228..8bc3fa1a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: # that are up-to-date (AL2) or don't provide OpenSSL development packages that is found in CMake (alpine) # or are not able to connect on the socket even with the correct setup (manylinux2014) linux-compat: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest strategy: matrix: image: @@ -59,7 +59,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} linux-compiler-compat: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest strategy: matrix: compiler: @@ -99,7 +99,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} std-compat: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest strategy: matrix: compiler: [gcc-8, clang-9] @@ -113,7 +113,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} --cmake-extra=-DUSE_OPENSSL=ON byo-crypto: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} @@ -122,7 +122,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBYO_CRYPTO=ON --cmake-extra=-DUSE_OPENSSL=ON linux-shared-libs: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} @@ -131,7 +131,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON linux-openssl-static: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} @@ -140,7 +140,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --variant=openssl --cmake-extra=-DUSE_OPENSSL=ON linux-openssl-shared: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} @@ -149,7 +149,7 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --variant=openssl --cmake-extra=-DUSE_OPENSSL=ON --cmake-extra=-DBUILD_SHARED_LIBS=ON linux-no-cpu-extensions: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} @@ -171,14 +171,14 @@ jobs: runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) strategy: matrix: - arch: [Win32, x64] + arch: [x86, x64] steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | md D:\a\work cd D:\a\work python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --compiler msvc-14 --target windows-${{ matrix.arch }} windows-shared-libs: runs-on: windows-2022 # latest @@ -217,7 +217,7 @@ jobs: python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF osx: - runs-on: macos-11 # latest + runs-on: macos-13 # latest steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -229,7 +229,7 @@ jobs: # it would be better to run tests natively on one of these machines, # but we don't have access to one in the cloud, so for now just cross-compile osx-arm64-cross-compile: - runs-on: macos-11 # latest + runs-on: macos-13 # latest steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -238,8 +238,11 @@ jobs: ./builder build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DCMAKE_OSX_ARCHITECTURES=arm64 run_tests=false test `lipo aws-crt-cpp/build/install/lib/libaws-crt-cpp.a -archs` = "arm64" + # cross-compile for iOS + # Skip signing the code on iOS. + # Otherwise it will not compile with error that Bundle identifier is missing. ios-cross-compile: - runs-on: macos-11 # latest + runs-on: macos-13 # latest steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -249,7 +252,7 @@ jobs: cross_compile: name: Cross Compile ${{matrix.arch}} - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest strategy: matrix: arch: [linux-armv6, linux-armv7, linux-arm64, android-armv7] @@ -263,7 +266,7 @@ jobs: # check that docs can still build check-docs: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: - uses: actions/checkout@v2 with: @@ -274,7 +277,7 @@ jobs: ./make-docs.py check-submodules: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-22.04 # latest steps: - name: Checkout Source uses: actions/checkout@v2 diff --git a/CMakeLists.txt b/CMakeLists.txt index e90c6394a..151c8fcf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,6 @@ project("aws-crt-cpp" LANGUAGES CXX C VERSION ${SIMPLE_VERSION}) -include(AwsCheckHeadersCxx) include(CTest) if(DEFINED CMAKE_PREFIX_PATH) @@ -183,7 +182,10 @@ file(GLOB AWS_CRT_PUBLIC_HEADERS ${AWS_CRT_ENDPOINT_HEADERS} ) -aws_check_headers_cxx(${PROJECT_NAME} ${AWS_CRT_PUBLIC_HEADERS}) +if(BUILD_DEPS) + include(AwsCheckHeaders) + aws_check_headers(${PROJECT_NAME} IS_CXX ${AWS_CRT_PUBLIC_HEADERS}) +endif() file(GLOB AWS_CRT_CPP_HEADERS ${AWS_CRT_PUBLIC_HEADERS} @@ -291,7 +293,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug) target_compile_definitions(${PROJECT_NAME} PRIVATE "-DDEBUG_BUILD") endif() - # set extra warning flags +# set extra warning flags if(AWS_WARNINGS_ARE_ERRORS) if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX /wd4068) diff --git a/cmake/AwsCheckHeadersCxx.cmake b/cmake/AwsCheckHeadersCxx.cmake deleted file mode 100644 index 2b475da91..000000000 --- a/cmake/AwsCheckHeadersCxx.cmake +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0. - -# This cmake logic verifies that each of our headers is complete, in that it -# includes any necessary dependencies, and builds with each supported c++ standard. -# -# To do so, we generate a single-line C or C++ source file that includes each -# header, and link all of these stub source files into a test executable. - -option(PERFORM_HEADER_CHECK_CXX "Performs compile-time checks that each header can be included independently.") - -# Call as: aws_check_headers_cxx(${target} HEADERS TO CHECK LIST) -function(aws_check_headers_cxx target) - # Check headers against each supported CXX_STANDARD - if (PERFORM_HEADER_CHECK_CXX) - aws_check_headers_cxx_internal(${target} 11 ${ARGN}) - aws_check_headers_cxx_internal(${target} 14 ${ARGN}) - aws_check_headers_cxx_internal(${target} 17 ${ARGN}) - aws_check_headers_cxx_internal(${target} 20 ${ARGN}) - aws_check_headers_cxx_internal(${target} 23 ${ARGN}) - endif () -endfunction() - -function(aws_check_headers_cxx_internal target std) - # Check that compiler supports this std - list (FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_${std}" feature_idx) - if (${feature_idx} LESS 0) - return() - endif() - - # MSVC's c++ 20 has issues with templates - if (MSVC AND NOT ${std} LESS 20) - return() - endif() - - set(HEADER_CHECKER_ROOT "${CMAKE_CURRENT_BINARY_DIR}/header-checker-cxx-${std}") - - # Write stub main file - set(HEADER_CHECKER_MAIN "${HEADER_CHECKER_ROOT}/stub.cpp") - file(WRITE ${HEADER_CHECKER_MAIN} " - int main(int argc, char **argv) { - (void)argc; - (void)argv; - - return 0; - }") - - set(HEADER_CHECKER_LIB ${target}-header-check-cxx-${std}) - add_executable(${HEADER_CHECKER_LIB} ${HEADER_CHECKER_MAIN}) - target_link_libraries(${HEADER_CHECKER_LIB} ${target}) - target_compile_definitions(${HEADER_CHECKER_LIB} PRIVATE AWS_UNSTABLE_TESTING_API=1 AWS_HEADER_CHECKER=1) - - set_target_properties(${HEADER_CHECKER_LIB} PROPERTIES - LINKER_LANGUAGE CXX - CXX_STANDARD ${std} - CXX_STANDARD_REQUIRED OFF - ) - - foreach(header IN LISTS ARGN) - if (NOT ${header} MATCHES "\\.inl$") - file(RELATIVE_PATH rel_header ${CMAKE_HOME_DIRECTORY} ${header}) - file(RELATIVE_PATH include_path "${CMAKE_HOME_DIRECTORY}/include" ${header}) - set(stub_dir "${HEADER_CHECKER_ROOT}/${rel_header}") - file(MAKE_DIRECTORY "${stub_dir}") - # include file twice to ensure header guards are present - file(WRITE "${stub_dir}/check.cpp" "#include <${include_path}>\n#include <${include_path}>\n") - - target_sources(${HEADER_CHECKER_LIB} PUBLIC "${stub_dir}/check.cpp") - endif() - endforeach(header) -endfunction()