-
Notifications
You must be signed in to change notification settings - Fork 110
SQLCipher build hook #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
SQLCipher build hook #375
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c8cd55f
sqlcipher target
davidmartos96 b38b0d2
hashes
davidmartos96 f0d680b
hashes update
davidmartos96 4005eb4
Trigger Actions detection
davidmartos96 8d2983c
cleanup
davidmartos96 6fdb82a
Merge branch 'main' into sqlcipher_pr
davidmartos96 b36ccb6
recover jobs
davidmartos96 166208d
cleanup
davidmartos96 fc2df9c
move flags
davidmartos96 0fb180f
cleanup
davidmartos96 979bf55
add archs
davidmartos96 257dbc3
library type
davidmartos96 852d774
fix name
davidmartos96 e8cbac7
copy clean openssl src dir for each arch
davidmartos96 b4f6acb
openssl folder per abi
davidmartos96 42c78e7
cleanup
davidmartos96 7b1b6e7
improvements
davidmartos96 9e2f295
perl Configure instead of ./Configure
davidmartos96 7f2a994
exclude some linux archs
davidmartos96 628a08a
encryption test
davidmartos96 0eed2b2
cleanup
davidmartos96 81f85ca
exclude sqlcipher tests on windows
davidmartos96 6223d81
fix log link
davidmartos96 9c4def4
extra flags
davidmartos96 5596169
format
davidmartos96 b31853d
Merge remote-tracking branch 'origin/sqlcipher' into sqlcipher_pr
davidmartos96 88d9530
cleanup after merge
davidmartos96 0c86241
link statically
davidmartos96 58a7d44
analyze
davidmartos96 2788cb6
fix
davidmartos96 632b96d
build openssl refactor
davidmartos96 80d2d0b
compile android
davidmartos96 2d5bb2f
ndk root
davidmartos96 f5d4f1c
download openssl
davidmartos96 662a407
cleanup
davidmartos96 ce4184b
integration tests
davidmartos96 49bf0c5
fix test
davidmartos96 4a247e4
Trigger Actions detection
davidmartos96 960df55
cleanup
davidmartos96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,15 +60,70 @@ ${usedSqliteSymbols.map((symbol) => ' $symbol;').join('\n')} | |
| } | ||
|
|
||
| final isSqlcipher = input.userDefines['is_sqlcipher'] as bool? ?? false; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm to blame for this, but there should be a comment here explaining that these options are internal, undocumented and only meant to be set via |
||
|
|
||
| final targetOS = input.config.code.targetOS; | ||
| final targetArchitecture = input.config.code.targetArchitecture; | ||
| final isAppleTarget = targetOS == OS.iOS || targetOS == OS.macOS; | ||
|
|
||
| // Directory where the architecture compiled OpenSSL is located. Null if OpenSSL is not used | ||
| Directory? openSslCompileDir; | ||
| File? openSslStaticLib; | ||
| if (isSqlcipher) { | ||
| final linksWithOpenSSL = | ||
| targetOS == OS.android || | ||
| targetOS == OS.linux || | ||
| targetOS == OS.windows; | ||
| if (linksWithOpenSSL) { | ||
| const openSSLCompiledRootKey = 'openssl_compiled_root'; | ||
| final Uri? opensslCompiledRoot = input.userDefines.path( | ||
| openSSLCompiledRootKey, | ||
| ); | ||
|
|
||
| if (opensslCompiledRoot == null) { | ||
| throw StateError( | ||
| 'Target $targetOS needs OpenSSL compiled dir root with \'openSSLCompiledRootKey\'', | ||
| ); | ||
| } | ||
|
|
||
| openSslCompileDir = Directory( | ||
| p.join( | ||
| opensslCompiledRoot.toFilePath(), | ||
| "${targetOS.name}-${targetArchitecture.name}", | ||
| ), | ||
| ); | ||
|
|
||
| if (!await openSslCompileDir.exists()) { | ||
| throw StateError( | ||
| 'Expected OpenSSL compiled directory at ${openSslCompileDir.path}', | ||
| ); | ||
| } | ||
|
|
||
| openSslStaticLib = File( | ||
| p.join( | ||
| openSslCompileDir.path, | ||
| _getOpenSslLibFolderName(targetOS, targetArchitecture), | ||
|
simolus3 marked this conversation as resolved.
|
||
| targetOS.staticlibFileName('crypto'), | ||
| ), | ||
| ); | ||
|
|
||
| if (!await openSslStaticLib.exists()) { | ||
| throw StateError( | ||
| 'Expected OpenSSL static library at ${openSslStaticLib.path}', | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| final library = CBuilder.library( | ||
| name: 'sqlite3', | ||
| packageName: 'sqlite3', | ||
| assetName: name, | ||
| sources: [sourceFile], | ||
| includes: [p.dirname(sourceFile)], | ||
| includes: [ | ||
| p.dirname(sourceFile), | ||
| if (openSslCompileDir != null) | ||
| p.join(openSslCompileDir.path, 'include'), | ||
| ], | ||
| defines: defines, | ||
| flags: [ | ||
| if (input.config.code.targetOS == OS.linux) ...[ | ||
|
|
@@ -78,12 +133,11 @@ ${usedSqliteSymbols.map((symbol) => ' $symbol;').join('\n')} | |
| // export, we might as well strip the rest. | ||
| // TODO: Port this to other targets too. | ||
| '-Wl,--version-script=$linkerScript', | ||
| // Strip symbols | ||
| '-s', | ||
| '-ffunction-sections', | ||
| '-fdata-sections', | ||
| '-Wl,--gc-sections', | ||
| if (isSqlcipher) | ||
| // TODO: Link OpenSSL statically? | ||
| '-lcrypto', | ||
| ], | ||
| if (isAppleTarget) ...[ | ||
| '-headerpad_max_install_names', | ||
|
|
@@ -101,10 +155,17 @@ ${usedSqliteSymbols.map((symbol) => ' $symbol;').join('\n')} | |
| ], | ||
| ], | ||
| ], | ||
| libraryDirectories: [ | ||
| if (openSslStaticLib != null) openSslStaticLib.parent.path, | ||
| ], | ||
| libraries: [ | ||
| if (input.config.code.targetOS == OS.android) | ||
| if (targetOS == OS.android) ...[ | ||
| // We need to link the math library on Android. | ||
| 'm', | ||
| if (isSqlcipher) 'log', | ||
| ], | ||
| // Link with OpenSSL (SQLCipher builds) | ||
| if (openSslCompileDir != null) 'crypto', | ||
| ], | ||
| ); | ||
|
|
||
|
|
@@ -121,5 +182,12 @@ ${usedSqliteSymbols.map((symbol) => ' $symbol;').join('\n')} | |
| }); | ||
| } | ||
|
|
||
| String _getOpenSslLibFolderName(OS os, Architecture architecture) { | ||
| return switch ((os, architecture)) { | ||
| (OS.linux, Architecture.x64) => 'lib64', | ||
| _ => 'lib', | ||
| }; | ||
| } | ||
|
|
||
| const package = 'sqlite3'; | ||
| const name = 'src/ffi/libsqlite3.g.dart'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Booting an emulator is quite slow. I wonder if the Android emulator tests should be a separate job now, where we might spawn a single Android emulator only and use a
script:that runs multipleflutter testcalls with different build options in sequence?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Should we create a bash script for the ci tests? Or would you like placing the "&&"s in the workflow yaml directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly in the yaml should work