Skip to content

Commit

Permalink
add back dynamically linked build
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed May 28, 2024
1 parent 12cf7b1 commit cc94539
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
name: Build
runs-on: ${{ matrix.os }}
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}-windows
VCPKG_DYNAMIC_TRIPLET: ${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}-windows
VCPKG_STATIC_TRIPLET: ${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}-windows-static
SQLCIPHER_NMAKE_VARS: USE_AMALGAMATION=1 NO_TCL=1 SQLITE3DLL=sqlcipher.dll SQLITE3LIB=sqlcipher.lib SQLITE3EXE=sqlcipher.exe
SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS: -DSQLITE_TEMP_STORE=2 -DSQLITE_HAS_CODEC=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_RTREE=1 -DSQLCIPHER_CRYPTO_OPENSSL=1 -DSQLITE_MAX_ATTACHED=125
permissions:
Expand Down Expand Up @@ -45,15 +46,16 @@ jobs:
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup OpenSSL
# about default OpenSSL 1.x: ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12
run: |
vcpkg install openssl:${{ env.VCPKG_DEFAULT_TRIPLET }}-static --binarysource="clear;x-gha,readwrite"
vcpkg install openssl:${{ env.VCPKG_DYNAMIC_TRIPLET }} openssl:${{ env.VCPKG_STATIC_TRIPLET }} --binarysource="clear;x-gha,readwrite"
- name: Init folders
continue-on-error: true
run: |
mkdir -p C:\temp\${{ matrix.arch }}\
mkdir -p C:\dev
mkdir -p C:\dev\SQLCipher-${{ matrix.arch }}
mkdir C:\temp\${{ matrix.arch }}\
mkdir C:\dev
mkdir C:\dev\SQLCipher-${{ matrix.arch }}
- name: Checkout SQLCipher
run: |
Expand All @@ -63,19 +65,35 @@ jobs:
working-directory: C:\dev\SQLCipher-${{ matrix.arch }}

- name: Build SQLCipher (statically linked)
# ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12
# ref: https://blog.hamaluik.ca/posts/statically-linking-sqlcipher-on-windows
run: |
mkdir sqlcipher\static
nmake /f Makefile.msc clean
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}-static\lib\libcrypto.lib`"" TCCOPTS="`"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}-static\include`"" RCCOPTS="`"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}-static\include`"" LTLIBPATHS="`"/LIBPATH:$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}-static\lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}-static\include`"" LTLIBS="libcrypto.lib libssl.lib WS2_32.Lib Gdi32.Lib AdvAPI32.Lib Crypt32.Lib User32.Lib"
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_STATIC_TRIPLET }}\lib\libcrypto.lib`"" TCCOPTS="`"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_STATIC_TRIPLET }}\include`"" RCCOPTS="`"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_STATIC_TRIPLET }}\include`"" LTLIBPATHS="`"/LIBPATH:$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_STATIC_TRIPLET }}\lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_STATIC_TRIPLET }}\include`"" LTLIBS="libcrypto.lib libssl.lib WS2_32.Lib Gdi32.Lib AdvAPI32.Lib Crypt32.Lib User32.Lib"
copy sqlcipher.exe sqlcipher-${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}.exe
copy sqlcipher.exe sqlcipher
copy sqlite3.c,sqlite3.h,sqlcipher.dll,sqlcipher.lib sqlcipher
copy sqlcipher.dll,sqlcipher.exe sqlcipher\static
working-directory: C:\dev\SQLCipher-${{ matrix.arch }}

- name: Build SQLCipher (dynamically linked)
run: |
mkdir sqlcipher\dynamic
nmake /f Makefile.msc clean
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DYNAMIC_TRIPLET }}\lib\libcrypto.lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DYNAMIC_TRIPLET }}\include`""
copy sqlcipher.dll,sqlcipher.exe,"$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DYNAMIC_TRIPLET }}\bin\libcrypto-*.dll" sqlcipher\dynamic
working-directory: C:\dev\SQLCipher-${{ matrix.arch }}

- name: Copy SQLCipher amalgamation & misc files
run: |
mkdir sqlcipher\amalgamation
copy sqlite3.c,sqlite3.h sqlcipher\amalgamation
mkdir -Force sqlcipher\misc
copy sqlcipher.lib sqlcipher\misc
working-directory: C:\dev\SQLCipher-${{ matrix.arch }}

- name: Copy LICENSE
run: |
copy LICENSE* C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher
mkdir -Force C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher\misc
copy LICENSE* C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher\misc
- name: Prepare artifacts
run: |
Expand All @@ -85,7 +103,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.arch }}
path: build-artifacts-${{ matrix.arch }}.zip
path: C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher
retention-days: 7

- name: Release
Expand Down

0 comments on commit cc94539

Please sign in to comment.