Skip to content

Commit

Permalink
AT-818 Support Debug mode for Mac (#71)
Browse files Browse the repository at this point in the history
* Added support Debug mode for macOS
  • Loading branch information
jerrytfleung authored Jun 8, 2021
1 parent 4a9d355 commit d6751bb
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 53 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/mac-debug-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Timestream ODBC Driver for Mac (Debug)

on:
workflow_dispatch:

env:
CI_OUTPUT_PATH: "ci-output"
ODBC_LIB_PATH: "./build/odbc/lib"
ODBC_BIN_PATH: "./build/odbc/bin"
ODBC_BUILD_PATH: "./build/odbc/build"
AWS_SDK_INSTALL_PATH: "./build/aws-sdk/install"

jobs:
build-mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: run-cppcheck
run: |
brew install cppcheck
sh run_cppcheck.sh
- name: upload-cppcheck-results
if: failure()
uses: actions/upload-artifact@v2
with:
name: cppcheck-results
path: cppcheck-results.log
- name: get-dependencies
run: |
brew unlink unixodbc
brew install curl
brew install cmake
brew install libiodbc
- name: configure-and-build-driver
run: |
./build_mac_debug64.sh
- name: configure-aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: prepare-dsn
run: |
sudo mkdir /Library/ODBC
sudo mv ./src/IntegrationTests/ITODBCConnection/odbc.ini /Library/ODBC
mkdir ${{ github.workspace }}/odbc-logs
- name: run-connection-unit-test
run: |
./build/odbc/bin/ut_conn
- name: run-integration-connection-tests
run: |
./build/odbc/bin/itodbc_connection
- name: run-integration-execution-tests
run: |
./build/odbc/bin/itodbc_execution
- name: run-integration-results-tests
run: |
./build/odbc/bin/itodbc_results
- name: run-integration-descriptors-tests
run: |
./build/odbc/bin/itodbc_descriptors
- name: run-integration-catalog-tests
run: |
./build/odbc/bin/itodbc_catalog
- name: run-integration-info-tests
run: |
./build/odbc/bin/itodbc_info
- name: run-integration-pagination-tests
run: |
./build/odbc/bin/itodbc_pagination
- name: print-test-logs
if: failure()
run: |
cat /tmp/timestreamodbc_*.log
cat ./aws_sdk_*.log
- name: print-memory-leak-logs
if: always()
run: |
cat ./leaks_*
- name: upload-integration-test-results
if: always()
uses: actions/upload-artifact@v2
with:
name: integration-test-results-mac64
path: |
${{ github.workspace }}/odbc-logs/
${{ github.workspace }}/leaks_
16 changes: 12 additions & 4 deletions build_mac_debug64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@

cd src
git clone --recurse-submodules -b "1.8.186" "https://github.com/aws/aws-sdk-cpp.git"
cd ..
cd aws-sdk-cpp
mkdir install
mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF"
# Rerun to set the install prefix (https://github.com/aws/aws-sdk-cpp/issues/1156)
cmake ../ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF"
make -j 4
make install
cd ../../../

PREFIX_PATH=$(pwd)
mkdir cmake-build64
cd cmake-build64
cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/AWSSDK/ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF"
cmake ../src -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_TESTS=ON -DCODE_COVERAGE=ON -DBUILD_SHARED_LIBS="OFF"
make ccov-all -j 4
cd ..

cmake --build cmake-build64 -- -j 4
16 changes: 12 additions & 4 deletions build_mac_release64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@

cd src
git clone --recurse-submodules -b "1.8.186" "https://github.com/aws/aws-sdk-cpp.git"
cd ..
cd aws-sdk-cpp
mkdir install
mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF"
# Rerun to set the install prefix (https://github.com/aws/aws-sdk-cpp/issues/1156)
cmake ../ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF"
make -j 4
make install
cd ../../../

PREFIX_PATH=$(pwd)
mkdir cmake-build64
cd cmake-build64
cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/AWSSDK/ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF"
cmake ../src -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_TESTS=ON -DCODE_COVERAGE=ON -DBUILD_SHARED_LIBS="OFF"
make -j 4
cd ..

cmake --build cmake-build64 -- -j 4
81 changes: 37 additions & 44 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
# permissions and limitations under the License.
#

# Pre 3.16 versions of Windows set MD/MT incorrectly and cause linker 'warnings' which are actually serious issues
if(WIN32)
cmake_minimum_required(VERSION 3.16)
else()
cmake_minimum_required(VERSION 3.13)
endif()

project(global_make_list)

include("${CMAKE_CURRENT_SOURCE_DIR}/modules/code-coverage.cmake")
add_code_coverage_all_targets(EXCLUDE libraries aws-cpp-sdk googletest IntegrationTests)
add_code_coverage_all_targets(EXCLUDE libraries aws-cpp-sdk googletest IntegrationTests UnitTests)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
Expand All @@ -39,34 +34,23 @@ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/bin")
endif()

set(CMAKE_CXX_STANDARD 17)
# This wasn't being picked up on mac, causes some symbol errors
if(APPLE)
set(CMAKE_CXX_STANDARD 17)
add_definitions(-DHAVE_STRLCAT)
# Do not use shared libraries for AWS SDK.
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# Set BUILD_WITH_TESTS to OFF before building installer package for size optimization.
option(BUILD_WITH_TESTS "Enable testing" ON)
else()
set(CMAKE_CXX_STANDARD 17)
# Use shared libraries for AWS SDK.
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
# Set BUILD_WITH_TESTS to OFF before building installer package for size optimization.
option(BUILD_WITH_TESTS "Enable testing" ON)
endif()
# Set BUILD_WITH_TESTS to OFF before building installer package for size optimization.
option(BUILD_WITH_TESTS "Enable testing" ON)

if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()

if(NOT WIN32)
# Unix builds require autoconf
option(AUTOCONF_ENABLE "Enable autoconf" ON)
configure_file(autoconf.h.in generated/autoconf.h @ONLY)
endif()

# Base directories
set(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..")
set(ODFEODBC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/odfesqlodbc")
Expand All @@ -76,7 +60,7 @@ set(UNIT_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/UnitTests")
set(INSTALL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/installer")
set(DSN_INSTALLER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/DSNInstaller")

# ODBC Driver version
# ODBC Driver version
set(MAJOR 0)
set(MINOR 2)
set(PATCH 0)
Expand All @@ -92,58 +76,70 @@ set(UT_HELPER "${UNIT_TESTS}/UTHelper")
set(IT_HELPER "${INTEGRATION_TESTS}/ITODBCHelper")

# Without this symbols will be exporting to Unix but not Windows
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

# Set path for AWS SDK
set(aws-cpp-sdk-base "${CMAKE_CURRENT_SOURCE_DIR}/aws-sdk-cpp")
set(aws-cpp-sdk-core_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-core")
set(aws-cpp-sdk-sts_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-sts")
set(aws-cpp-sdk-timestream-query_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-timestream-query")

set(aws-c-event-stream_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-event-stream/cmake")
set(aws-c-common_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-common/cmake")
set(aws-checksums_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-checksums/cmake")
if(WIN32)
set(aws-cpp-sdk-core_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-core")
set(aws-cpp-sdk-sts_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-sts")
set(aws-cpp-sdk-timestream-query_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-timestream-query")
# AWS SDK dependencies
set(aws-c-event-stream_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-event-stream/cmake")
set(aws-c-common_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-common/cmake")
set(aws-checksums_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-checksums/cmake")
else()
set(aws-cpp-sdk-core_DIR "${aws-cpp-sdk-base}/install/lib/cmake/aws-cpp-sdk-core")
set(aws-cpp-sdk-sts_DIR "${aws-cpp-sdk-base}/install/lib/cmake/aws-cpp-sdk-sts")
set(aws-cpp-sdk-timestream-query_DIR "${aws-cpp-sdk-base}/install/lib/cmake/aws-cpp-sdk-timestream-query")
# AWS SDK dependencies
set(aws-c-event-stream_DIR "${aws-cpp-sdk-base}/install/lib/aws-c-event-stream/cmake")
set(aws-c-common_DIR "${aws-cpp-sdk-base}/install/lib/aws-c-common/cmake")
set(aws-checksums_DIR "${aws-cpp-sdk-base}/install/lib/aws-checksums/cmake")
endif()

if (WIN32)
find_package(AWSSDK REQUIRED core sts timestream-query)
else()
find_package(AWSSDK REQUIRED COMPONENTS core sts timestream-query PATHS aws-sdk-cpp/install NO_DEFAULT_PATH)
endif()

# General compiler definitions
add_compile_definitions ( _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
UNICODE_SUPPORT
DYNAMIC_LOAD
UNICODE_SUPPORT
DYNAMIC_LOAD
_MBCS
_CRT_SECURE_NO_DEPRECATE
_USRDLL
_CRT_SECURE_NO_DEPRECATE
_USRDLL
_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
)

# Platform specific compiler definitions
if (WIN32 AND BITNESS EQUAL 64)
# Windows specific
add_compile_definitions ( _WINDLL
_WIN64
add_compile_definitions ( _WINDLL
_WIN64
_WINDOWS
WIN_EXPORT
WIN_EXPORT
)
elseif (WIN32 AND BITNESS EQUAL 32)
# Windows specific
add_compile_definitions ( _WINDLL
_WIN32
add_compile_definitions ( _WINDLL
_WIN32
_WINDOWS
WIN_EXPORT
WIN_EXPORT
)
elseif(APPLE)
# macOS specific
add_compile_definitions ( WITH_IODBC
add_compile_definitions ( WITH_IODBC
SQLCOLATTRIBUTE_SQLLEN
)
# iODBC includes
include_directories(/usr/local/include)
elseif(UNIX)
# Unix specific
add_compile_definitions ( WITH_UNIXODBC
add_compile_definitions ( WITH_UNIXODBC
SQLCOLATTRIBUTE_SQLLEN
)
endif()
Expand All @@ -159,9 +155,6 @@ if(BUILD_WITH_TESTS)
endif()

# Projects to build
if (APPLE)
add_subdirectory(${aws-cpp-sdk-base})
endif()
add_subdirectory(${ODFEODBC_SRC})
add_subdirectory(${ODFEENLIST_SRC})
add_subdirectory(${INSTALL_SRC})
Expand Down
1 change: 1 addition & 0 deletions src/IntegrationTests/ITODBCExecution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ include_directories( ${UT_HELPER}
add_executable(itodbc_execution ${SOURCE_FILES})

# Library dependencies
target_code_coverage(itodbc_execution PUBLIC AUTO ALL)
target_link_libraries(itodbc_execution odfesqlodbc itodbc_helper ut_helper gtest_main)
target_compile_definitions(itodbc_execution PUBLIC _UNICODE UNICODE)
7 changes: 7 additions & 0 deletions src/IntegrationTests/ITODBCExecution/test_odbc_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
#include <thread>
#include <chrono>
// clang-format on
#ifdef WIN32
#define Sleep(milliseconds) Sleep(milliseconds)
#else
#define Sleep(milliseconds) usleep(milliseconds * 1000)
#endif

class TestSQLFetch : public Fixture {};

class TestSQLExecute : public Fixture {};
Expand Down Expand Up @@ -462,6 +468,7 @@ TEST_F(TestSQLCancel, QueryInProgress) {
}
EXPECT_LT(cnt, limit);
LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret);
Sleep(1000);
}

// The following test case needs to change the logic of ts_communication before running.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ include_directories(${UT_HELPER}
add_executable(itodbc_saml_authentication ${SOURCE_FILES})

# Library dependencies
target_code_coverage(itodbc_saml_authentication PUBLIC AUTO ALL)
target_link_libraries(itodbc_saml_authentication odfesqlodbc itodbc_helper ut_helper gtest_main)
target_compile_definitions(itodbc_saml_authentication PUBLIC _UNICODE UNICODE)

1 change: 1 addition & 0 deletions src/UnitTests/UTConn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ include_directories(${UT_HELPER}
add_executable(ut_conn ${SOURCE_FILES})

# Library dependencies
target_code_coverage(ut_conn PUBLIC AUTO ALL)
target_link_libraries(ut_conn odfesqlodbc ut_helper gtest_main)
target_compile_definitions(ut_conn PUBLIC _UNICODE UNICODE)

0 comments on commit d6751bb

Please sign in to comment.