Skip to content

Commit

Permalink
Collected fixes related to bugs #280, #302, #783, #696 and 317 all to…
Browse files Browse the repository at this point in the history
…gether. (#479) (#481)

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
(cherry picked from commit 646ce3c)

Co-authored-by: Yury-Fridlyand <88679692+Yury-Fridlyand@users.noreply.github.com>
  • Loading branch information
1 parent 4401791 commit df9b314
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 9 deletions.
15 changes: 12 additions & 3 deletions sql-odbc/scripts/build_aws-sdk-cpp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ $WIN_ARCH = $args[1]
$SRC_DIR = $args[2]
$BUILD_DIR = $args[3]
$INSTALL_DIR = $args[4]
$VCPKG_DIR = $args[5]
$LIBCURL_WIN_ARCH = $args[6]

Write-Host $args

# Clone the AWS SDK CPP repo
$SDK_VER = "1.8.186"
# -b "$SDK_VER" `
$SDK_VER = "1.9.199"

git clone `
--branch `
$SDK_VER `
--single-branch `
"https://github.com/aws/aws-sdk-cpp.git" `
--recurse-submodules `
$SRC_DIR

# Make and move to build directory
Expand All @@ -23,13 +26,19 @@ Set-Location $BUILD_DIR
# Configure and build
cmake $SRC_DIR `
-A $WIN_ARCH `
-D CMAKE_VERBOSE_MAKEFILE=ON `
-D CMAKE_INSTALL_PREFIX=$INSTALL_DIR `
-D CMAKE_BUILD_TYPE=$CONFIGURATION `
-D BUILD_ONLY="core" `
-D ENABLE_UNITY_BUILD="ON" `
-D CUSTOM_MEMORY_MANAGEMENT="OFF" `
-D ENABLE_RTTI="OFF" `
-D ENABLE_TESTING="OFF"
-D ENABLE_TESTING="OFF" `
-D FORCE_CURL="ON" `
-D ENABLE_CURL_CLIENT="ON" `
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake" `
-D CURL_LIBRARY="${VCPKG_DIR}/packages/curl_${LIBCURL_WIN_ARCH}-windows/lib" `
-D CURL_INCLUDE_DIR="${VCPKG_DIR}/packages/curl_${LIBCURL_WIN_ARCH}-windows/include/"

# Build AWS SDK and install to $INSTALL_DIR
msbuild ALL_BUILD.vcxproj /m /p:Configuration=$CONFIGURATION
Expand Down
11 changes: 11 additions & 0 deletions sql-odbc/scripts/build_libcurl-vcpkg.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$SRC_DIR = $args[0]
$LIBCURL_WIN_ARCH = $args[1]

if (!("${SRC_DIR}/packages/curl_${LIBCURL_WIN_ARCH}-windows" | Test-Path))
{
git clone https://github.com/Microsoft/vcpkg.git $SRC_DIR
Set-Location $SRC_DIR
cmd.exe /c bootstrap-vcpkg.bat
.\vcpkg.exe integrate install
.\vcpkg.exe install curl[tool]:${LIBCURL_WIN_ARCH}-windows
}
16 changes: 15 additions & 1 deletion sql-odbc/scripts/build_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,34 @@ if ($BITNESS -eq "64") {
else {
$WIN_ARCH = "Win32"
}
if ($BITNESS -eq "64") {
$LIBCURL_WIN_ARCH = "x64"
}
else {
$LIBCURL_WIN_ARCH = "x86"
}

# Create build directory; remove if exists
$BUILD_DIR = "${WORKING_DIR}\build"
# $BUILD_DIR = "${WORKING_DIR}\build\${CONFIGURATION}${BITNESS}"
New-Item -Path $BUILD_DIR -ItemType Directory -Force | Out-Null

$VCPKG_DIR = "${WORKING_DIR}/src/vcpkg"

.\scripts\build_libcurl-vcpkg.ps1 $VCPKG_DIR $LIBCURL_WIN_ARCH

Set-Location $CURRENT_DIR

# Build AWS SDK CPP
$SDK_SOURCE_DIR = "${WORKING_DIR}\src\aws-sdk-cpp"
$SDK_BUILD_DIR = "${BUILD_DIR}\aws-sdk\build"
$SDK_INSTALL_DIR = "${BUILD_DIR}\aws-sdk\install"

.\scripts\build_aws-sdk-cpp.ps1 `
$CONFIGURATION $WIN_ARCH `
$SDK_SOURCE_DIR $SDK_BUILD_DIR $SDK_INSTALL_DIR
$SDK_SOURCE_DIR $SDK_BUILD_DIR $SDK_INSTALL_DIR $VCPKG_DIR `
$LIBCURL_WIN_ARCH

Set-Location $CURRENT_DIR

# Build driver
Expand Down
18 changes: 13 additions & 5 deletions sql-odbc/src/installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ cpack_add_component(Resources
DISPLAY_NAME "Resources"
DESCRIPTION "Resources for OpenSearch SQL ODBC Driver"
)

# Install driver files
install(TARGETS sqlodbc DESTINATION bin COMPONENT "Driver")

# TODO: look into DSN Installer failure
# if(APPLE)
# install(FILES "${PROJECT_ROOT}/bin64/dsn_installer" DESTINATION bin COMPONENT "Driver")
Expand All @@ -93,10 +93,18 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Resources/opensearch_sql_odbc.tdc" DE
# Install AWS dependencies
if(WIN32)
set(AWS_SDK_BIN_DIR "${PROJECT_ROOT}/build/aws-sdk/install/bin")
install(FILES "${AWS_SDK_BIN_DIR}/aws-c-common.dll" DESTINATION bin COMPONENT "Driver")
install(FILES "${AWS_SDK_BIN_DIR}/aws-c-event-stream.dll" DESTINATION bin COMPONENT "Driver")
install(FILES "${AWS_SDK_BIN_DIR}/aws-checksums.dll" DESTINATION bin COMPONENT "Driver")
install(FILES "${AWS_SDK_BIN_DIR}/aws-cpp-sdk-core.dll" DESTINATION bin COMPONENT "Driver")
install(DIRECTORY ${AWS_SDK_BIN_DIR} DESTINATION . COMPONENT "Driver")
endif()

if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# We actually never build the installer for Debug
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/libcurl-d.dll" DESTINATION bin COMPONENT "Driver")
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/zlibd1.dll" DESTINATION bin COMPONENT "Driver")
else() # release
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/libcurl.dll" DESTINATION bin COMPONENT "Driver")
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/zlib1.dll" DESTINATION bin COMPONENT "Driver")
endif()
endif()

include(CPack)
3 changes: 3 additions & 0 deletions sql-odbc/src/sqlodbc/opensearch_communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ OpenSearchCommunication::OpenSearchCommunication()
}

OpenSearchCommunication::~OpenSearchCommunication() {
// Release the HTTP client instance to free its resources before releasing AWS SDK.
// Changing order of these actions would cause crash on disconnect.
m_http_client.reset();
--AWS_SDK_HELPER;
}

Expand Down

0 comments on commit df9b314

Please sign in to comment.