File tree Expand file tree Collapse file tree 11 files changed +276811
-0
lines changed
pkgs/code_assets/example/build/sqlite Expand file tree Collapse file tree 11 files changed +276811
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'package:code_assets/code_assets.dart' ;
6
+ import 'package:hooks/hooks.dart' ;
7
+ import 'package:logging/logging.dart' ;
8
+ import 'package:native_toolchain_c/native_toolchain_c.dart' ;
9
+
10
+ void main (List <String > args) async {
11
+ await build (args, (input, output) async {
12
+ if (input.config.buildCodeAssets) {
13
+ final cbuilder = CBuilder .library (
14
+ name: 'sqlite3' ,
15
+ assetName: 'src/third_party/sqlite3.g.dart' ,
16
+ sources: ['third_party/sqlite/sqlite3.c' ],
17
+ defines: {
18
+ if (input.config.code.targetOS == OS .windows)
19
+ // Ensure symbols are exported in dll.
20
+ 'SQLITE_API' : '__declspec(dllexport)' ,
21
+ },
22
+ );
23
+ await cbuilder.run (
24
+ input: input,
25
+ output: output,
26
+ logger: Logger ('' )
27
+ ..level = Level .ALL
28
+ ..onRecord.listen ((record) => print (record.message)),
29
+ );
30
+ }
31
+ });
32
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ export 'src/sqlite.dart' ;
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'package:ffi/ffi.dart' ;
6
+
7
+ import 'third_party/sqlite3.g.dart' ;
8
+
9
+ /// The machine's hostname.
10
+ ///
11
+ /// Returns `null` if looking up the machines host name fails.
12
+ String get version {
13
+ final nativeString = sqlite3_libversion ();
14
+ return nativeString.cast <Utf8 >().toDartString ();
15
+ }
Original file line number Diff line number Diff line change
1
+ // The author disclaims copyright to this source code. In place of
2
+ // a legal notice, here is a blessing:
3
+ //
4
+ // May you do good and not evil.
5
+ // May you find forgiveness for yourself and forgive others.
6
+ // May you share freely, never taking more than you give.
7
+
8
+ // AUTO GENERATED FILE, DO NOT EDIT.
9
+ //
10
+ // Generated by `package:ffigen`.
11
+ // ignore_for_file: type=lint
12
+ import 'dart:ffi' as ffi;
13
+
14
+ @ffi .Native <ffi.Pointer <ffi.Char > Function ()>()
15
+ external ffi.Pointer <ffi.Char > sqlite3_libversion ();
Original file line number Diff line number Diff line change
1
+ name : sqlite
2
+ description : An example for `package:code_assets` demonstrating how to bundle a locally built sqlite3 dynamic library.
3
+ version : 0.1.0
4
+ repository : https://github.com/dart-lang/native/tree/main/pkgs/sqlite
5
+
6
+ publish_to : none
7
+
8
+ resolution : workspace
9
+
10
+ environment :
11
+ sdk : ' >=3.9.0 <4.0.0'
12
+
13
+ dependencies :
14
+ code_assets : any
15
+ ffi : ^2.1.4
16
+ hooks : any
17
+ logging : ^1.3.0
18
+ native_toolchain_c : any
19
+
20
+ dev_dependencies :
21
+ ffigen : ^19.1.0
22
+ lints : ^6.0.0
23
+ test : ^1.25.15
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'package:sqlite/sqlite.dart' ;
6
+ import 'package:test/test.dart' ;
7
+
8
+ void main () {
9
+ test ('version' , () {
10
+ expect (version, equals ('3.50.4' ));
11
+ });
12
+ }
You can’t perform that action at this time.
0 commit comments