[Commits] 302f8c2: MDEV-10847 Bring AWS KMS encryption plugin up-to-date with released SDK

wlad at mariadb.com wlad at mariadb.com
Fri Sep 23 22:31:56 EEST 2016


revision-id: 302f8c2ed91168accff35711a6e4c5ae12a03392 (mariadb-10.1.17-22-g302f8c2)
parent(s): 154969a0769aa8c2a2cbd2f29281a7ae85565cfe
author: Vladislav Vaintroub
committer: Vladislav Vaintroub
timestamp: 2016-09-23 21:31:44 +0200
message:

MDEV-10847 Bring AWS KMS encryption plugin up-to-date with released SDK

---
 plugin/aws_key_management/CMakeLists.txt           | 43 ++++++----------------
 .../aws_key_management_plugin.cc                   | 11 +++++-
 2 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt
index 97bcfbb..ecb5f9e 100644
--- a/plugin/aws_key_management/CMakeLists.txt
+++ b/plugin/aws_key_management/CMakeLists.txt
@@ -3,7 +3,7 @@
 # are
  
 # - OS : Windows,Linux or OSX
-# - C++11 compiler : VS2013+, gcc 4.7+, clang 3.3+
+# - C++11 compiler : VS2013+, gcc 4.8+, clang 3.3+
 # - libcurl development package needs to be present on Unixes
 #
 # If we build SDK outselves, we'll need require GIT to be present on the build machine
@@ -13,7 +13,10 @@
 # or if plugin is explicitely requested to build. Then bail out.
 MACRO(SKIP_AWS_PLUGIN msg)
   IF(VERBOSE OR "${PLUGIN_AWS_KEY_MANAGEMENT}" MATCHES "^(STATIC|DYNAMIC)$")
-    MESSAGE(STATUS "Skip aws_key_management - ${msg}")
+    MESSAGE(STATUS "Can't build aws_key_management - ${msg}")
+  ENDIF()
+  IF(TARGET aws_key_management)
+    MESSAGE(FATAL_ERROR "Error configuring aws_key_management - aborting")
   ENDIF()
   RETURN()
 ENDMACRO()
@@ -27,7 +30,7 @@ ENDIF()
 
 # This plugin needs recent C++ compilers (AWS C++ SDK header files are using C++11 features)
 SET(CXX11_FLAGS)
-SET(OLD_COMPILER_MSG "AWS SDK requires c++11 -capable compiler (minimal supported versions are g++ 4.7, clang 3.3, VS2103)")
+SET(OLD_COMPILER_MSG "AWS SDK requires c++11 -capable compiler (minimal supported versions are g++ 4.8, clang 3.3, VS2103)")
 
 IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
   EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
@@ -54,27 +57,6 @@ IF (NOT(WIN32 OR APPLE  OR (CMAKE_SYSTEM_NAME MATCHES "Linux")))
 ENDIF()
 
 
-# Figure out where AWS installs SDK libraries 
-# The below is defined in AWS SDK's CMakeLists.txt 
-# (and their handling is weird, every OS has special install directory)
-IF(WIN32)
-  SET(SDK_INSTALL_BINARY_PREFIX "windows")
-ELSEIF(APPLE)
-  SET(SDK_INSTALL_BINARY_PREFIX "mac")
-ELSEIF(UNIX)
-  SET(SDK_INSTALL_BINARY_PREFIX "linux")
-ENDIF()
-IF(NOT APPLE)
- IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
-   SET(SDK_INSTALL_BINARY_PREFIX "${SDK_INSTALL_BINARY_PREFIX}/intel64")
-  ELSE()
-   SET(SDK_INSTALL_BINARY_PREFIX "${SDK_INSTALL_BINARY_PREFIX}/ia32")
-  ENDIF()
-ENDIF()
-IF(CMAKE_CONFIGURATION_TYPES)
-  SET(SDK_INSTALL_BINARY_PREFIX "${SDK_INSTALL_BINARY_PREFIX}/${CMAKE_CFG_INTDIR}")
-ENDIF()
-
 FIND_LIBRARY(AWS_CPP_SDK_CORE NAMES aws-cpp-sdk-core PATH_SUFFIXES  "${SDK_INSTALL_BINARY_PREFIX}")
 FIND_LIBRARY(AWS_CPP_SDK_KMS NAMES aws-cpp-sdk-core PATH_SUFFIXES  "${SDK_INSTALL_BINARY_PREFIX}")
 SET(CMAKE_REQUIRED_FLAGS ${CXX11_FLAGS})
@@ -101,24 +83,23 @@ ELSE()
     SET(PIC_FLAG -fPIC)
   ENDIF()
   IF(MSVC)
-    SET(EXTRA_SDK_CMAKE_FLAGS -DCMAKE_CXX_FLAGS_DEBUGOPT="" -DCMAKE_EXE_LINKER_FLAGS_DEBUGOPT="" -DCMAKE_CXX_FLAGS=/wd4592)
+    SET(EXTRA_SDK_CMAKE_FLAGS -DCMAKE_CXX_FLAGS_DEBUGOPT="" -DCMAKE_EXE_LINKER_FLAGS_DEBUGOPT="" "-DCMAKE_CXX_FLAGS=/wd4530 /WX-")
   ENDIF()
   IF(CMAKE_CXX_COMPILER)
    SET(EXTRA_SDK_CMAKE_FLAGS ${EXTRA_SDK_CMAKE_FLAGS} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
   ENDIF()
 
-  # Relax AWS C++ SDK unreasonably high requirements for CMake version. Use replace utility (from MariaDB build)
-  # to patch their CMakeLists.txt
   SET(AWS_SDK_PATCH_COMMAND )
   ExternalProject_Add(
     aws_sdk_cpp
     GIT_REPOSITORY "https://github.com/awslabs/aws-sdk-cpp.git"
-    GIT_TAG "0.9.6" # single tag
+    GIT_TAG "1.0.8"
     UPDATE_COMMAND ""
-    PATCH_COMMAND replace 3.1.2 2.8 -- ${CMAKE_BINARY_DIR}/aws-sdk-cpp/CMakeLists.txt
     SOURCE_DIR "${CMAKE_BINARY_DIR}/aws-sdk-cpp"
     CMAKE_ARGS 
-    -DBUILD_ONLY=aws-cpp-sdk-kms -DSTATIC_LINKING=1 
+    -DBUILD_ONLY=kms
+    -DBUILD_SHARED_LIBS=OFF
+    -DFORCE_SHARED_CRT=OFF
     "-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} ${PIC_FLAG}"
     "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${PIC_FLAG}"
     "-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} ${PIC_FLAG}"
@@ -133,7 +114,7 @@ ELSE()
   FOREACH(lib ${AWS_SDK_LIBS})
     ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
     ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
-    SET(loc "${CMAKE_BINARY_DIR}/aws_sdk_cpp/lib/${SDK_INSTALL_BINARY_PREFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    SET(loc "${CMAKE_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
     SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
     IF(WIN32)
       SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "bcrypt;winhttp;wininet;userenv")
diff --git a/plugin/aws_key_management/aws_key_management_plugin.cc b/plugin/aws_key_management/aws_key_management_plugin.cc
index f4d3c7a..eed2b60 100644
--- a/plugin/aws_key_management/aws_key_management_plugin.cc
+++ b/plugin/aws_key_management/aws_key_management_plugin.cc
@@ -34,6 +34,7 @@
 #include <sstream>
 #include <fstream>
 
+#include <aws/core/Aws.h>
 #include <aws/core/client/AWSError.h>
 #include <aws/core/utils/logging/AWSLogging.h>
 #include <aws/core/utils/logging/ConsoleLogSystem.h>
@@ -148,13 +149,18 @@ class  MySQLLogSystem : public Aws::Utils::Logging::FormattedLogSystem
 static int plugin_init(void *p)
 {
   DBUG_ENTER("plugin_init");
+
+  Aws::SDKOptions options;
+  Aws::InitAPI(options);
+  InitializeAWSLogging(Aws::MakeShared<MySQLLogSystem>("aws_key_management_plugin", (Aws::Utils::Logging::LogLevel) log_level));
+
   client = new KMSClient();
   if (!client)
   {
     sql_print_error("Can not initialize KMS client");
     DBUG_RETURN(-1);
   }
-  InitializeAWSLogging(Aws::MakeShared<MySQLLogSystem>("aws_key_management_plugin", (Aws::Utils::Logging::LogLevel) log_level));
+  
 #ifdef HAVE_PSI_INTERFACE
   mysql_mutex_register("aws_key_management", &mtx_info, 1);
 #endif
@@ -189,6 +195,9 @@ static int plugin_deinit(void *p)
   mysql_mutex_destroy(&mtx);
   delete client;
   ShutdownAWSLogging();
+
+  Aws::SDKOptions options;
+  Aws::ShutdownAPI(options);
   DBUG_RETURN(0);
 }
 


More information about the commits mailing list