Skip to content

Commit

Permalink
chore: build on ubuntu 20.04
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed Nov 29, 2024
1 parent 11d94ef commit 0c01336
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 1,287 deletions.
102 changes: 47 additions & 55 deletions .github/workflows/build-installer.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,75 @@
name: Build installer
on:
workflow_dispatch:
push:
branches:
- build/older-glibc-version

env:
BUILD_TYPE: Release
DRIVER_VERSION: 1.1.0

jobs:
build-windows:
name: Windows
runs-on: windows-latest
build-linux:
name: Linux
runs-on: ubuntu-20.04
env:
CMAKE_GENERATOR: Visual Studio 17 2022
WIX_DIR: "C:/Program Files (x86)/WiX Toolset v3.14/bin"
CMAKE_GENERATOR: Unix Makefiles
CXX: g++-11
CC: gcc-11
steps:
- name: Checkout source code
uses: actions/checkout@v4

# Configure build environment/dependencies
- name: Install MySQL client libs
- name: Install build dependencies
run: |
curl -L https://dev.mysql.com/get/Downloads/MySQL-8.3/mysql-${{ vars.MYSQL_VERSION }}-winx64.zip -o mysql.zip
unzip -d C:/ mysql.zip
- name: Install OpenSSL 3
run: |
curl -L https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-3.3.1.zip -o openssl3.zip
unzip -d C:/ openssl3.zip
cp -r C:/openssl-3/x64/bin/libssl-3-x64.dll C:/Windows/System32/
cp -r C:/openssl-3/x64/bin/libcrypto-3-x64.dll C:/Windows/System32/
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
sudo apt-get update
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 --slave /usr/bin/g++ g++ /usr/bin/g++-11
sudo apt-get install build-essential libgtk-3-dev unixodbc unixodbc-dev libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev
- name: Cache AWS SDK libraries
id: cache-dynamic-aws-sdk
uses: actions/cache@v4
with:
path: |
aws_sdk
key: ${{ runner.os }}-aws-sdk-dynamic-lib
- name: Install MySQL client libs and include files
run: |
curl -L https://dev.mysql.com/get/Downloads/MySQL-8.3/mysql-${{ vars.MYSQL_VERSION }}-linux-glibc2.28-x86_64.tar.xz -o mysql.tar.gz
tar xf mysql.tar.gz
- name: Build and install AWS SDK C++
working-directory: ./scripts
if: steps.cache-dynamic-aws-sdk.outputs.cache-hit != 'true'
run: |
.\build_aws_sdk_win.ps1 x64 ${{ env.BUILD_TYPE}} ON "${{env.CMAKE_GENERATOR}}"
./build_aws_sdk_unix.sh $BUILD_TYPE
- name: Setup nmake
uses: ilammy/msvc-dev-cmd@v1
- name: Create build environment
shell: bash
run: cmake -E make_directory ${{ github.workspace }}/build

- name: Run build installer script
shell: pwsh
run: |
.\build_installer.ps1 x64 ${{ env.BUILD_TYPE}} "${{env.CMAKE_GENERATOR}}" C:/mysql-${{ vars.MYSQL_VERSION }}-winx64 "${{env.WIX_DIR}}"
- name: Configure CMake
shell: bash
run: cmake -S . -B build
-G "$CMAKE_GENERATOR"
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
-DMYSQLCLIENT_STATIC_LINKING=true
-DWITH_UNIXODBC=1
-DCONNECTOR_PLATFORM=linux
-DMYSQL_DIR=./mysql-${{ vars.MYSQL_VERSION }}-linux-glibc2.28-x86_64/
-DBUNDLE_DEPENDENCIES=true

# Build driver
- name: Build driver
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build . --config $BUILD_TYPE

- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-skip-session-tagging: true
aws-access-key-id: ${{ secrets.AWS_BUILD_KEY }}
aws-secret-access-key: ${{ secrets.AWS_BUILD_SECRET_KEY }}
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
role-duration-seconds: 3600
- name: Build installer
working-directory: ${{ github.workspace }}/build
if: success()
run: cpack .

- name: Run signer script
shell: pwsh
working-directory: ./scripts
run: |
choco upgrade jq -y
. ".\sign_installer.ps1"
Invoke-SignInstaller ${{ github.workspace }}\wix winx64a ${{ env.DRIVER_VERSION}} ${{ secrets.AWS_UNSIGNED_BUCKET }} ${{ secrets.AWS_SIGNED_BUCKET }} ${{ secrets.AWS_S3_KEY }}aws-mysql-odbc-${{ env.DRIVER_VERSION}}-winx64a.msi
- name: Upload Windows installer as artifact
- name: Upload Linux installer as artifact
if: success()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: installers
path: ${{ github.workspace }}/wix/*.msi
name: installers-linux
path: ${{ github.workspace }}/build/aws-mysql-odbc-*.tar.gz
if-no-files-found: error
5 changes: 4 additions & 1 deletion build_installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ if ($null -eq $MYSQL_DIR) {
$MYSQL_DIR = "C:\Program Files\MySQL\MySQL Server 8.3"
}

$CXX_COMPILER=$(which g++)
$C_COMPILER=$(which gcc)

# BUILD DRIVER
cmake -S . -B ./build -G $GENERATOR -DMYSQL_DIR="$MYSQL_DIR" -DMYSQLCLIENT_STATIC_LINKING=TRUE -DCMAKE_BUILD_TYPE="$CONFIGURATION" -DBUNDLE_DEPENDENCIES=TRUE -DOPENSSL_INCLUDE_DIR="$OPENSSL_INCLUDE_DIR"
cmake -S . -B ./build -G $GENERATOR -DMYSQL_DIR="$MYSQL_DIR" -DMYSQLCLIENT_STATIC_LINKING=TRUE -DCMAKE_BUILD_TYPE="$CONFIGURATION" -DBUNDLE_DEPENDENCIES=TRUE -DOPENSSL_INCLUDE_DIR="$OPENSSL_INCLUDE_DIR" -DCMAKE_C_COMPILER="$C_COMPILER" -DCMAKE_CXX_COMPILER="$CXX_COMPILER"
cmake --build ./build --config "$CONFIGURATION"

# CREATE INSTALLER
Expand Down
28 changes: 0 additions & 28 deletions driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})
SET(DRIVER_NAME_STATIC "awsmysqlodbc${CONNECTOR_DRIVER_TYPE_SHORT}-static")

SET(DRIVER_SRCS
adfs_proxy.cc
auth_util.cc
aws_sdk_helper.cc
base_metrics_holder.cc
Expand Down Expand Up @@ -94,14 +93,11 @@ WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})
my_stmt.cc
mylog.cc
mysql_proxy.cc
okta_proxy.cc
options.cc
parse.cc
prepare.cc
query_parsing.cc
results.cc
saml_http_client.cc
saml_util.cc
secrets_manager_proxy.cc
topology_service.cc
transact.cc
Expand All @@ -127,7 +123,6 @@ WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/driver/driver.def.cmake ${CMAKE_SOURCE_DIR}/driver/driver${CONNECTOR_DRIVER_TYPE_SHORT}.def @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/driver/driver.rc.cmake ${CMAKE_SOURCE_DIR}/driver/driver${CONNECTOR_DRIVER_TYPE_SHORT}.rc @ONLY)
SET(DRIVER_SRCS ${DRIVER_SRCS} driver${CONNECTOR_DRIVER_TYPE_SHORT}.def driver${CONNECTOR_DRIVER_TYPE_SHORT}.rc
adfs_proxy.h
auth_util.h
aws_sdk_helper.h
base_metrics_holder.h
Expand All @@ -152,11 +147,8 @@ WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})
mylog.h
mysql_proxy.h
myutil.h
okta_proxy.h
parse.h
query_parsing.h
saml_http_client.h
saml_util.h
secrets_manager_proxy.h
topology_service.h
../MYODBC_MYSQL.h ../MYODBC_CONF.h ../MYODBC_ODBC.h)
Expand Down Expand Up @@ -301,26 +293,6 @@ WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})

MATH(EXPR DRIVER_INDEX "${DRIVER_INDEX} + 1")

#------------DEPENDENCIES FOR FEDERATED AUTH---------
include(FetchContent)

FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz
)

FetchContent_Declare(
httplib
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.16.1.zip
)

FetchContent_MakeAvailable(httplib json)

TARGET_INCLUDE_DIRECTORIES(${DRIVER_NAME} PUBLIC "${httplib_SOURCE_DIR}" ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${DRIVER_NAME} nlohmann_json::nlohmann_json)
TARGET_INCLUDE_DIRECTORIES(${DRIVER_NAME_STATIC} PUBLIC "${httplib_SOURCE_DIR}" ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${DRIVER_NAME_STATIC} nlohmann_json::nlohmann_json)

#------------AWS SDK------------------
LIST(APPEND SERVICE_LIST rds secretsmanager sts aws-c-compression aws-c-sdkutils)

Expand Down
Loading

0 comments on commit 0c01336

Please sign in to comment.