Skip to content

Update sqlite3 to v2.4.7 #14

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 12 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
id: cache_sqlite_build
with:
path: sqlite/out
key: sqlite-${{ runner.os }}-${{ env.SQLITE_VERSION }}
key: sqlite-v3-${{ runner.os }}-${{ env.SQLITE_VERSION }}
- name: Compile sqlite3 on Linux
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Linux'
run: |
Expand All @@ -37,6 +37,7 @@ jobs:
mkdir ../out
cp sqlite3 ../out
cp .libs/libsqlite3.so ../out
cp *.h ../out
- name: Compile sqlite3 on macOS
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'macOS'
run: |
Expand All @@ -50,6 +51,7 @@ jobs:
mkdir ../out
cp sqlite3 ../out
cp .libs/libsqlite3.dylib ../out
cp *.h ../out
- uses: ilammy/msvc-dev-cmd@v1
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Windows'
- name: Compile sqlite3 on Windows
Expand All @@ -69,6 +71,7 @@ jobs:
cp sqlite3.dll ../out
cp sqlite3.h ../out
cp sqlite3ext.h ../out
cp *.h ../out
- name: Upload built sqlite3 binaries
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -145,12 +148,14 @@ jobs:
chmod a+x sqlite/out/sqlite3
realpath sqlite/out >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$(realpath sqlite/out)" >> $GITHUB_ENV
echo "C_INCLUDE_PATH=$(realpath sqlite/out)" >> $GITHUB_ENV
- name: Install compiled sqlite3 (macOS)
if: runner.os == 'macOS'
run: |
chmod a+x sqlite/out/sqlite3
echo "$(pwd)/sqlite/out" >> $GITHUB_PATH
echo "DYLD_LIBRARY_PATH=$(pwd)/sqlite/out" >> $GITHUB_ENV
echo "CPATH=$(pwd)/sqlite/out" >> $GITHUB_ENV
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Install compiled sqlite3 (Windows)
Expand Down
4 changes: 4 additions & 0 deletions sqlite3/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.7

- Web: Improve performance of in-memory and IndexedDB file system implementations.

## 2.4.6

- WebAssembly: Call `_initialize` function of sqlite3 module if one is present.
Expand Down
33 changes: 33 additions & 0 deletions sqlite3/example/custom_extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/

src/sqlite3.h
src/sqlite3ext.h
vendor/
42 changes: 42 additions & 0 deletions sqlite3/example/custom_extension/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
channel: "stable"

project_type: plugin_ffi

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: android
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: ios
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: linux
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: macos
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: windows
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions sqlite3/example/custom_extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* TODO: Describe initial release.
1 change: 1 addition & 0 deletions sqlite3/example/custom_extension/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
21 changes: 21 additions & 0 deletions sqlite3/example/custom_extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
vendor:
mkdir -p vendor
curl -o sqlite-amalgamation.zip https://www.sqlite.org/2024/sqlite-amalgamation-3450300.zip
unzip sqlite-amalgamation.zip
mv sqlite-amalgamation-3450300/* vendor/
rmdir sqlite-amalgamation-3450300
rm sqlite-amalgamation.zip

deps: sqlite3ext.h sqlite3.h

init: vendor deps

sqlite3ext.h: ./vendor/sqlite3ext.h
cp $< $@
mv sqlite3ext.h src/

sqlite3.h: ./vendor/sqlite3.h
cp $< $@
mv sqlite3.h src/

.PHONY: deps
24 changes: 24 additions & 0 deletions sqlite3/example/custom_extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# uuid.c example

This example shows how to load SQLite extensions into Flutter apps using `sqlite3_flutter_libs`.
As an example, it uses the [uuid.c](https://github.com/sqlite/sqlite/blob/master/ext/misc/uuid.c)
extension, but other extensions can be adapted similarly.

To build the extension:

1. A `CMakeLists.txt` (in `src/`) is written for Android, Linux and Windows.
2. On Android, the NDK is set up to point at the CMake builds in `android/build.gradle`.
3. For macOS and iOS (which don't use CMake as a build tool), the `uuid.c` file is added
to `macos|ios/Classes` instead.
4. Note that this example does not currently support WebAssembly. Loadable extensions don't
work on the web, but you can compile a custom `sqlite3.wasm` bundle with the desired extensions
included. The `../custom_wasm_build` example has an example for that setup.

This build setup includes a shared library with the extension in your app. To use it, load the
`DynamicLibrary` and then load it into sqlite3 like this:

```dart
sqlite3.ensureExtensionLoaded(
SqliteExtension.inLibrary(uuid.lib, 'sqlite3_uuid_init'),
);
```
4 changes: 4 additions & 0 deletions sqlite3/example/custom_extension/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
9 changes: 9 additions & 0 deletions sqlite3/example/custom_extension/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx
65 changes: 65 additions & 0 deletions sqlite3/example/custom_extension/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// The Android Gradle Plugin builds the native code with the Android NDK.

group = "com.example.uuid"
version = "1.0"

buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath("com.android.tools.build:gradle:7.3.0")
}
}

rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: "com.android.library"

android {
if (project.android.hasProperty("namespace")) {
namespace = "com.example.uuid"
}

// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdk = 34

// Use the NDK version
// declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specific NDK version.
// (e.g. ndkVersion "23.1.7779620")
ndkVersion = android.ndkVersion

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path = "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

defaultConfig {
minSdk = 21
}
}
1 change: 1 addition & 0 deletions sqlite3/example/custom_extension/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'uuid'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.uuid">
</manifest>
43 changes: 43 additions & 0 deletions sqlite3/example/custom_extension/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
16 changes: 16 additions & 0 deletions sqlite3/example/custom_extension/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# uuid_example

Demonstrates how to use the uuid plugin.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
28 changes: 28 additions & 0 deletions sqlite3/example/custom_extension/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
13 changes: 13 additions & 0 deletions sqlite3/example/custom_extension/example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
Loading
Loading