Skip to content

Commit

Permalink
apacheGH-37394: [C++][S3] Use AWS_SDK_VERSION_* instead of try_compile()
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 25, 2023
1 parent 4586689 commit 80e04a7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
10 changes: 0 additions & 10 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,6 @@ if(ARROW_FILESYSTEM)
list(APPEND ARROW_SRCS filesystem/hdfs.cc)
endif()
if(ARROW_S3)
try_compile(S3_HAS_CRT ${CMAKE_CURRENT_BINARY_DIR}/try_compile
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/filesystem/try_compile/check_s3fs_crt.cc"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CURRENT_INCLUDE_DIRECTORIES}"
LINK_LIBRARIES ${AWSSDK_LINK_LIBRARIES} CXX_STANDARD 17)

if(S3_HAS_CRT)
message(STATUS "AWS SDK is new enough to have CRT support")
add_definitions(-DARROW_S3_HAS_CRT)
endif()

list(APPEND ARROW_SRCS filesystem/s3fs.cc)
set_source_files_properties(filesystem/s3fs.cc
PROPERTIES SKIP_PRECOMPILE_HEADERS ON
Expand Down
36 changes: 28 additions & 8 deletions cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

#include <aws/core/Aws.h>
#include <aws/core/Region.h>
#include <aws/core/VersionConfig.h>
#include <aws/core/auth/AWSCredentials.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/auth/STSCredentialsProvider.h>
Expand All @@ -53,11 +54,6 @@
#include <aws/core/utils/logging/ConsoleLogSystem.h>
#include <aws/core/utils/stream/PreallocatedStreamBuf.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#ifdef ARROW_S3_HAS_CRT
#include <aws/crt/io/Bootstrap.h>
#include <aws/crt/io/EventLoopGroup.h>
#include <aws/crt/io/HostResolver.h>
#endif
#include <aws/identity-management/auth/STSAssumeRoleCredentialsProvider.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/S3Errors.h>
Expand All @@ -80,6 +76,32 @@
#include <aws/s3/model/PutObjectRequest.h>
#include <aws/s3/model/UploadPartRequest.h>

// AWS_SDK_VERSION_{MAJOR,MINOR,PATCH} are available since 1.9.7.
#if defined(AWS_SDK_VERSION_MAJOR) && defined(AWS_SDK_VERSION_MINOR) && \
defined(AWS_SDK_VERSION_PATCH)
#define ARROW_AWS_SDK_VERSION_CHECK(major, minor, patch) \
(AWS_SDK_VERSION_MAJOR > (major) || \
(AWS_SDK_VERSION_MAJOR == (major) && AWS_SDK_VERSION_MINOR > (minor)) || \
(AWS_SDK_VERSION_MAJOR == (major) && AWS_SDK_VERSION_MINOR == (minor) && \
AWS_SDK_VERSION_PATCH >= (patch)))
#else
#define ARROW_AWS_SDK_VERSION_CHECK(major, minor, patch) 0
#endif

// This feature is available since 1.9.0 but
// AWS_SDK_VERSION_{MAJOR,MINOR,PATCH} are available since 1.9.7. So
// we can't use this feature for [1.9.0,1.9.6]. If it's a problem,
// please report it to our issue tracker.
#if ARROW_AWS_SDK_VERSION_CHECK(1, 9, 0)
#define ARROW_S3_HAS_CRT
#endif

#ifdef ARROW_S3_HAS_CRT
#include <aws/crt/io/Bootstrap.h>
#include <aws/crt/io/EventLoopGroup.h>
#include <aws/crt/io/HostResolver.h>
#endif

#include "arrow/util/windows_fixup.h"

#include "arrow/buffer.h"
Expand Down Expand Up @@ -2913,9 +2935,7 @@ struct AwsInstance {
return std::make_shared<Aws::Utils::Logging::ConsoleLogSystem>(
aws_options_.loggingOptions.logLevel);
};
#if (defined(AWS_SDK_VERSION_MAJOR) && \
(AWS_SDK_VERSION_MAJOR > 1 || AWS_SDK_VERSION_MINOR > 9 || \
(AWS_SDK_VERSION_MINOR == 9 && AWS_SDK_VERSION_PATCH >= 272)))
#if ARROW_AWS_SDK_VERSION_CHECK(1, 9, 272)
// ARROW-18290: escape all special chars for compatibility with non-AWS S3 backends.
// This configuration options is only available with AWS SDK 1.9.272 and later.
aws_options_.httpOptions.compliantRfc3986Encoding = true;
Expand Down
28 changes: 0 additions & 28 deletions cpp/src/arrow/filesystem/try_compile/check_s3fs_crt.cc

This file was deleted.

0 comments on commit 80e04a7

Please sign in to comment.