-
-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1037 from tekartik/dart3a
Dart3a
- Loading branch information
Showing
22 changed files
with
213 additions
and
103 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ build/ | |
/web/sqlite3.wasm | ||
/test/sqflite_sw.js | ||
/test/sqlite3.wasm | ||
/test/sqflite_sw_v1.js |
This file contains 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
5 changes: 5 additions & 0 deletions
5
packages_web/sqflite_common_ffi_web_test/tool/setup_web_tests.dart
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:sqflite_common_ffi_web/src/setup/setup.dart'; | ||
|
||
Future<void> main() async { | ||
await setupBinaries(options: SetupOptions(verbose: true, dir: 'test')); | ||
} |
6 changes: 6 additions & 0 deletions
6
packages_web/sqflite_common_ffi_web_test/tool/setup_web_tests_force.dart
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:sqflite_common_ffi_web/src/setup/setup.dart'; | ||
|
||
Future<void> main() async { | ||
await setupBinaries( | ||
options: SetupOptions(verbose: true, dir: 'test', force: true)); | ||
} |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
## 2.3.0 | ||
## 2.3.0+2 | ||
|
||
* Dart 3 only. | ||
* Bundle Windows sqlite3.dll 3.42.0 | ||
|
||
## 2.2.5 | ||
|
||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Updating SQLite DLL | ||
|
||
This projects ships with a precompiled version of the SQLite DLL for Windows that allows running dart and flutter app | ||
without additional setup. This version might not be the latest available at https://www.sqlite.org/download.html. | ||
|
||
You should grab and copy a fresh version of sqlite3.dll for your released app to bundle with your app. | ||
|
||
## Upgrading SQLite dll | ||
|
||
`sqlite3_info.dart` can be modified to download a new version of the SQLite DLL by running `tool/windows_setup.dart`. |
This file contains 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
Binary file not shown.
This file contains 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/// Information about the bundled sqlite3.dll | ||
/// https://www.sqlite.org/download.html | ||
class Sqlite3DllInfo { | ||
/// Version string. | ||
final String version; | ||
|
||
/// Src zip. | ||
final String srcZip; | ||
|
||
/// Sha3. | ||
final String sha3; | ||
|
||
/// Sqflite3DllInfo. | ||
Sqlite3DllInfo(this.version, this.srcZip, this.sha3); | ||
|
||
/// Sqflite3DllInfo from map. | ||
factory Sqlite3DllInfo.fromMap(Map map) => Sqlite3DllInfo( | ||
map['version']!.toString(), | ||
map['srcZip']!.toString(), | ||
map['sha3']!.toString()); | ||
|
||
/// To map. | ||
Map<String, Object?> toMap() => <String, Object?>{ | ||
'version': version, | ||
'srcZip': srcZip, | ||
'sha3': sha3, | ||
}; | ||
@override | ||
String toString() => '$version $srcZip $sha3'; | ||
} | ||
|
||
/// 3.38.2 info | ||
var sqlite3_38_2Info = Sqlite3DllInfo( | ||
'3.38.2', | ||
'https://www.sqlite.org/2022/sqlite-dll-win64-x64-3380200.zip', | ||
'9f71eec9a2c7f12602eaa2af76bd7c052e540502ae7a89dac540e10962e2fa35'); | ||
|
||
// sqlite-dll-win64-x64-3420000.zip | ||
// (1.16 MiB) 64-bit DLL (x64) for SQLite version 3.42.0. | ||
// (SHA3-256: 2425efa95556793a20761dfdab0d3b56a52e61716e8bb65e6a0a3590d41c97c0) | ||
/// 3.42.0 info | ||
var sqlite3_42_0Info = Sqlite3DllInfo( | ||
'3.42.0', | ||
'https://www.sqlite.org/2023/sqlite-dll-win64-x64-3420000.zip', | ||
'2425efa95556793a20761dfdab0d3b56a52e61716e8bb65e6a0a3590d41c97c0'); | ||
|
||
/// Current info | ||
var sqlite3Info = sqlite3_42_0Info; |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"3.42.0","srcZip":"https://www.sqlite.org/2023/sqlite-dll-win64-x64-3420000.zip","sha3":"2425efa95556793a20761dfdab0d3b56a52e61716e8bb65e6a0a3590d41c97c0"} |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
import 'package:archive/archive_io.dart'; | ||
import 'package:http/http.dart'; | ||
import 'package:path/path.dart'; | ||
import 'package:sqflite_common_ffi/src/windows/setup.dart'; | ||
import 'package:sqflite_common_ffi/src/windows/setup_impl.dart'; | ||
import 'package:sqflite_common_ffi/src/windows/sqlite3_info.dart'; | ||
|
||
class Sqlite3DllSetupHelper { | ||
final Sqlite3DllInfo sqlite3Info; | ||
// This tests does actually the actual install of the dll | ||
|
||
late var srcZip = sqlite3Info.srcZip; | ||
late var localZip = join('.local', basename(srcZip)); | ||
late var localExtractedZipDir = | ||
join('.local', basenameWithoutExtension(srcZip)); | ||
late var localExtractedJsonInfoFile = | ||
join(localExtractedZipDir, sqflite3InfoJsonFileName); | ||
var bundledDir = join('lib', dirname(packageGetSqlite3DllPath('.'))); | ||
late var bundledJsonInfoFilePath = join(bundledDir, 'sqlite3_info.json'); | ||
late var bundledSqlite3DllFilePath = join(bundledDir, 'sqlite3.dll'); | ||
late var localInfoZip = join('.local', basename(srcZip)); | ||
|
||
Sqlite3DllSetupHelper(this.sqlite3Info); | ||
|
||
/// For tools and test only. not exported. | ||
/// Returns null on failure, don't care about the failure... | ||
Future<Sqlite3DllInfo?> readBundleInfo() async { | ||
try { | ||
var map = pathGetJson(bundledJsonInfoFilePath); | ||
var sqlite3Info = Sqlite3DllInfo.fromMap(map); | ||
print('sqlite3Info $sqlite3Info'); | ||
} catch (_) {} | ||
return null; | ||
} | ||
|
||
Future<bool> getZip() async { | ||
if (!File(localZip).existsSync()) { | ||
print('Downloading sqlite3 $sqlite3Info'); | ||
await Directory(dirname(localZip)).create(recursive: true); | ||
try { | ||
await File(localZip).writeAsBytes(await readBytes(Uri.parse(srcZip))); | ||
} catch (e) { | ||
stderr.writeln( | ||
'Fail to fetch sqlite.zip version $sqlite3_38_2Info at $srcZip'); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
Future<void> extractZip() async { | ||
var jsonInfo = File(localExtractedJsonInfoFile); | ||
if (!jsonInfo.existsSync()) { | ||
// Extract the zip | ||
print('Extracting $localZip to $localExtractedZipDir'); | ||
final inputStream = InputFileStream(localZip); | ||
final archive = ZipDecoder().decodeBuffer(inputStream); | ||
extractArchiveToDisk(archive, localExtractedZipDir); | ||
await jsonInfo.writeAsString(jsonEncode(sqlite3Info.toMap())); | ||
} | ||
} | ||
|
||
Future<void> copyToBundle() async { | ||
var srcFile = join(localExtractedZipDir, 'sqlite3.dll'); | ||
var dstFile = bundledSqlite3DllFilePath; | ||
print('Copying $srcZip to $dstFile'); | ||
//await File(dstFile).delete(recursive: true); | ||
await File(srcFile).copy(dstFile); | ||
await File(bundledJsonInfoFilePath) | ||
.writeAsString(jsonEncode(sqlite3Info.toMap())); | ||
//await File() | ||
} | ||
} | ||
|
||
/// This tool is actually ran on linux to download install the updated dll | ||
Future main() async { | ||
await setupSqliteDll(); | ||
} | ||
|
||
Future setupSqliteDll() async { | ||
// Tested only on linux for now. | ||
if (Platform.isLinux) { | ||
var helper = Sqlite3DllSetupHelper(sqlite3Info); | ||
var info = await helper.readBundleInfo(); | ||
if (info?.version != sqlite3Info.version) { | ||
await helper.getZip(); | ||
await helper.extractZip(); | ||
await helper.copyToBundle(); | ||
} else { | ||
print('sqlite3 $sqlite3Info already up to date'); | ||
} | ||
} else { | ||
stderr.writeln('To run on linux!'); | ||
} | ||
} |
Oops, something went wrong.