Коммит 0130610d создал по автору OMP Education's avatar OMP Education
Просмотр файлов

[Source] Add cmake file for upload and build SQLite 3.50.4 version.

владелец 255170df
......@@ -31,3 +31,4 @@ migrate_working_dir/
.flutter-plugins
.flutter-plugins-dependencies
build/
example/pubspec.lock
The author disclaims copyright to this source code. In place of
a legal notice, here is a blessing:
* May you do good and not evil.
* May you find forgiveness for yourself and forgive others.
* May you share freely, never taking more than you give.
libsqlite3.so.0.8.6
\ Нет новой строки в конце файла
libsqlite3.so.0.8.6
\ Нет новой строки в конце файла
Это отличие свёрнуто
Это отличие свёрнуто
libsqlite3.so.0.8.6
\ Нет новой строки в конце файла
# SPDX-FileCopyrightText: Copyright 2025 Open Mobile Platform LLC <community@omp.ru>
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.18)
project(sqlite3_libs_aurora LANGUAGES C)
include(ExternalProject)
set(SQLITE_VERSION_TAG "version-3.50.4")
set(SQLITE_URL "https://github.com/sqlite/sqlite/archive/refs/tags/${SQLITE_VERSION_TAG}.tar.gz")
set(SQLITE_PREFIX_DIR "${CMAKE_BINARY_DIR}/sqlite3_ep")
set(SQLITE_SOURCE_DIR "${CMAKE_BINARY_DIR}/sqlite3_src")
set(SQLITE_BUILD_DIR "${SQLITE_SOURCE_DIR}/bld")
set(SQLITE_C_FILE "${SQLITE_BUILD_DIR}/sqlite3.c")
set(SQLITE_H_FILE "${SQLITE_BUILD_DIR}/sqlite3.h")
ExternalProject_Add(sqlite3_ep
URL ${SQLITE_URL}
PREFIX ${SQLITE_PREFIX_DIR}
SOURCE_DIR ${SQLITE_SOURCE_DIR}
CONFIGURE_COMMAND bash -c "mkdir -p ${SQLITE_BUILD_DIR} && cd ${SQLITE_BUILD_DIR} && ../configure --enable-all"
BUILD_COMMAND bash -c "cd ${SQLITE_BUILD_DIR} && make sqlite3.c"
INSTALL_COMMAND ""
BUILD_BYPRODUCTS "${SQLITE_C_FILE}" "${SQLITE_H_FILE}"
)
set(SQLITE_DEFINES
SQLITE_ENABLE_DBSTAT_VTAB
SQLITE_ENABLE_FTS5
SQLITE_ENABLE_RTREE
SQLITE_DQS=0
SQLITE_DEFAULT_MEMSTATUS=0
SQLITE_TEMP_STORE=2
SQLITE_MAX_EXPR_DEPTH=0
SQLITE_STRICT_SUBTYPE=1
SQLITE_OMIT_AUTHORIZATION
SQLITE_OMIT_DECLTYPE
SQLITE_OMIT_DEPRECATED
SQLITE_OMIT_PROGRESS_CALLBACK
SQLITE_OMIT_SHARED_CACHE
SQLITE_OMIT_TCL_VARIABLE
SQLITE_OMIT_TRACE
SQLITE_USE_ALLOCA
SQLITE_UNTESTABLE
SQLITE_HAVE_ISNAN
SQLITE_HAVE_LOCALTIME_R
SQLITE_HAVE_LOCALTIME_S
SQLITE_HAVE_MALLOC_USABLE_SIZE
SQLITE_HAVE_STRCHRNUL
)
add_library(sqlite3_bundle SHARED "${SQLITE_C_FILE}")
add_dependencies(sqlite3_bundle sqlite3_ep)
target_compile_definitions(sqlite3_bundle PRIVATE ${SQLITE_DEFINES})
target_include_directories(sqlite3_bundle PRIVATE "${SQLITE_BUILD_DIR}")
set_target_properties(sqlite3_bundle PROPERTIES
INSTALL_RPATH "\$ORIGIN:/usr/share/${FLUTTER_PROJECT_NAME}/lib"
BUILD_WITH_INSTALL_RPATH TRUE
SKIP_BUILD_RPATH FALSE
OUTPUT_NAME "sqlite3"
PUBLIC_HEADER "${SQLITE_H_FILE}"
)
add_custom_command(TARGET sqlite3_bundle POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:sqlite3_bundle>
${CMAKE_BINARY_DIR}/bundle/lib/
)
# SPDX-FileCopyrightText: Copyright 2024-2025 Open Mobile Platform LLC <community@omp.ru>
# SPDX-FileCopyrightText: Copyright 2020 Simon Binder
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.18)
set(PROJECT_NAME sqlite3_lib)
set(PLUGIN_NAME sqlite3_flutter_libs)
set(3RDPARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/aurora_${PSDK_MAJOR})
project(${PROJECT_NAME} LANGUAGES C)
include(FetchContent)
set(SQL_LIB_NAME sqlite3_lib)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
# cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when
# the default is used, so override it to the recommended behavior.
# We can't really ask users to use a cmake that recent, so there's this if here.
FetchContent_Declare(
${SQL_LIB_NAME}
URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP NEW
)
else()
FetchContent_Declare(
${SQL_LIB_NAME}
URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz
)
endif()
FetchContent_MakeAvailable(${SQL_LIB_NAME})
add_library(${PLUGIN_NAME} SHARED
"${sqlite3_lib_SOURCE_DIR}/sqlite3.c"
project(sqlite3_libs_aurora
DESCRIPTION "SQLite 3 libraries for Aurora"
)
target_compile_definitions(${PLUGIN_NAME} PUBLIC DART_SHARED_LIB)
target_include_directories(${PLUGIN_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/${sqlite3_lib_SOURCE_DIR}"
)
set_target_properties(${PLUGIN_NAME} PROPERTIES
PUBLIC_HEADER "${sqlite3_lib_SOURCE_DIR}/sqlite3.h"
OUTPUT_NAME "sqlite3"
)
# Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt
target_compile_definitions(${PLUGIN_NAME} PRIVATE
SQLITE_ENABLE_DBSTAT_VTAB
SQLITE_ENABLE_FTS5
SQLITE_ENABLE_RTREE
SQLITE_DQS=0
SQLITE_DEFAULT_MEMSTATUS=0
SQLITE_TEMP_STORE=2
SQLITE_MAX_EXPR_DEPTH=0
SQLITE_STRICT_SUBTYPE=1
SQLITE_OMIT_AUTHORIZATION
SQLITE_OMIT_DECLTYPE
SQLITE_OMIT_DEPRECATED
SQLITE_OMIT_PROGRESS_CALLBACK
SQLITE_OMIT_SHARED_CACHE
SQLITE_OMIT_TCL_VARIABLE
SQLITE_OMIT_TRACE
SQLITE_USE_ALLOCA
SQLITE_UNTESTABLE
SQLITE_HAVE_ISNAN
SQLITE_HAVE_LOCALTIME_R
SQLITE_HAVE_LOCALTIME_S
SQLITE_HAVE_MALLOC_USABLE_SIZE
SQLITE_HAVE_STRCHRNUL
)
#################### sqlite3
set(SQLITE_LIB_NAME "sqlite3")
set(SQLITE_LIB_LINK "libsqlite3.so")
set(SQLITE_LIB_LIST ${SQLITE_LIB_LINK} "libsqlite3.so.0.8.6")
target_include_directories(${PLUGIN_NAME} PUBLIC ${3RDPARTY_PATH}/${SQLITE_LIB_NAME}/include)
foreach (file ${SQLITE_LIB_LIST})
add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${3RDPARTY_PATH}/${SQLITE_LIB_NAME}/${CMAKE_SYSTEM_PROCESSOR}/${file}
${ROOT_PROJECT_BINARY_DIR}/bundle/lib/${file})
endforeach()
add_library(${SQLITE_LIB_NAME} SHARED IMPORTED)
set_property(TARGET ${SQLITE_LIB_NAME} PROPERTY IMPORTED_LOCATION ${3RDPARTY_PATH}/${SQLITE_LIB_NAME}/${CMAKE_SYSTEM_PROCESSOR}/${SQLITE_LIB_LINK})
target_link_libraries(${PLUGIN_NAME} PUBLIC ${SQLITE_LIB_NAME})
####################
add_subdirectory(3rdparty/sqlite3)
......@@ -2,8 +2,8 @@
%global __requires_exclude ^lib(icudata|icui18n|icuuc|dconf|flutter-embedder|maliit-glib|.+_platform_plugin)\\.so.*$
Name: ru.auroraos.sqlite3_flutter_libs_aurora_example
Summary: Demonstrates how to use the sqflite_aurora plugin.
Version: 1.0.1
Summary: Demonstrates how to use the sqflite_common_ffi plugin with SQLite library.
Version: 0.6.1
Release: 1
License: BSD 3-Clause
Source0: %{name}-%{version}.tar.zst
......
......@@ -2,7 +2,9 @@
// SPDX-License-Identifier: BSD-3-Clause
import 'dart:async';
import 'dart:developer';
import 'package:sqlite3/sqlite3.dart' hide Database;
import 'package:flutter/material.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
......@@ -72,7 +74,8 @@ class AppDatabase {
try {
await _db?.transaction((txn) async {
debugPrint([id, value].toString());
final result = await txn.rawUpdate('UPDATE $_table SET val_str = ? WHERE rowid = ?', [value, id]);
final result = await txn.rawUpdate(
'UPDATE $_table SET val_str = ? WHERE rowid = ?', [value, id]);
if (result == 0) {
throw Exception('Nothing to update');
}
......@@ -150,7 +153,8 @@ class _MyAppState extends State<MyApp> {
padding: const EdgeInsets.all(16),
child: Column(
children: [
const Text('Flutter plugin to include native sqlite3 libraries.'),
const Text(
'Flutter plugin to include native sqlite3 libraries.'),
const Divider(height: 32.0),
Text('Value: $_value'),
const Divider(height: 32.0),
......@@ -219,10 +223,31 @@ class _MyAppState extends State<MyApp> {
},
child: const Text('Clear data'),
),
const SizedBox(height: 16.0),
ElevatedButton(
onPressed: () async {
// The SQLite version used in the ffi plugin
var sqlite3Version = sqlite3.version.toString();
_controller.text = _prettyVersion(sqlite3Version);
log('Using sqlite3 $sqlite3Version');
},
child: const Text('Version'),
),
],
),
))
}),
);
}
String _prettyVersion(String input) {
final regex = RegExp(r'libVersion:\s*([0-9.]+)');
final match = regex.firstMatch(input);
if (match == null) {
return input;
}
return 'sqlite ${match.group(1)}';
}
}
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
characters:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
collection:
dependency: transitive
description:
name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.19.0"
ffi:
dependency: transitive
description:
name: ffi
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
lints:
dependency: transitive
description:
name: lints
sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
url: "https://pub.dev"
source: hosted
version: "5.1.1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.15.0"
path:
dependency: "direct main"
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
path_provider:
dependency: "direct main"
description:
name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2"
url: "https://pub.dev"
source: hosted
version: "2.2.15"
path_provider_aurora:
dependency: "direct main"
description:
path: "packages/path_provider_aurora"
ref: "aurora-path_provider_aurora-0.6.1"
resolved-ref: "1006f995d3d3895182ecbebf3169c490e6b351f3"
url: "https://developer.auroraos.ru/git/flutter/packages.git"
source: git
version: "0.6.1"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
sha256: "761b9740ecbd4d3e66b8916d784e581861fd3c3553eda85e167bc49fdb68f709"
url: "https://pub.dev"
source: hosted
version: "2.5.4+6"
sqflite_common_ffi:
dependency: "direct main"
description:
name: sqflite_common_ffi
sha256: "883dd810b2b49e6e8c3b980df1829ef550a94e3f87deab5d864917d27ca6bf36"
url: "https://pub.dev"
source: hosted
version: "2.3.4+4"
sqlite3:
dependency: transitive
description:
name: sqlite3
sha256: cb7f4e9dc1b52b1fa350f7b3d41c662e75fc3d399555fa4e5efcf267e9a4fbb5
url: "https://pub.dev"
source: hosted
version: "2.5.0"
sqlite3_flutter_libs_aurora:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.6.0"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225"
url: "https://pub.dev"
source: hosted
version: "3.3.0+3"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
url: "https://pub.dev"
source: hosted
version: "1.4.0"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
source: hosted
version: "1.1.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.24.0"
......@@ -2,26 +2,22 @@
# SPDX-License-Identifier: BSD-3-Clause
name: sqlite3_flutter_libs_aurora_example
description: "The Aurora OS example of sqlite3_flutter_libs."
publish_to: 'none'
publish_to: "none"
version: 1.0.1
environment:
sdk: '>=3.2.2 <4.0.0'
sdk: ">=3.2.2 <4.0.0"
dependencies:
flutter:
sdk: flutter
path: ^1.8.3
sqflite_common_ffi: ^2.0.0
sqlite3: ^2.5.0
sqlite3_flutter_libs_aurora:
path: ../
path_provider: ^2.1.5
path_provider_aurora:
git:
url: https://developer.auroraos.ru/git/flutter/packages.git
path: packages/path_provider_aurora
ref: aurora-path_provider_aurora-0.6.1
dev_dependencies:
flutter_lints: ^5.0.0
......
# SPDX-FileCopyrightText: Copyright 2025 Open Mobile Platform LLC <community@omp.ru>
# SPDX-License-Identifier: BSD-3-Clause
name: sqlite3_flutter_libs_aurora
description: "Flutter plugin to include native sqlite3 libraries."
version: 0.6.0
description: "Demonstrates how to use the sqflite_common_ffi plugin with SQLite library."
version: 0.6.1
environment:
sdk: ">=2.12.0 <4.0.0"
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать