From ede5205b78d727773d1a2c56a1406406f4fd4550 Mon Sep 17 00:00:00 2001 From: qianyong325 Date: Thu, 8 May 2025 16:12:09 +0800 Subject: [PATCH] =?UTF-8?q?sqlite=E6=B5=8B=E8=AF=95=20Signed-off-by:=20qia?= =?UTF-8?q?nyong325=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 19 ++++++++++++++----- bundle.json | 4 ++++ include/sqlite3sym.h | 3 ++- src/shell.c | 1 + src/sqlite3.c | 3 +++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 3b03c37..2651cec 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -112,6 +112,8 @@ ohos_shared_library("sqlite") { "SQLITE_DIRECT_OVERFLOW_READ", "SQLITE_HAS_CODEC", "SQLITE_EXPORT_SYMBOLS", + "SQLITE_API=SQLITE_EXPORT", + "SQLITE_ENABLE_LOAD_EXTENSION", "SQLITE_SHARED_BLOCK_OPTIMIZATION", "SQLITE_CODEC_ATTACH_CHANGED", "SQLITE_ENABLE_DROPTABLE_CALLBACK", @@ -158,10 +160,7 @@ ohos_shared_library("sqlite") { ohos_executable("sqlite3") { include_dirs = [ "$sqlite_patched_dir/include" ] - sources = [ - "$sqlite_patched_dir/src/shell.c", - "$sqlite_patched_dir/src/sqlite3.c", - ] + sources = ["$sqlite_patched_dir/src/shell.c"] defines = [ "NDEBUG=1", @@ -192,10 +191,20 @@ ohos_executable("sqlite3") { cflags = [ "-Wno-error=implicit-function-declaration", + "-Wno-macro-redefined", "-Wno-implicit-fallthrough", ] - deps = [ "//third_party/sqlite/patch:apply_patch" ] + deps = [ + ":sqlite", + "//third_party/sqlite/patch:apply_patch", + ] + + public_configs = [ ":sqlite_config" ] + external_deps = [ "c_utils:utils" ] + configs = [ ":sqlite3_private_config" ] + part_name = "sqlite" + subsystem_name = "thirdparty" } if (is_mingw || is_mac) { diff --git a/bundle.json b/bundle.json index b733d95..9d0f67e 100644 --- a/bundle.json +++ b/bundle.json @@ -31,6 +31,7 @@ "build": { "sub_component": [ "//third_party/sqlite:sqlite", + "//third_party/sqlite:sqlite3", "//third_party/sqlite:sqliteicu" ], "inner_kits": [ @@ -46,6 +47,9 @@ }, { "name": "//third_party/sqlite:sqliteicu" + }, + { + "name": "//third_party/sqlite:sqlite3" } ], "test": [] diff --git a/include/sqlite3sym.h b/include/sqlite3sym.h index e63a497..8b5d1d6 100644 --- a/include/sqlite3sym.h +++ b/include/sqlite3sym.h @@ -21,7 +21,7 @@ // We extend the original purpose of the "sqlite3ext.h". #include "sqlite3ext.h" - +// typedef struct sqlite3 sqlite3; struct sqlite3_api_routines_hw { int (*initialize)(); int (*config)(int,...); @@ -32,6 +32,7 @@ struct sqlite3_api_routines_hw { }; extern const struct sqlite3_api_routines_hw *sqlite3_export_hw_symbols; +/* 通过符号表实现模块间调用 */ #define sqlite3_initialize sqlite3_export_hw_symbols->initialize #define sqlite3_config sqlite3_export_hw_symbols->config #define sqlite3_key sqlite3_export_hw_symbols->key diff --git a/src/shell.c b/src/shell.c index a951b27..f052d8c 100644 --- a/src/shell.c +++ b/src/shell.c @@ -118,6 +118,7 @@ typedef unsigned short int u16; #include #include #include "sqlite3.h" +#include "sqlite3sym.h" typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; typedef unsigned char u8; diff --git a/src/sqlite3.c b/src/sqlite3.c index 2fb86bc..6985b68 100644 --- a/src/sqlite3.c +++ b/src/sqlite3.c @@ -17,6 +17,9 @@ ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. */ +#ifndef SQLITE_EXPORT +#define SQLITE_EXPORT +#endif #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 #ifndef SQLITE_PRIVATE -- Gitee