| 
 | 1 | +import 'dart:io';  | 
 | 2 | + | 
 | 3 | +const sqlitePath = 'sqlite-amalgamation-3500400';  | 
 | 4 | +const sqliteSource = 'https://sqlite.org/2025/$sqlitePath.zip';  | 
 | 5 | +const sqliteMultipleCiphersSource =  | 
 | 6 | +    'https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v2.2.4/sqlite3mc-2.2.4-sqlite-3.50.4-amalgamation.zip';  | 
 | 7 | + | 
 | 8 | +const tmpDir = 'tmp';  | 
 | 9 | + | 
 | 10 | +void main(List<String> args) async {  | 
 | 11 | +  await Directory(tmpDir).create();  | 
 | 12 | + | 
 | 13 | +  await _downloadAndExtract(sqliteSource, 'sqlite3');  | 
 | 14 | +  await _downloadAndExtract(sqliteMultipleCiphersSource, 'sqlite3mc');  | 
 | 15 | + | 
 | 16 | +  await Directory('out').create();  | 
 | 17 | +  await Directory('out/sqlite3mc').create();  | 
 | 18 | +  await File('$tmpDir/sqlite3mc_amalgamation.h')  | 
 | 19 | +      .copy('out/sqlite3mc/sqlite3mc_amalgamation.h');  | 
 | 20 | +  await File('$tmpDir/sqlite3mc_amalgamation.c')  | 
 | 21 | +      .copy('out/sqlite3mc/sqlite3mc_amalgamation.c');  | 
 | 22 | + | 
 | 23 | +  await Directory('out/sqlite3').create();  | 
 | 24 | +  await File('$tmpDir/$sqlitePath/sqlite3.h').copy('out/sqlite3/sqlite3.h');  | 
 | 25 | +  await File('$tmpDir/$sqlitePath/sqlite3.c').copy('out/sqlite3/sqlite3.c');  | 
 | 26 | +  await File('$tmpDir/$sqlitePath/sqlite3ext.h')  | 
 | 27 | +      .copy('out/sqlite3/sqlite3ext.h');  | 
 | 28 | +}  | 
 | 29 | + | 
 | 30 | +Future<void> _downloadAndExtract(String url, String filename) async {  | 
 | 31 | +  await _run('curl -L $url --output $filename.zip', workingDirectory: tmpDir);  | 
 | 32 | +  await _run('unzip $filename.zip', workingDirectory: tmpDir);  | 
 | 33 | +}  | 
 | 34 | + | 
 | 35 | +Future<void> _run(String command, {String? workingDirectory}) async {  | 
 | 36 | +  print('Running $command');  | 
 | 37 | + | 
 | 38 | +  final proc = await Process.start(  | 
 | 39 | +    'sh',  | 
 | 40 | +    ['-c', command],  | 
 | 41 | +    mode: ProcessStartMode.inheritStdio,  | 
 | 42 | +    workingDirectory: workingDirectory,  | 
 | 43 | +  );  | 
 | 44 | +  final exitCode = await proc.exitCode;  | 
 | 45 | + | 
 | 46 | +  if (exitCode != 0) {  | 
 | 47 | +    exit(exitCode);  | 
 | 48 | +  }  | 
 | 49 | +}  | 
0 commit comments