diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index d2e7f5a92..b3979aeb8 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -27,7 +27,6 @@ env: DOC_DB_ODBC_INTEGRATION_TEST: 1 DOC_DB_LOG_PATH: "${{github.workspace}}/build/odbc/logs" DOC_DB_LOG_LEVEL: "debug" - JDBC_DRIVER_VERSION: "1.3.1" JAVA_HOME: "/usr/lib/jvm/java-17-amazon-corretto/" jobs: @@ -71,6 +70,11 @@ jobs: sudo apt update sudo apt install libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev libpulse-dev linux-headers-$(uname -r) gcc gcc-multilib g++ g++-multilib linux-headers-$(uname -r) build-essential valgrind libboost-all-dev libbson-dev libsasl2-dev lcov + - name: Update environment with JDBC_DRIVER_VERSION + run: | + read -r JDBC_DRIVER_VERSION < ./src/JDBC_DRIVER_VERSION.txt + echo "JDBC_DRIVER_VERSION=$JDBC_DRIVER_VERSION" >> $GITHUB_ENV + - name: Cache DocumentDB JDBC JAR id: cache-documentdb-jdbc-jar uses: actions/cache@v3 @@ -214,6 +218,11 @@ jobs: sudo apt update sudo apt install libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev libpulse-dev linux-headers-$(uname -r) gcc gcc-multilib g++ g++-multilib linux-headers-$(uname -r) build-essential valgrind libboost-all-dev libbson-dev libsasl2-dev lcov + - name: Update environment with JDBC_DRIVER_VERSION + run: | + read -r JDBC_DRIVER_VERSION < ./src/JDBC_DRIVER_VERSION.txt + echo "JDBC_DRIVER_VERSION=$JDBC_DRIVER_VERSION" >> $GITHUB_ENV + - name: Cache DocumentDB JDBC JAR id: cache-documentdb-jdbc-jar uses: actions/cache@v3 diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 709144bfd..0293bae22 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -27,7 +27,6 @@ env: DOC_DB_ODBC_INTEGRATION_TEST: 1 DOC_DB_LOG_PATH: "${{github.workspace}}/build/odbc/logs" DOC_DB_LOG_LEVEL: "debug" - JDBC_DRIVER_VERSION: "1.3.1" ODBCINSTINI: "${{github.workspace}}/build/odbc/lib/documentdb-odbc-install.ini" ODBCINI: "${{github.workspace}}/odbc.ini" @@ -64,6 +63,11 @@ jobs: chmod +x scripts/install_dependencies_mac.sh ./scripts/install_dependencies_mac.sh + - name: Update environment with JDBC_DRIVER_VERSION + run: | + read -r JDBC_DRIVER_VERSION < ./src/JDBC_DRIVER_VERSION.txt + echo "JDBC_DRIVER_VERSION=$JDBC_DRIVER_VERSION" >> $GITHUB_ENV + - name: Cache DocumentDB JDBC JAR id: cache-documentdb-jdbc-jar uses: actions/cache@v3 diff --git a/.github/workflows/mac-debug-build.yml b/.github/workflows/mac-debug-build.yml index 33b9a32fb..d9a67d318 100644 --- a/.github/workflows/mac-debug-build.yml +++ b/.github/workflows/mac-debug-build.yml @@ -27,7 +27,6 @@ env: DOC_DB_ODBC_INTEGRATION_TEST: 1 DOC_DB_LOG_PATH: "${{github.workspace}}/build/odbc/logs" DOC_DB_LOG_LEVEL: "debug" - JDBC_DRIVER_VERSION: "1.3.1" ODBCINSTINI: "${{github.workspace}}/build/odbc/lib/documentdb-odbc-install.ini" ODBCINI: "${{github.workspace}}/odbc.ini" @@ -71,6 +70,11 @@ jobs: echo "/Library/Developer/CommandLineTools/usr/bin" >> $GITHUB_PATH echo "/usr/local/bin/" >> $GITHUB_PATH + - name: Update environment with JDBC_DRIVER_VERSION + run: | + read -r JDBC_DRIVER_VERSION < ./src/JDBC_DRIVER_VERSION.txt + echo "JDBC_DRIVER_VERSION=$JDBC_DRIVER_VERSION" >> $GITHUB_ENV + - name: Cache DocumentDB JDBC JAR id: cache-documentdb-jdbc-jar uses: actions/cache@v3 diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 39d62ed14..2926ba745 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -29,7 +29,6 @@ env: DOC_DB_PRIV_KEY_FILE: ~/certs/docdb-sshtunnel.pem DOC_DB_LOG_PATH: "${{github.workspace}}/build/odbc/logs" DOC_DB_LOG_LEVEL: "debug" - JDBC_DRIVER_VERSION: "1.3.1" MONGO_IMPORT_COMMAND: "mongoimport.exe" # Artifacts are created when pushing to develop branch on merge of pull requests. SHOULD_CREATE_ARTIFACTS: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} @@ -61,16 +60,36 @@ jobs: run: | Get-Content ./src/ODBC_DRIVER_VERSION.txt | ForEach-Object { echo "ODBC_DRIVER_VERSION=$_"; break; } >> $env:GITHUB_ENV - - name: Get Java distribution + - name: Update environment with JDBC_DRIVER_VERSION + shell: pwsh + run: | + echo "JDBC_DRIVER_VERSION=$($(Get-Content -Path ./src/JDBC_DRIVER_VERSION.txt -Raw).ToString().Trim())" >> $env:GITHUB_ENV + + # Get first JDK to provide access to jpackage + - name: Get Java distribution (JDK 17, 32-bit) uses: actions/setup-java@v2 with: distribution: 'temurin' java-version: '17' architecture: x86 + # Get second JDK to provide access to jlink + - name: Get Java distribution (JDK 11, 32-bit) + shell: pwsh + run: | + . ./scripts/functions_win.ps1 + Install-JavaJdk -InstallParentPath "jdks" -PlatformArchitecture "x86" -JdkVersion "11" + echo "JAVA_HOME=$env:JAVA_HOME" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: "Update path for Java" run: | - echo "${{ env.JAVA_HOME }}\bin\server" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "${{env.JAVA_HOME}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "${{env.JAVA_HOME}}\bin\server" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Ensure jlink and jpackage have the expected versions + run: | + if ( -not ((jlink --version) -like "11*") ) { exit 1 } + if ( -not ((jpackage --version) -like "17*") ) { exit 1 } - name: "Update path for WIX Toolset" run: | @@ -134,7 +153,14 @@ jobs: uses: actions/upload-artifact@v3 with: name: docdb-odbc-driver-win32-${{env.ODBC_DRIVER_VERSION}} - path: build/odbc/cmake/Release + path: | + build/odbc/cmake/Release/*.dll + build/odbc/cmake/Release/*.msi + build/odbc/cmake/Release/*.exe + build/odbc/cmake/Release/*.pdb + !build/odbc/cmake/Release/images + !build/odbc/cmake/Release/jpackage-resources + !build/odbc/cmake/Release/runtime-image - name: Upload performance test at push to develop if: ${{env.SHOULD_CREATE_ARTIFACTS == 'true'}} @@ -229,15 +255,21 @@ jobs: run: | Get-Content ./src/ODBC_DRIVER_VERSION.txt | ForEach-Object { echo "ODBC_DRIVER_VERSION=$_"; break; } >> $env:GITHUB_ENV + - name: Update environment with JDBC_DRIVER_VERSION + shell: pwsh + run: | + echo "JDBC_DRIVER_VERSION=$($(Get-Content -Path ./src/JDBC_DRIVER_VERSION.txt -Raw).ToString().Trim())" >> $env:GITHUB_ENV + - name: Get Java distribution - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '17' - architecture: x64 + shell: pwsh + run: | + . ./scripts/functions_win.ps1 + Install-JavaJdk -InstallParentPath "jdks" -PlatformArchitecture "x64" + echo "JAVA_HOME=$env:JAVA_HOME" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: "Update path for Java" run: | + echo "${{env.JAVA_HOME}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "${{env.JAVA_HOME}}\bin\server" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: "Update path for WIX Toolset" @@ -301,7 +333,14 @@ jobs: uses: actions/upload-artifact@v3 with: name: docdb-odbc-driver-amd64-${{env.ODBC_DRIVER_VERSION}} - path: build/odbc/cmake/Release + path: | + build/odbc/cmake/Release/*.dll + build/odbc/cmake/Release/*.msi + build/odbc/cmake/Release/*.exe + build/odbc/cmake/Release/*.pdb + !build/odbc/cmake/Release/images + !build/odbc/cmake/Release/jpackage-resources + !build/odbc/cmake/Release/runtime-image - name: Upload performance test at push to develop if: ${{env.SHOULD_CREATE_ARTIFACTS == 'true'}} @@ -367,15 +406,21 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Update environment with JDBC_DRIVER_VERSION + shell: pwsh + run: | + echo "JDBC_DRIVER_VERSION=$($(Get-Content -Path ./src/JDBC_DRIVER_VERSION.txt -Raw).ToString().Trim())" >> $env:GITHUB_ENV + - name: Get Java distribution - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '17' - architecture: x64 + shell: pwsh + run: | + . ./scripts/functions_win.ps1 + Install-JavaJdk -InstallParentPath "jdks" -PlatformArchitecture "x64" + echo "JAVA_HOME=$env:JAVA_HOME" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: "Update path for Java" run: | + echo "${{env.JAVA_HOME}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "${{env.JAVA_HOME}}\bin\server" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: "Update path for WIX Toolset" diff --git a/build_linux_debug64.sh b/build_linux_debug64.sh index 7c1d10631..d169ebd59 100755 --- a/build_linux_debug64.sh +++ b/build_linux_debug64.sh @@ -12,9 +12,7 @@ cmake ../src -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCODE_COVERAGE="ON" -DBUILD_SHARE cd .. # Download the DocumentDB JDBC Driver -if [ -z "$JDBC_DRIVER_VERSION" ]; then - JDBC_DRIVER_VERSION="1.3.1" -fi +read -r JDBC_DRIVER_VERSION < "${PROJECT_DIR}/src/odbc/JDBC_DRIVER_VERSION.txt" JDBC_DRIVER_FILENAME="documentdb-jdbc-$JDBC_DRIVER_VERSION-all.jar" JDBC_DRIVER_FULLPATH="$DRIVER_BIN_DIR/libs/$JDBC_DRIVER_FILENAME" export DOCUMENTDB_HOME="$DRIVER_BIN_DIR" diff --git a/build_linux_release64_deb.sh b/build_linux_release64_deb.sh index c304a1e06..ceb23082b 100755 --- a/build_linux_release64_deb.sh +++ b/build_linux_release64_deb.sh @@ -9,9 +9,7 @@ cmake ../src -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCODE_COVERAGE="OFF" -DBUILD_SHARED cd .. # Download the DocumentDB JDBC Driver -if [ -z "$JDBC_DRIVER_VERSION" ]; then - JDBC_DRIVER_VERSION="1.3.1" -fi +read -r JDBC_DRIVER_VERSION < "${PROJECT_DIR}/src/odbc/JDBC_DRIVER_VERSION.txt" JDBC_DRIVER_FILENAME="documentdb-jdbc-$JDBC_DRIVER_VERSION-all.jar" JDBC_DRIVER_FULLPATH="$DRIVER_BIN_DIR/libs/$JDBC_DRIVER_FILENAME" export DOCUMENTDB_HOME="$DRIVER_BIN_DIR" diff --git a/build_mac_debug64.sh b/build_mac_debug64.sh index 0499c77ea..b12612d53 100755 --- a/build_mac_debug64.sh +++ b/build_mac_debug64.sh @@ -12,9 +12,7 @@ cmake ../src -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCODE_COVERAGE="ON" -DBUILD_SHARE cd .. # Download the DocumentDB JDBC Driver -if [ -z "$JDBC_DRIVER_VERSION" ]; then - JDBC_DRIVER_VERSION="1.3.1" -fi +read -r JDBC_DRIVER_VERSION < "${PROJECT_DIR}/src/odbc/JDBC_DRIVER_VERSION.txt" JDBC_DRIVER_FILENAME="documentdb-jdbc-$JDBC_DRIVER_VERSION-all.jar" JDBC_DRIVER_FULLPATH="$DRIVER_BIN_DIR/libs/$JDBC_DRIVER_FILENAME" export DOCUMENTDB_HOME="$DRIVER_BIN_DIR" diff --git a/build_mac_release64.sh b/build_mac_release64.sh index 5605db448..b91fe3476 100755 --- a/build_mac_release64.sh +++ b/build_mac_release64.sh @@ -9,9 +9,7 @@ cmake ../src -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCODE_COVERAGE="OFF" -DBUILD_SHAR make -j 4 # Download the DocumentDB JDBC Driver -if [ -z "$JDBC_DRIVER_VERSION" ]; then - JDBC_DRIVER_VERSION="1.3.1" -fi +read -r JDBC_DRIVER_VERSION < "${PROJECT_DIR}/src/odbc/JDBC_DRIVER_VERSION.txt" JDBC_DRIVER_FILENAME="documentdb-jdbc-$JDBC_DRIVER_VERSION-all.jar" JDBC_DRIVER_FULLPATH="$DRIVER_BIN_DIR/libs/$JDBC_DRIVER_FILENAME" export DOCUMENTDB_HOME="$DRIVER_BIN_DIR" diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1 index e9ec73b0b..a2e5873e7 100644 --- a/scripts/build_windows.ps1 +++ b/scripts/build_windows.ps1 @@ -20,7 +20,7 @@ $DRIVER_SOURCE_DIR = "${WORKING_DIR}\src" $DRIVER_BUILD_DIR = "${BUILD_DIR}\odbc\cmake" # Download the JDBC driver -$JDBC_DRIVER_VERSION = if ($JDBC_DRIVER_VERSION -eq $null) { "1.3.1" } else { $JDBC_DRIVER_VERSION } +$JDBC_DRIVER_VERSION = $($(Get-Content -Path ./src/JDBC_DRIVER_VERSION.txt -Raw).ToString().Trim()) $JDBC_DRIVER_FILENAME = "documentdb-jdbc-$JDBC_DRIVER_VERSION-all.jar" $JDBC_DRIVER_FULLPATH = "$DRIVER_BUILD_DIR\$CONFIGURATION\libs\$JDBC_DRIVER_FILENAME" if (-not (Test-Path -Path $JDBC_DRIVER_FULLPATH -PathType Leaf)) { diff --git a/scripts/functions_win.ps1 b/scripts/functions_win.ps1 index 1224eca21..d51f62a61 100644 --- a/scripts/functions_win.ps1 +++ b/scripts/functions_win.ps1 @@ -20,345 +20,366 @@ $scriptPath = Split-Path -parent $PSCommandPath $projectPath = Split-Path -parent $scriptPath function Update-UserPath { - [OutputType([Boolean])] - Param( - $Path - ) - - $userPath = [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User) - [string[]]$paths = $($userPath.Split(";") | Get-Unique) - if ( -not $paths.Contains($Path) ) { - [string[]]$addPath = $Path - $newPaths = $addPath + $paths - $newPath = [String]::Join(";", $newPaths) - [System.Environment]::SetEnvironmentVariable('Path', $newPath, [System.EnvironmentVariableTarget]::User) - } + [OutputType([Boolean])] + Param( + $Path + ) + + $userPath = [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User) + [string[]]$paths = $($userPath.Split(";") | Get-Unique) + if ( -not $paths.Contains($Path) ) { + [string[]]$addPath = $Path + $newPaths = $addPath + $paths + $newPath = [String]::Join(";", $newPaths) + [System.Environment]::SetEnvironmentVariable('Path', $newPath, [System.EnvironmentVariableTarget]::User) + } } # Confirms that the minimum PowerShell version is being used. # Returns true if version is supported, otherwise, returns false. function Confirm-PowerShellVersion { - [OutputType([Boolean])] - Param() - - # Validate that we have the correct version of PowerShell - if ( [string]::IsNullOrEmpty($powerShellVersion) ) { - Write-Host "Unable to determine PowerShell version" - return $false - } - if ( $powerShellVersion -lt 7 ) { - Write-Host "PowerShell version must be version 7 or greater. Found version: $powerShellVersion" - return $false - } - return $true + [OutputType([Boolean])] + Param() + + # Validate that we have the correct version of PowerShell + if ( [string]::IsNullOrEmpty($powerShellVersion) ) { + Write-Host "Unable to determine PowerShell version" + return $false + } + if ( $powerShellVersion -lt 7 ) { + Write-Host "PowerShell version must be version 7 or greater. Found version: $powerShellVersion" + return $false + } + return $true } # Confirms if the PowerShell is running as an administrator. # Returns true is running as an administrator, otherwise, returns false. function Confirm-RunAsAdministrator { - [OutputType([Boolean])] - Param() - - $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) - if ( -not ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) ) { - return $false - } - Write-Host "Running as administrator." - return $true + [OutputType([Boolean])] + Param() + + $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + if ( -not ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) ) { + return $false + } + Write-Host "Running as administrator." + return $true } # Invokes the given command in a new process elevated to run as administrator. function Invoke-RunAsAdministrator { - [OutputType([Boolean])] - Param( - [Parameter(Mandatory=$true, ValueFromPipeline=$false)] - [string]$CommandPath, - [Parameter(Mandatory=$false, ValueFromPipeline=$false)] - [string]$Arguments, - [switch]$Wait - ) - - if ( -not $(Confirm-PowerShellVersion) ){ - return $false - } - - if ( -not $(Confirm-RunAsAdministrator) ) { - # Elevate the command - if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { - Write-Host "Starting command `"$CommandPath`" in new elevated process." - if ($Wait) { - Start-Process -Wait -FilePath $CommandPath -Verb Runas -ArgumentList "$Arguments" - } - else { - Start-Process -FilePath $CommandPath -Verb Runas -ArgumentList "$Arguments" - } - return $true - } - } - - return $false + [OutputType([Boolean])] + Param( + [Parameter(Mandatory=$true, ValueFromPipeline=$false)] + [string]$CommandPath, + [Parameter(Mandatory=$false, ValueFromPipeline=$false)] + [string]$Arguments, + [switch]$Wait + ) + + if ( -not $(Confirm-PowerShellVersion) ){ + return $false + } + + if ( -not $(Confirm-RunAsAdministrator) ) { + # Elevate the command + if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { + Write-Host "Starting command `"$CommandPath`" in new elevated process." + if ($Wait) { + Start-Process -Wait -FilePath $CommandPath -Verb Runas -ArgumentList "$Arguments" + } + else { + Start-Process -FilePath $CommandPath -Verb Runas -ArgumentList "$Arguments" + } + return $true + } + } + + return $false } # Invokes the given script in a new process elevated to run as administrator. function Invoke-ScriptRunAsAdministrator { - [OutputType([Boolean])] - Param( - [Parameter(Mandatory=$true, ValueFromPipeline=$false)] - [string]$CommandPath, - [Parameter(Mandatory=$false, ValueFromPipeline=$false)] - [string]$Arguments, - [switch]$Wait, - [switch]$NoExit - ) - - if ( -not $(Confirm-PowerShellVersion) ){ - return $false - } - - # Self-elevate the script if required - if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { - $CommandArguments = "-File `"" + $CommandPath + "`" " + $Arguments - if ($NoExit) { - $CommandArguments = "-noe $CommandArguments" - } - if ($Wait) { - Invoke-RunAsAdministrator -Wait "pwsh.exe" $CommandArguments - } - else { - Invoke-RunAsAdministrator -Wait $CommandArguments - } - return $true - } - - return $false + [OutputType([Boolean])] + Param( + [Parameter(Mandatory=$true, ValueFromPipeline=$false)] + [string]$CommandPath, + [Parameter(Mandatory=$false, ValueFromPipeline=$false)] + [string]$Arguments, + [switch]$Wait, + [switch]$NoExit + ) + + if ( -not $(Confirm-PowerShellVersion) ){ + return $false + } + + # Self-elevate the script if required + if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { + $CommandArguments = "-File `"" + $CommandPath + "`" " + $Arguments + if ($NoExit) { + $CommandArguments = "-noe $CommandArguments" + } + if ($Wait) { + Invoke-RunAsAdministrator -Wait "pwsh.exe" $CommandArguments + } + else { + Invoke-RunAsAdministrator -Wait $CommandArguments + } + return $true + } + + return $false } # Enables the Visual Studio DevShell. This provides paths and evironment to support compiling, etc. function Enable-VsDevShell { - [OutputType([Boolean])] - Param() - - # Enable VsDevShell explicitly - $vsInstance = $(Get-CimInstance MSFT_VSInstance) - $devShellLocation = $(Get-ChildItem -Path $vsInstance.InstallLocation -Filter "Microsoft.VisualStudio.DevShell.dll" -Recurse -ErrorAction SilentlyContinue -Force) - if ( ([string]::IsNullOrEmpty($devShellLocation)) ) { - Write-Host "Unable to locate Visual Studio DevShell." - return $false - } - Import-Module $devShellLocation - Enter-VsDevShell $vsInstance.IdentifyingNumber - Write-Host "Entered Visual Studio DevShell." - return $true + [OutputType([Boolean])] + Param() + + # Enable VsDevShell explicitly + $vsInstance = $(Get-CimInstance MSFT_VSInstance) + $devShellLocation = $(Get-ChildItem -Path $vsInstance.InstallLocation -Filter "Microsoft.VisualStudio.DevShell.dll" -Recurse -ErrorAction SilentlyContinue -Force) + if ( ([string]::IsNullOrEmpty($devShellLocation)) ) { + Write-Host "Unable to locate Visual Studio DevShell." + return $false + } + Import-Module $devShellLocation + Enter-VsDevShell $vsInstance.IdentifyingNumber + Write-Host "Entered Visual Studio DevShell." + return $true } # Confirms that the 'cmake' command is available. function Confirm-CmakeExists { - [OutputType([Boolean])] - Param() - - # Test that we have access to CMake - i.e., Visual Studio dev shell. - $cmakeVersion = $(cmake --version) - if ( [string]::IsNullOrEmpty($cmakeVersion) ) { - Write-Host "Unable to find 'cmake'. " - Write-Host "Please ensure Visual Studio and C++ tools are installed." - return $false - } - Write-Host "Valid CMake found. Version: $cmakeVersion" - return $true + [OutputType([Boolean])] + Param() + + # Test that we have access to CMake - i.e., Visual Studio dev shell. + $cmakeVersion = $(cmake --version) + if ( [string]::IsNullOrEmpty($cmakeVersion) ) { + Write-Host "Unable to find 'cmake'. " + Write-Host "Please ensure Visual Studio and C++ tools are installed." + return $false + } + Write-Host "Valid CMake found. Version: $cmakeVersion" + return $true } # Confirms that a valid version of Java JDK is installed and available. function Confirm-JavaJdk { - [OutputType([Boolean])] - param () - - # Java SDK - Write-Host "Checking for dependency JDK" - $jdkFound = $false - # Checks that JAVA_HOME is defined, the path to JAVA_HOME exists - # and is a JDK (i.e., include subdirectory) - if ( -not ([string]::IsNullOrEmpty($Env:JAVA_HOME)) ` - -and (Test-Path -Path $Env:JAVA_HOME) ` - -and (Test-Path -Path "${Env:JAVA_HOME}\include") ) { - - # Test Java in path and has minimum version - $regex = "\d+[.]\d+[.]\d+" - try { - $javaVersionString = $(java --version) - $javaVersion = $($javaVersionString | Select-String -Pattern $regex | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } | Get-Unique -AsString) - $javaVersionArray = $javaVersion.Split(".") - if ( ($javaVersionArray.Count -ge 1) -and -not ([string]::IsNullOrEmpty($javaVersionArray[0])) ) { - if ( "1" -eq $javaVersionArray[0] -and -not ([string]::IsNullOrEmpty($javaVersionArray[1])) ) { - if ( $javaVersionArray[1] -eq "8" -or $javaVersionArray[1] -eq "9" ) { - $jdkFound = $true - } - } elseif ( $javaVersionArray[0] -ge "10") { - $jdkFound = $true - } - } - if ( $jdkFound ) { - Set-JdkPath - } - } - catch { - Write-Host $_ - } - } - - return $jdkFound + [OutputType([Boolean])] + param () + + # Java SDK + Write-Host "Checking for dependency JDK" + $jdkFound = $false + # Checks that JAVA_HOME is defined, the path to JAVA_HOME exists + # and is a JDK (i.e., include subdirectory) + if ( -not ([string]::IsNullOrEmpty($Env:JAVA_HOME)) ` + -and (Test-Path -Path $Env:JAVA_HOME) ` + -and (Test-Path -Path "${Env:JAVA_HOME}\include") ) { + + # Test Java in path and has minimum version + $regex = "\d+[.]\d+[.]\d+" + try { + $javaVersionString = $(java --version) + $javaVersion = $($javaVersionString | Select-String -Pattern $regex | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } | Get-Unique -AsString) + $javaVersionArray = $javaVersion.Split(".") + if ( ($javaVersionArray.Count -ge 1) -and -not ([string]::IsNullOrEmpty($javaVersionArray[0])) ) { + if ( "1" -eq $javaVersionArray[0] -and -not ([string]::IsNullOrEmpty($javaVersionArray[1])) ) { + if ( $javaVersionArray[1] -eq "8" -or $javaVersionArray[1] -eq "9" ) { + $jdkFound = $true + } + } elseif ( $javaVersionArray[0] -ge "10") { + $jdkFound = $true + } + } + if ( $jdkFound ) { + Set-JdkPath + } + } + catch { + Write-Host $_ + } + } + + return $jdkFound } # Installs an Amazon Corretto JDK into the user's folder and updates the JAVA_HOME and PATH environment variables. function Install-JavaJdk { - [OutputType([Boolean])] - param () - - Write-Host "Installing Java JDK" - $jdksFolder = "$env:USERPROFILE\.jdks" - $jdkZipFileName = 'amazon-corretto-17-x64-windows-jdk.zip' - $jdkDownloadUri = "https://corretto.aws/downloads/latest/$jdkZipFileName" - $jdkZipFilePath = "$jdksFolder\$jdkZipFileName" - $tempFolderPath = Join-Path $Env:Temp $(New-Guid) - - try { - # Download the JDK - Invoke-WebRequest $jdkDownloadUri -OutFile $jdkZipFilePath - #Extract the zip file - New-Item -Type Directory -Path $tempFolderPath - Expand-Archive -Path $jdkZipFilePath $tempFolderPath - - # Ensure unique folder - $contentsOfTempFolder = Get-ChildItem -Path $tempFolderPath -Directory -Name - if ( $contentsOfTempFolder.Count -ne 1 ) { - Write-Host "Unable to insall Java JDK. Unexpected distribution does not have unique folder." - return $false - } - # Place JDK in user's folder - $jdkFolderName = $contentsOfTempFolder - $Env:JAVA_HOME = "$jdksFolder\$jdkFolderName" - if ( -not (Test-Path -Path $Env:JAVA_HOME) ) { - Copy-Item -Path "$tempFolderPath\*" -Destination $jdksFolder -Recurse -Force - } - - # Update PATH for bin (java.exe) and server (jvm.dll) - Set-JdkPath - } - catch { - Write-Host "Error installing Java JDK." - Write-Host $_ - return $false - } - finally { - #Delete the zip file after extraction - Remove-Item $jdkZipFilePath -Force - Remove-Item $tempFolderPath -Recurse -Force - } - Write-Host "Finished installing Java JDK" - return $true + [OutputType([Boolean])] + param ( + $InstallParentPath = "$env:USERPROFILE\.jdks", + $PlatformArchitecture = "x64", + $JdkVersion = "17", + $JdkName = "amazon-corretto", + $JdkDownloadUrl = "https://corretto.aws/downloads/latest", + $Platform = "windows" + ) + + Write-Host "Installing Java JDK" + + Write-Host "`$InstallParentPath = '$InstallParentPath'" + Write-Host "`$PlatformArchitecture = '$PlatformArchitecture'" + Write-Host "`$JdkVersion = '$JdkVersion'" + Write-Host "`$JdkName = '$JdkName'" + Write-Host "`$JdkDownloadUrl = '$JdkDownloadUrl'" + Write-Host "`$Platform = '$Platform'" + + $jdksFolder = $InstallParentPath + $jdkZipFileName = "${JdkName}-${JdkVersion}-${PlatformArchitecture}-${Platform}-jdk.zip" + $jdkDownloadUri = "${JdkDownloadUrl}/$jdkZipFileName" + $tempFolderPath = Join-Path $Env:Temp $(New-Guid) + # Ensure parent folder exists + if ( -not (Test-Path -Path $jdksFolder)) { + New-Item -Type Directory -Path $jdksFolder -Force + } + $jdksFolder = Resolve-Path -Path $jdksFolder + $jdkZipFilePath = "$jdksFolder\$jdkZipFileName" + + try { + # Download the JDK + Invoke-WebRequest $jdkDownloadUri -OutFile $jdkZipFilePath + Write-Host "After 'Invoke-WebRequest $jdkDownloadUri -OutFile $jdkZipFilePath'" + #Extract the zip file + New-Item -Type Directory -Path $tempFolderPath + Expand-Archive -Path $jdkZipFilePath $tempFolderPath + Write-Host "After 'Expand-Archive -Path $jdkZipFilePath $tempFolderPath'" + + # Ensure unique folder + $contentsOfTempFolder = Get-ChildItem -Path $tempFolderPath -Directory -Name + if ( $contentsOfTempFolder.Count -ne 1 ) { + Write-Host "Unable to insall Java JDK. Unexpected distribution does not have unique folder." + return $false + } + # Place JDK in user's folder + $jdkFolderName = $contentsOfTempFolder + if ( -not (Test-Path -Path "$jdksFolder\$jdkFolderName") ) { + Copy-Item -Path "$tempFolderPath\*" -Destination $jdksFolder -Recurse -Force + } + # Update JAVA_HOME and PATH for bin (java.exe) and server (jvm.dll) + $Env:JAVA_HOME = "$jdksFolder\$jdkFolderName" + Set-JdkPath + } + catch { + Write-Host "Error installing Java JDK." + Write-Host $_ + return $false + } + finally { + #Delete the zip file after extraction + Remove-Item $jdkZipFilePath -Force + Remove-Item $tempFolderPath -Recurse -Force + } + Write-Host "Finished installing Java JDK" + return $true } # Sets the PATH for ensuring access to 'java.exe' and 'jvm.dll' function Set-JdkPath { - [OutputType([Boolean])] - param () + [OutputType([Boolean])] + param () - $updatePath = $false + $updatePath = $false - # Update PATH for bin (java.exe) and server (jvm.dll) - $javaFile = Get-ChildItem -Path $Env:JAVA_HOME -Recurse -Filter "java.exe" - $binPath = $javaFile.Directory.FullName - $jvmFile = Get-ChildItem -Path $Env:JAVA_HOME -Recurse -Filter "jvm.dll" - $jvmPath = $jvmFile.Directory.FullName + # Update PATH for bin (java.exe) and server (jvm.dll) + $javaFile = Get-ChildItem -Path $Env:JAVA_HOME -Recurse -Filter "java.exe" + $binPath = $javaFile.Directory.FullName + $jvmFile = Get-ChildItem -Path $Env:JAVA_HOME -Recurse -Filter "jvm.dll" + $jvmPath = $jvmFile.Directory.FullName - Update-UserPath $jvmPath - Update-UserPath $binPath + Update-UserPath $jvmPath + Update-UserPath $binPath } # Installs or updates the VCPKG repository from GitHub. function Install-Vcpkg { - [OutputType([Boolean])] - Param() - - # VCPKG (Windows) - if ( [string]::IsNullOrEmpty($Env:VCPKG_ROOT) ) { - $Env:VCPKG_ROOT = "c:\vcpkg" - [System.Environment]::SetEnvironmentVariable('VCPKG_ROOT', $Env:VCPKG_ROOT, [System.EnvironmentVariableTarget]::User) - Write-Host "Setting environment variable VCPKG_ROOT=$Env:VCPKG_ROOT" - } - if ( -not (Test-Path -Path $Env:VCPKG_ROOT) ) { - Write-Host "Cloning VCPKG GitHub repository into $Env:VCPKG_ROOT" - New-Item $Env:VCPKG_ROOT -ItemType Directory -Force - $prevLocation = Get-Location - Set-Location $Env:VCPKG_ROOT - git clone https://github.com/microsoft/vcpkg.git $Env:VCPKG_ROOT - .\bootstrap-vcpkg | Write-Host - .\vcpkg.exe integrate install | Write-Host - Set-Location $prevLocation - } else { - Write-Host "Updating VCPKG GitHub local repository in $Env:VCPKG_ROOT" - $prevLocation = Get-Location - Set-Location $Env:VCPKG_ROOT - git pull - .\vcpkg.exe integrate install | Write-Host - Set-Location $prevLocation - } - return $true + [OutputType([Boolean])] + Param() + + # VCPKG (Windows) + if ( [string]::IsNullOrEmpty($Env:VCPKG_ROOT) ) { + $Env:VCPKG_ROOT = "c:\vcpkg" + [System.Environment]::SetEnvironmentVariable('VCPKG_ROOT', $Env:VCPKG_ROOT, [System.EnvironmentVariableTarget]::User) + Write-Host "Setting environment variable VCPKG_ROOT=$Env:VCPKG_ROOT" + } + if ( -not (Test-Path -Path $Env:VCPKG_ROOT) ) { + Write-Host "Cloning VCPKG GitHub repository into $Env:VCPKG_ROOT" + New-Item $Env:VCPKG_ROOT -ItemType Directory -Force + $prevLocation = Get-Location + Set-Location $Env:VCPKG_ROOT + git clone https://github.com/microsoft/vcpkg.git $Env:VCPKG_ROOT + .\bootstrap-vcpkg | Write-Host + .\vcpkg.exe integrate install | Write-Host + Set-Location $prevLocation + } else { + Write-Host "Updating VCPKG GitHub local repository in $Env:VCPKG_ROOT" + $prevLocation = Get-Location + Set-Location $Env:VCPKG_ROOT + git pull + .\vcpkg.exe integrate install | Write-Host + Set-Location $prevLocation + } + return $true } # Installs or updates the required VCPKG packages using the 'vcpkg.json' manifest file. function Install-VcpkgPackages { - [OutputType([Boolean])] - Param( - $Triplet = "x64-windows" - ) - - $prevLocation = Get-Location - try { - # Assumes the script's folder contains the 'vcpkg.json' configuration file. - Set-Location $scriptPath - & "${Env:VCPKG_ROOT}\vcpkg.exe" install --triplet $Triplet --x-install-root="${Env:VCPKG_ROOT}/installed" | Write-Host - if ($LASTEXITCODE -ne 0) { - Write-Host "Unable to install VCPKG libraries" - return $false - } - - return $true - } - finally { - Set-Location $prevLocation - } + [OutputType([Boolean])] + Param( + $Triplet = "x64-windows" + ) + + $prevLocation = Get-Location + try { + # Assumes the script's folder contains the 'vcpkg.json' configuration file. + Set-Location $scriptPath + & "${Env:VCPKG_ROOT}\vcpkg.exe" install --triplet $Triplet --x-install-root="${Env:VCPKG_ROOT}/installed" | Write-Host + if ($LASTEXITCODE -ne 0) { + Write-Host "Unable to install VCPKG libraries" + return $false + } + + return $true + } + finally { + Set-Location $prevLocation + } } # Installs or updates the MongoDb server and shell commands. function Install-MongoDb { - [OutputType([Boolean])] - Param() - - # Install/upgrade Mongo Server - if ( -not $(Confirm-RunAsAdministrator) ) { - Invoke-ScriptRunAsAdministrator "$projectPath\scripts\reinstall_mongodb.ps1" -Wait - } - else { - "$projectPath\scripts\reinstall_mongodb.ps1" - } - - return $true + [OutputType([Boolean])] + Param() + + # Install/upgrade Mongo Server + if ( -not $(Confirm-RunAsAdministrator) ) { + Invoke-ScriptRunAsAdministrator "$projectPath\scripts\reinstall_mongodb.ps1" -Wait + } + else { + "$projectPath\scripts\reinstall_mongodb.ps1" + } + + return $true } # Installs or updates the WIX Toolset and updates the PATH environment variable. function Install-WixToolset { - [OutputType([Boolean])] - Param() + [OutputType([Boolean])] + Param() - if ( -not $(Confirm-RunAsAdministrator) ) { - Invoke-RunAsAdministrator -Wait "choco" "upgrade wixtoolset -y" - } - else { - choco upgrade wixtoolset -y - } + if ( -not $(Confirm-RunAsAdministrator) ) { + Invoke-RunAsAdministrator -Wait "choco" "upgrade wixtoolset -y" + } + else { + choco upgrade wixtoolset -y + } - $wixToolsetBinFolder = "${Env:ProgramFiles(x86)}\WiX Toolset v3.11\bin" - Update-UserPath $wixToolsetBinFolder + $wixToolsetBinFolder = "${Env:ProgramFiles(x86)}\WiX Toolset v3.11\bin" + Update-UserPath $wixToolsetBinFolder - return $true + return $true } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 76a6cacf1..0c0c64646 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ cmake_minimum_required(VERSION 3.20) # Update version number in ODBC_DRIVER_VERSION.txt file. file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/ODBC_DRIVER_VERSION.txt" ODBC_DRIVER_VERSION) +string(STRIP ${ODBC_DRIVER_VERSION} ODBC_DRIVER_VERSION) project(DocumentDB-ODBC.C++ VERSION ${ODBC_DRIVER_VERSION}) include("${CMAKE_CURRENT_SOURCE_DIR}/modules/code-coverage.cmake") diff --git a/src/JDBC_DRIVER_VERSION.txt b/src/JDBC_DRIVER_VERSION.txt new file mode 100644 index 000000000..3a3cd8cc8 --- /dev/null +++ b/src/JDBC_DRIVER_VERSION.txt @@ -0,0 +1 @@ +1.3.1 diff --git a/src/markdown/setup/developer-guide.md b/src/markdown/setup/developer-guide.md index bc4af4a4f..6a7687bdb 100644 --- a/src/markdown/setup/developer-guide.md +++ b/src/markdown/setup/developer-guide.md @@ -171,6 +171,7 @@ There are two ways to fix the issue. 1. Ensure that your github is checking out the files as Unix-style https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings 2. Alternatively you can convert the end-of-line using the following command `tr -d '\015' < build_linux_debug64.sh > build_linux_debug64_lf.sh and run the build_linux_debug64_lf.sh` 1. Note that the command will need to be executed for all scripts that you will run in the container (register_driver_unix.sh,env_variables_check.sh and any other that you might need). + ### Using Ubuntu 64bit 1. Install all dependencies @@ -242,3 +243,8 @@ If you want to check a detailed report generate the with `--html-details` option ### Windows OpenCppCoverage is used to generate code coverage for windows, for more information check it in the official (documentation)[https://github.com/OpenCppCoverage/OpenCppCoverage] + +## Versioning + +1. To set the version of the ODBC driver, update the `src/ODBC_DRIVER_VERSION.txt` file with the appropriate version. +1. To set the version of the JDBC drvier to download and embed, update the `src/JDBC_DRIVER_VERSION.txt` file to the appropriate version. \ No newline at end of file diff --git a/src/odbc/CMakeLists.txt b/src/odbc/CMakeLists.txt index faced799e..6221333fb 100644 --- a/src/odbc/CMakeLists.txt +++ b/src/odbc/CMakeLists.txt @@ -221,6 +221,16 @@ if (WIN32 AND ${WITH_ODBC_MSI}) message(FATAL_ERROR "WIX light.exe not found! Have you installed WIX Toolset or forgotten to add it to Path?") endif() + find_program(JAVA_JPACKAGE jpackage) + if(NOT JAVA_JPACKAGE) + message(FATAL_ERROR "Java 'jpackage' not found! Have you installed JDK or forgotten to add it to Path?") + endif() + + find_program(JAVA_JLINK jlink) + if(NOT JAVA_JLINK) + message(FATAL_ERROR "Java 'jlink' not found! Have you installed JDK or forgotten to add it to Path?") + endif() + set(WIX_ODBC_LIBRARY_PATH ".\\documentdb.odbc.dll") set(WIX_ODBC_BSON1_PATH ".\\bson-1.0.dll") set(WIX_ODBC_BSONCXX_PATH ".\\bsoncxx.dll") @@ -235,10 +245,19 @@ if (WIN32 AND ${WITH_ODBC_MSI}) set(WIX_ODBC_ZLIB1_FILE "zlibd1.dll") endif() - set(WIX_ODBC_JDBC_PATH ".\\libs\\documentdb-jdbc-1.3.1-all.jar") + # Get the JDBC version + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/../JDBC_DRIVER_VERSION.txt" JDBC_DRIVER_VERSION) + string(STRIP ${JDBC_DRIVER_VERSION} JDBC_DRIVER_VERSION) + # Get the version of Java via the `jlink` command (used to build the Java runtime) + execute_process(COMMAND jlink --version OUTPUT_VARIABLE JLINK_VERSION) + string(STRIP ${JLINK_VERSION} JLINK_VERSION) + string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)(.*)" "\\1.\\2.\\3" JLINK_VERSION ${JLINK_VERSION}) + message(STATUS "Using JLINK_VERSION='${JLINK_VERSION}' for Java runtime image.") + set(WIX_ODBC_JDBC_PATH ".\\libs\\documentdb-jdbc-${JDBC_DRIVER_VERSION}-all.jar") set(WIX_PROJECT_NAME "Amazon DocumentDB") set(WIX_MANUFACTURER "Amazon Web Services") + set(WIX_JRE_INSTALLER_NAME "documentdb-jre") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(WIX_BIT_SUFFIX "64-bit") @@ -250,7 +269,6 @@ if (WIN32 AND ${WITH_ODBC_MSI}) set(WIX_COMPONENT_ID_MONGOC "7ee7d64d-2f03-4c8e-9da1-6995deb7c9ac") set(WIX_COMPONENT_ID_MONGOCXX "88eb3917-63e0-4e7c-ae6e-04dae66df013") set(WIX_COMPONENT_ID_ZLIB1 "2c920532-81fa-4088-a446-47aaa8db83ae") - set(WIX_COMPONENT_ID_JDBC "70020c86-713b-423d-b782-79f72ec7a388") set(WIX_COMPONENT_ID_DOCUMNETDB_HOME_ENV_VAR "281ea3c0-192c-4a3c-9ddf-5bc1cd77a790") set(WIX_COMPONENT_ID_PATH_JVM_DLL "ce3442b1-9a44-42f8-b492-82b01d9cf54a") set(WIX_BUNDLE_UPGRADE_CODE "f76aa702-9d83-427e-98ec-8b0749ae169a") @@ -258,9 +276,11 @@ if (WIN32 AND ${WITH_ODBC_MSI}) set(WIX_COMPONENT_IS_WIN64 "yes") set(WIX_PACKAGE_PLATFORM "x64") set(WIX_VC_DOWNLOAD_URL "https://aka.ms/vs/17/release/vc_redist.x64.exe") - set(WIX_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-amd64) - set(WIX_BUNDLE_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-amd64-all) + set(WIX_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-amd64-${ODBC_DRIVER_VERSION}) + set(WIX_BUNDLE_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-amd64-${ODBC_DRIVER_VERSION}-all) set(WIX_VCRUNTIME_NAME "VC_redist.x64.exe") + set(WIX_COMPONENT_ID_JVM_PATH_ENV_VAR "4de23e2e-b4f3-486f-a50f-b65dc25e34bc") + set(JLINK_MODULES "jdk.management.jfr,java.rmi,jdk.jdi,jdk.charsets,java.xml,jdk.xml.dom,java.datatransfer,jdk.jstatd,jdk.httpserver,java.desktop,java.security.sasl,jdk.zipfs,java.base,jdk.crypto.ec,jdk.javadoc,jdk.management.agent,jdk.jshell,jdk.editpad,jdk.jsobject,jdk.sctp,java.sql.rowset,java.smartcardio,jdk.jlink,jdk.unsupported,java.security.jgss,java.compiler,jdk.nio.mapmode,jdk.dynalink,jdk.unsupported.desktop,jdk.accessibility,jdk.security.jgss,java.sql,jdk.incubator.vector,java.xml.crypto,java.logging,java.transaction.xa,jdk.jfr,jdk.crypto.cryptoki,jdk.random,jdk.net,java.naming,jdk.internal.ed,java.prefs,java.net.http,jdk.compiler,jdk.internal.opt,jdk.naming.rmi,jdk.jconsole,jdk.attach,jdk.crypto.mscapi,jdk.internal.le,java.management,jdk.jdwp.agent,jdk.incubator.foreign,jdk.internal.jvmstat,java.instrument,jdk.management,jdk.security.auth,java.scripting,jdk.jdeps,jdk.jartool,jdk.jpackage,java.management.rmi,jdk.naming.dns,jdk.localedata") elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) set(WIX_BIT_SUFFIX "32-bit") set(WIX_PRODUCT_ID "60cb757b-69cb-412c-9d06-f22cd96914ed") @@ -271,7 +291,6 @@ if (WIN32 AND ${WITH_ODBC_MSI}) set(WIX_COMPONENT_ID_MONGOC "694ecd9b-7d68-4998-bc82-83d82ba2bde6") set(WIX_COMPONENT_ID_MONGOCXX "0aa05333-e7ff-4f32-9d89-0b637475425e") set(WIX_COMPONENT_ID_ZLIB1 "41f84e00-d899-493b-a0c4-c59b53998538") - set(WIX_COMPONENT_ID_JDBC "1ff0aa89-8a06-4c21-b0ce-ff9523ac8f10") set(WIX_COMPONENT_ID_DOCUMNETDB_HOME_ENV_VAR "04aff702-9fe4-4dc1-9979-daa94aca5a03") set(WIX_COMPONENT_ID_PATH_JVM_DLL "cd20ba75-b91d-4189-bb9e-8d3a8036928f") set(WIX_BUNDLE_UPGRADE_CODE "a2788555-6ba4-4e1f-b429-cbb9e6ea7421") @@ -279,13 +298,24 @@ if (WIN32 AND ${WITH_ODBC_MSI}) set(WIX_COMPONENT_IS_WIN64 "no") set(WIX_PACKAGE_PLATFORM "x86") set(WIX_VC_DOWNLOAD_URL "https://aka.ms/vs/17/release/vc_redist.x86.exe") - set(WIX_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-x86) - set(WIX_BUNDLE_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-x86-all) + set(WIX_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-x86-${ODBC_DRIVER_VERSION}) + set(WIX_BUNDLE_INSTALLER_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/documentdb-odbc-x86-${ODBC_DRIVER_VERSION}-all) set(WIX_VCRUNTIME_NAME "VC_redist.x86.exe") + set(WIX_COMPONENT_ID_JVM_PATH_ENV_VAR "3C1D09FA-07A0-4FB6-A60B-FAD83AC08709") + set(JLINK_MODULES "jdk.management.jfr,java.rmi,jdk.jdi,jdk.charsets,java.xml,jdk.xml.dom,java.datatransfer,jdk.jstatd,jdk.httpserver,java.desktop,java.security.sasl,jdk.zipfs,java.base,jdk.crypto.ec,jdk.javadoc,jdk.management.agent,jdk.jshell,jdk.editpad,jdk.jsobject,jdk.sctp,java.sql.rowset,java.smartcardio,jdk.jlink,jdk.unsupported,java.security.jgss,java.compiler,jdk.dynalink,jdk.unsupported.desktop,jdk.accessibility,jdk.security.jgss,java.sql,java.xml.crypto,java.logging,java.transaction.xa,jdk.jfr,jdk.crypto.cryptoki,jdk.net,java.naming,jdk.internal.ed,java.prefs,java.net.http,jdk.compiler,jdk.internal.opt,jdk.naming.rmi,jdk.jconsole,jdk.attach,jdk.crypto.mscapi,jdk.internal.le,java.management,jdk.jdwp.agent,jdk.internal.jvmstat,java.instrument,jdk.management,jdk.security.auth,java.scripting,jdk.jdeps,jdk.jartool,java.management.rmi,jdk.naming.dns,jdk.localedata") endif() + set(WIX_JRE_INSTALLER "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${WIX_JRE_INSTALLER_NAME}-${WIX_PACKAGE_PLATFORM}-${JLINK_VERSION}") set(WIX_PRODUCT_NAME "${WIX_PROJECT_NAME} ODBC ${WIX_BIT_SUFFIX} Driver") + set(JPACKAGE_RESOURCE "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/jpackage-resources") + file(MAKE_DIRECTORY ${JPACKAGE_RESOURCE}) + configure_file( + "${CMAKE_CURRENT_LIST_DIR}/install/${WIX_JRE_INSTALLER_NAME}.wxs.in" + "${JPACKAGE_RESOURCE}/main.wxs" + @ONLY + ) + configure_file( "${CMAKE_CURRENT_LIST_DIR}/install/documentdb-odbc.wxs.in" "${WIX_INSTALLER_PREFIX}.wxs" @@ -305,8 +335,12 @@ if (WIN32 AND ${WITH_ODBC_MSI}) COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/odbc/install/images $/images) + set (JLINK_RUNTIME_IMAGE_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/runtime-image") + file(REMOVE_RECURSE ${JLINK_RUNTIME_IMAGE_DIR}) add_custom_command( TARGET ${TARGET} POST_BUILD + COMMAND ${JAVA_JLINK} --output ${JLINK_RUNTIME_IMAGE_DIR} --strip-native-commands --strip-debug --no-man-pages --no-header-files --module-path $ENV{JAVA_HOME}/jmods --add-modules ${JLINK_MODULES} + COMMAND ${JAVA_JPACKAGE} --runtime-image ${JLINK_RUNTIME_IMAGE_DIR} --resource-dir "${JPACKAGE_RESOURCE}" --name "${WIX_JRE_INSTALLER_NAME}-${WIX_PACKAGE_PLATFORM}" --vendor "${WIX_MANUFACTURER}" --copyright "Copyright (c) 2022 Amazon.com" --win-upgrade-uuid "d90635c3-2233-443d-8c46-42ae1d922dc1" --type msi --dest "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}" --app-version "${JLINK_VERSION}" COMMAND ${WIX_CANDLE} ${WIX_INSTALLER_PREFIX}.wxs -out ${WIX_INSTALLER_PREFIX}.wxobj COMMAND ${WIX_LIGHT} -ext WixUIExtension ${WIX_INSTALLER_PREFIX}.wxobj -out ${WIX_INSTALLER_PREFIX}.msi COMMAND ${WIX_CANDLE} ${WIX_BUNDLE_INSTALLER_PREFIX}.wxs -ext WixBalExtension -ext WixUtilExtension -out ${WIX_BUNDLE_INSTALLER_PREFIX}.wxobj @@ -323,6 +357,7 @@ install(TARGETS ${TARGET} ) if (WIN32 AND ${WITH_ODBC_MSI}) + install(FILES ${WIX_JRE_INSTALLER}.msi DESTINATION bin) install(FILES ${WIX_INSTALLER_PREFIX}.msi DESTINATION bin) install(FILES ${WIX_BUNDLE_INSTALLER_PREFIX}.exe DESTINATION bin) endif() diff --git a/src/odbc/install/documentdb-jre.wxs.in b/src/odbc/install/documentdb-jre.wxs.in new file mode 100644 index 000000000..6dd43f397 --- /dev/null +++ b/src/odbc/install/documentdb-jre.wxs.in @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Not Installed + Not Installed + Not Installed + Not Installed + + Not Installed + + + Not Installed + + + Not Installed + + + + JP_UPGRADABLE_FOUND + + + JP_DOWNGRADABLE_FOUND + + + + + + diff --git a/src/odbc/install/documentdb-odbc-bundle.wxs.in b/src/odbc/install/documentdb-odbc-bundle.wxs.in index 0c4dd4155..16b0c9f89 100644 --- a/src/odbc/install/documentdb-odbc-bundle.wxs.in +++ b/src/odbc/install/documentdb-odbc-bundle.wxs.in @@ -26,6 +26,8 @@ RepairCommand="/q ACTION=Repair /hideconsole" Permanent="yes" /> + + diff --git a/src/odbc/install/documentdb-odbc.wxs.in b/src/odbc/install/documentdb-odbc.wxs.in index 7e4ca8577..485916cba 100644 --- a/src/odbc/install/documentdb-odbc.wxs.in +++ b/src/odbc/install/documentdb-odbc.wxs.in @@ -65,17 +65,14 @@ - - - - - - - - - - + + + + + + + @@ -91,7 +88,6 @@ -