Skip to content

Commit 8995a4e

Browse files
committed
Delete native assets package
1 parent 0b45401 commit 8995a4e

File tree

166 files changed

+321
-6246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+321
-6246
lines changed

pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ environment:
66

77
workspace:
88
- sqlite3
9-
- sqlite3_native_assets
10-
- sqlite3/example/custom_extension_native_assets
9+
- sqlite3/example/custom_extension

sqlite3/example/custom_extension/.gitignore

Lines changed: 0 additions & 33 deletions
This file was deleted.

sqlite3/example/custom_extension/.metadata

Lines changed: 0 additions & 42 deletions
This file was deleted.

sqlite3/example/custom_extension/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

sqlite3/example/custom_extension/LICENSE

Lines changed: 0 additions & 1 deletion
This file was deleted.

sqlite3/example/custom_extension/Makefile

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
# uuid.c example
1+
This shows how a custom SQLite extension can be linked with native assets.
22

3-
This example shows how to load SQLite extensions into Flutter apps using `sqlite3_flutter_libs`.
4-
As an example, it uses the [uuid.c](https://github.com/sqlite/sqlite/blob/master/ext/misc/uuid.c)
5-
extension, but other extensions can be adapted similarly.
3+
The extension (https://github.com/asg017/sqlite-vec) is built with a code asset that will download
4+
the extension as a prebuilt file from its GitHub releases.
65

7-
To build the extension:
6+
SQLite extensions are shared libraries that have a function called `sqlite3_$extensionName_init`.
7+
With the hook linking the extension, you can bind to that function with Dart:
88

9-
1. A `CMakeLists.txt` (in `src/`) is written for Android, Linux and Windows.
10-
2. On Android, the NDK is set up to point at the CMake builds in `android/build.gradle`.
11-
3. For macOS and iOS (which don't use CMake as a build tool), the `uuid.c` file is added
12-
to `macos|ios/Classes` instead.
13-
4. Note that this example does not currently support WebAssembly. Loadable extensions don't
14-
work on the web, but you can compile a custom `sqlite3.wasm` bundle with the desired extensions
15-
included. The `../custom_wasm_build` example has an example for that setup.
9+
```dart
10+
@Native<Int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>)>()
11+
external int sqlite3_vec_init(
12+
Pointer<Void> db,
13+
Pointer<Void> pzErrMsg,
14+
Pointer<Void> pApi,
15+
);
16+
17+
```
1618

17-
This build setup includes a shared library with the extension in your app. To use it, load the
18-
`DynamicLibrary` and then load it into sqlite3 like this:
19+
This will then allow linking the extension:
1920

2021
```dart
21-
sqlite3.ensureExtensionLoaded(
22-
SqliteExtension.inLibrary(uuid.lib, 'sqlite3_uuid_init'),
23-
);
22+
extension LoadVectorExtension on Sqlite3 {
23+
void loadSqliteVectorExtension() {
24+
ensureExtensionLoaded(
25+
SqliteExtension(
26+
Native.addressOf<
27+
NativeFunction<
28+
Int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>)
29+
>
30+
>(sqlite3_vec_init).cast(),
31+
),
32+
);
33+
}
34+
}
2435
```
36+
37+
To try this example, run `dart run example/main.dart`.

sqlite3/example/custom_extension/analysis_options.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

sqlite3/example/custom_extension/android/.gitignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

sqlite3/example/custom_extension/android/build.gradle

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)