summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Shombert <shombert@google.com>2024-03-24 11:07:39 -0700
committerLee Shombert <shombert@google.com>2024-03-24 18:15:19 -0700
commit224a7bfe134f7313d58551d9878d1acd01b243f0 (patch)
tree9618beaf915ff3de6922952410c83b796b9e3ff6
parent2d872eae699ec975f6af72f400ccfb444bc1d713 (diff)
downloadsqlite-224a7bfe134f7313d58551d9878d1acd01b243f0.tar.gz
Consume build flag in sqlite Android.bp
The two Android.bp files for sqlite now use the build flag RELEASE_PACKAGE_LIBSQLITE3. The value of the build flag must be a seven-digit sqlite release number. For example, release 3.44.2 is coded as 3440200. This is the same number that sqlite.org uses for the release URLs. The default source files (also 3.42.0) have been copied into the directory external/sqlite/dist/sqlite-default. These files are used for every target that is not aware of trunk-stable build flags. Bug: 323176655 Change-Id: Iba1dd75408f42b35eb52b680c11a9947aad04f3f
-rw-r--r--README-upgrade.md22
-rw-r--r--android/Android.bp24
-rw-r--r--dist/Android.bp134
-rw-r--r--dist/sqlite-default/Android.patch153
-rw-r--r--dist/sqlite-default/METADATA21
-rw-r--r--dist/sqlite-default/README.version3
-rw-r--r--dist/sqlite-default/orig/shell.c (renamed from dist/orig/shell.c)0
-rw-r--r--dist/sqlite-default/orig/sqlite3.c (renamed from dist/orig/sqlite3.c)0
-rw-r--r--dist/sqlite-default/orig/sqlite3.h (renamed from dist/orig/sqlite3.h)0
-rw-r--r--dist/sqlite-default/orig/sqlite3ext.h (renamed from dist/orig/sqlite3ext.h)0
-rw-r--r--dist/sqlite-default/shell.c (renamed from dist/shell.c)0
-rw-r--r--dist/sqlite-default/sqlite3.c (renamed from dist/sqlite3.c)0
-rw-r--r--dist/sqlite-default/sqlite3.h (renamed from dist/sqlite3.h)0
-rw-r--r--dist/sqlite-default/sqlite3ext.h (renamed from dist/sqlite3ext.h)0
14 files changed, 324 insertions, 33 deletions
diff --git a/README-upgrade.md b/README-upgrade.md
index 951bb37..c14b1e3 100644
--- a/README-upgrade.md
+++ b/README-upgrade.md
@@ -28,6 +28,28 @@ This script takes the same arguments as `UPDATE-SOURCE.bash`. Then rerun
`UPDATE-SOURCE.bash`. It is important that `UPDATE-SOURCE.bash` run without
errors.
+Once the scripts have completed, there will be a directory containing the new
+source files. The directory is named after the sqlite release and exists in
+parallel with other sqlite release directories. For release 3.42.0, the
+directory name is `external/sqlite/dist/sqlite-autoconf-3420000`.
+
+## Flagging
+
+The release of sqlite can be controlled by trunk-stable build flags. The flag
+is `RELEASE_PACKAGE_LIBSQLITE3`. The value of that flag is the 7-digit sqlite
+release number (e.g., 3420000). Any target that respects trunk-stable flags
+will use the source in `external/sqlite/dist/sqlite-autoconf-FLAG`. Not all
+targets respect the trunk-stable flags, however. Such targets use the directory
+`external/sqlite/dist/sqlite-default`.
+
+A new release of sqlite can be promoted to `trunk` by setting the flag to the
+proper release string.
+
+A release of sqlite is promoted to `next` by setting the flag to the release
+string AND by copying the associated release directory to `sqlite-default`.
+This moves all targets that do not honor build flags to use the newly promoted
+release.
+
## LICENSE
This file contains the license that allows Android to use the third-party
diff --git a/android/Android.bp b/android/Android.bp
index f0a6da6..b485f0c 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -15,8 +15,29 @@ license {
],
}
-cc_defaults {
+soong_config_module_type {
+ name: "release_package_libsqlite3_android_defaults_config",
+ module_type: "cc_defaults",
+ config_namespace: "libsqlite3",
+ value_variables: ["release_package_libsqlite3"],
+ properties: [
+ "include_dirs",
+ ],
+}
+
+// Construct the correct source and includes for sqlite libraries,
+// based on the build flag.
+release_package_libsqlite3_android_defaults_config {
name: "libsqlite3_android_defaults",
+ soong_config_variables: {
+ release_package_libsqlite3: {
+ include_dirs: ["external/sqlite/dist/sqlite-autoconf-%s"],
+ conditions_default: {
+ include_dirs: ["external/sqlite/dist/sqlite-default"],
+ },
+ },
+ },
+
host_supported: true,
cflags: [
"-Wall",
@@ -29,7 +50,6 @@ cc_defaults {
"OldPhoneNumberUtils.cpp",
"sqlite3_android.cpp",
],
- include_dirs: ["external/sqlite/dist"],
shared_libs: [
"liblog",
],
diff --git a/dist/Android.bp b/dist/Android.bp
index 6ca2767..c47dfe5 100644
--- a/dist/Android.bp
+++ b/dist/Android.bp
@@ -101,17 +101,53 @@ cc_defaults {
},
}
+soong_config_module_type {
+ name: "release_package_libsqlite3_library_defaults_config",
+ module_type: "cc_defaults",
+ config_namespace: "libsqlite3",
+ value_variables: ["release_package_libsqlite3"],
+ properties: [
+ "export_include_dirs",
+ "srcs",
+ ],
+}
+
+// Construct the correct source and includes for sqlite libraries,
+// based on the build flag.
+release_package_libsqlite3_library_defaults_config {
+ name: "release_package_libsqlite3_library_defaults",
+ soong_config_variables: {
+ release_package_libsqlite3: {
+ export_include_dirs: ["sqlite-autoconf-%s"],
+ srcs: ["sqlite-autoconf-%s/sqlite3.c"],
+ conditions_default: {
+ export_include_dirs: ["sqlite-default"],
+ srcs: ["sqlite-default/sqlite3.c"],
+ },
+ },
+ },
+}
+
+cc_defaults {
+ name: "libsqlite_defaults",
+ defaults: [
+ "sqlite-defaults",
+ "release_package_libsqlite3_library_defaults",
+ ],
+}
+
cc_library {
name: "libsqlite",
- defaults: ["sqlite-defaults"],
+ defaults: [
+ "sqlite-defaults",
+ "release_package_libsqlite3_library_defaults",
+ ],
vendor_available: true,
native_bridge_supported: true,
vndk: {
enabled: true,
},
- srcs: ["sqlite3.c"],
-
target: {
android: {
shared_libs: [
@@ -145,7 +181,6 @@ cc_library {
exclude_static_libs: ["libsqlite3_android"],
},
},
- export_include_dirs: ["."],
apex_available: [
"//apex_available:platform",
"com.android.virt",
@@ -160,11 +195,12 @@ cc_library {
// desirable, like microdroid.
cc_library_static {
name: "libsqlite_static_noicu",
- defaults: ["sqlite-defaults"],
- srcs: ["sqlite3.c"],
+ defaults: [
+ "sqlite-defaults",
+ "release_package_libsqlite3_library_defaults",
+ ],
whole_static_libs: ["libsqlite3_android_noicu"],
// Not define SQLITE_ENABLE_ICU
- export_include_dirs: ["."],
apex_available: [
"//apex_available:platform",
"com.android.os.statsd",
@@ -174,18 +210,75 @@ cc_library_static {
host_supported: true,
}
+// Build a minimal version of sqlite3 without any android specific
+// features against the NDK. This is used by libcore's JDBC related
+// unit tests.
+cc_library_static {
+ name: "libsqlite_static_minimal",
+ defaults: [
+ "sqlite-minimal-defaults",
+ "release_package_libsqlite3_library_defaults",
+ ],
+ sdk_version: "23",
+}
+
+soong_config_module_type {
+ name: "release_package_libsqlite3_library_percentile_config",
+ module_type: "cc_library_static",
+ config_namespace: "libsqlite3",
+ value_variables: ["release_package_libsqlite3"],
+ properties: [
+ "export_include_dirs",
+ ],
+}
+
+release_package_libsqlite3_library_percentile_config {
+ name: "sqlite_ext_percentile",
+ soong_config_variables: {
+ release_package_libsqlite3: {
+ export_include_dirs: ["sqlite-autoconf-%s"],
+ conditions_default: {
+ export_include_dirs: ["sqlite-default"],
+ },
+ },
+ },
+ srcs: [
+ "ext/misc/percentile.c",
+ ],
+ defaults: ["sqlite-defaults"],
+ host_supported: true,
+}
+
//
//
// Build the device command line tool sqlite3
//
//
-cc_binary {
+soong_config_module_type {
+ name: "release_package_libsqlite3_library_shell_config",
+ module_type: "cc_binary",
+ config_namespace: "libsqlite3",
+ value_variables: ["release_package_libsqlite3"],
+ properties: [
+ "srcs",
+ ],
+}
+
+// Construct the correct source and includes for sqlite libraries,
+// based on the build flag.
+release_package_libsqlite3_library_shell_config {
name: "sqlite3",
+ soong_config_variables: {
+ release_package_libsqlite3: {
+ srcs: ["sqlite-autoconf-%s/shell.c"],
+ conditions_default: {
+ srcs: ["sqlite-default/shell.c"],
+ },
+ },
+ },
defaults: ["sqlite-defaults"],
- srcs: ["shell.c"],
-
target: {
android: {
shared_libs: [
@@ -211,24 +304,3 @@ cc_binary {
},
},
}
-
-// Build a minimal version of sqlite3 without any android specific
-// features against the NDK. This is used by libcore's JDBC related
-// unit tests.
-cc_library_static {
- name: "libsqlite_static_minimal",
- defaults: ["sqlite-minimal-defaults"],
- srcs: ["sqlite3.c"],
- sdk_version: "23",
- export_include_dirs: ["."],
-}
-
-cc_library_static {
- name: "sqlite_ext_percentile",
- srcs: [
- "ext/misc/percentile.c",
- ],
- defaults: ["sqlite-defaults"],
- host_supported: true,
- export_include_dirs: ["."],
-}
diff --git a/dist/sqlite-default/Android.patch b/dist/sqlite-default/Android.patch
new file mode 100644
index 0000000..f38906c
--- /dev/null
+++ b/dist/sqlite-default/Android.patch
@@ -0,0 +1,153 @@
+--- orig/shell.c 2024-03-14 11:00:02.445940614 -0700
++++ shell.c 2024-03-14 11:00:02.477940578 -0700
+@@ -127,6 +127,11 @@
+ #endif
+ #include <ctype.h>
+ #include <stdarg.h>
++// Begin Android Add
++#ifndef NO_ANDROID_FUNCS
++#include <sqlite3_android.h>
++#endif
++// End Android Add
+
+ #if !defined(_WIN32) && !defined(WIN32)
+ # include <signal.h>
+@@ -246,7 +251,9 @@
+ #if SQLITE_OS_WINRT
+ #include <intrin.h>
+ #endif
++#ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
++#endif
+ #include <windows.h>
+
+ /* string conversion routines only needed on Win32 */
+@@ -20793,6 +20800,21 @@
+ editFunc, 0, 0);
+ #endif
+
++// Begin Android Add
++#ifndef NO_ANDROID_FUNCS
++ int err = register_localized_collators(p->db, "en_US", 0);
++ if (err != SQLITE_OK) {
++ fprintf(stderr, "register_localized_collators() failed\n");
++ exit(1);
++ }
++ err = register_android_functions(p->db, 0);
++ if (err != SQLITE_OK) {
++ fprintf(stderr, "register_android_functions() failed\n");
++ exit(1);
++ }
++#endif
++// End Android Add
++
+ if( p->openMode==SHELL_OPEN_ZIPFILE ){
+ char *zSql = sqlite3_mprintf(
+ "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
+--- orig/sqlite3.c 2024-03-14 11:00:02.457940601 -0700
++++ sqlite3.c 2024-03-14 11:00:02.509940542 -0700
+@@ -37314,6 +37314,10 @@
+ # include <sys/mount.h>
+ #endif
+
++#if defined(__BIONIC__)
++# include <android/fdsan.h>
++#endif
++
+ #ifdef HAVE_UTIME
+ # include <utime.h>
+ #endif
+@@ -37922,6 +37926,12 @@
+ #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
+ osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+ #endif
++
++#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
++ uint64_t tag = android_fdsan_create_owner_tag(
++ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
++ android_fdsan_exchange_owner_tag(fd, 0, tag);
++#endif
+ }
+ return fd;
+ }
+@@ -38502,7 +38512,13 @@
+ ** and move on.
+ */
+ static void robust_close(unixFile *pFile, int h, int lineno){
++#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
++ uint64_t tag = android_fdsan_create_owner_tag(
++ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
++ if( android_fdsan_close_with_tag(h, tag) ){
++#else
+ if( osClose(h) ){
++#endif
+ unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
+ pFile ? pFile->zPath : 0, lineno);
+ }
+@@ -41051,7 +41067,7 @@
+ SimulateIOError( rc=1 );
+ if( rc!=0 ){
+ storeLastErrno((unixFile*)id, errno);
+- return SQLITE_IOERR_FSTAT;
++ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
+ }
+ *pSize = buf.st_size;
+
+@@ -41087,7 +41103,7 @@
+ struct stat buf; /* Used to hold return values of fstat() */
+
+ if( osFstat(pFile->h, &buf) ){
+- return SQLITE_IOERR_FSTAT;
++ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
+ }
+
+ nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
+@@ -41829,7 +41845,7 @@
+ ** with the same permissions.
+ */
+ if( osFstat(pDbFd->h, &sStat) ){
+- rc = SQLITE_IOERR_FSTAT;
++ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
+ goto shm_open_err;
+ }
+
+@@ -138266,7 +138282,7 @@
+ }
+ if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
+ sqlite3SetString(pzErrMsg, db, "unsupported file format");
+- rc = SQLITE_ERROR;
++ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
+ goto initone_error_out;
+ }
+
+@@ -185208,7 +185224,9 @@
+ ** module with sqlite.
+ */
+ if( SQLITE_OK==rc
++#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
+ && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer"))
++#endif
+ && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
+ && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
+ && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
+@@ -185219,6 +185237,20 @@
+ rc = sqlite3_create_module_v2(
+ db, "fts3", &fts3Module, (void *)pHash, hashDestroy
+ );
++#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
++ if( rc==SQLITE_OK ){
++ pHash->nRef++;
++ rc = sqlite3_create_module_v2(
++ db, "fts1", &fts3Module, (void *)pHash, hashDestroy
++ );
++ }
++ if( rc==SQLITE_OK ){
++ pHash->nRef++;
++ rc = sqlite3_create_module_v2(
++ db, "fts2", &fts3Module, (void *)pHash, hashDestroy
++ );
++ }
++#endif
+ if( rc==SQLITE_OK ){
+ pHash->nRef++;
+ rc = sqlite3_create_module_v2(
diff --git a/dist/sqlite-default/METADATA b/dist/sqlite-default/METADATA
new file mode 100644
index 0000000..76cc062
--- /dev/null
+++ b/dist/sqlite-default/METADATA
@@ -0,0 +1,21 @@
+name: "SQLite"
+description:
+ "SQLite database"
+
+third_party {
+ url {
+ type: HOMEPAGE
+ value: "https://www.sqlite.org"
+ }
+ url {
+ type: ARCHIVE
+ value: "https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz"
+ }
+ version: "3.42.0"
+ last_upgrade_date { year: 2024 month: 00 day: 03/14/24 }
+ license_type: NOTICE
+
+ security: {
+ tag: "NVD-CPE2.3:cpe:/a:sqlite:sqlite" # see http://go/metadata-cpe
+ }
+}
diff --git a/dist/sqlite-default/README.version b/dist/sqlite-default/README.version
new file mode 100644
index 0000000..c892550
--- /dev/null
+++ b/dist/sqlite-default/README.version
@@ -0,0 +1,3 @@
+URL: https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz
+Version: 3.42.0
+BugComponent: 24950
diff --git a/dist/orig/shell.c b/dist/sqlite-default/orig/shell.c
index 647a214..647a214 100644
--- a/dist/orig/shell.c
+++ b/dist/sqlite-default/orig/shell.c
diff --git a/dist/orig/sqlite3.c b/dist/sqlite-default/orig/sqlite3.c
index dd3b5c5..dd3b5c5 100644
--- a/dist/orig/sqlite3.c
+++ b/dist/sqlite-default/orig/sqlite3.c
diff --git a/dist/orig/sqlite3.h b/dist/sqlite-default/orig/sqlite3.h
index 48effe2..48effe2 100644
--- a/dist/orig/sqlite3.h
+++ b/dist/sqlite-default/orig/sqlite3.h
diff --git a/dist/orig/sqlite3ext.h b/dist/sqlite-default/orig/sqlite3ext.h
index 19e0300..19e0300 100644
--- a/dist/orig/sqlite3ext.h
+++ b/dist/sqlite-default/orig/sqlite3ext.h
diff --git a/dist/shell.c b/dist/sqlite-default/shell.c
index 30b0e9a..30b0e9a 100644
--- a/dist/shell.c
+++ b/dist/sqlite-default/shell.c
diff --git a/dist/sqlite3.c b/dist/sqlite-default/sqlite3.c
index 8778289..8778289 100644
--- a/dist/sqlite3.c
+++ b/dist/sqlite-default/sqlite3.c
diff --git a/dist/sqlite3.h b/dist/sqlite-default/sqlite3.h
index 48effe2..48effe2 100644
--- a/dist/sqlite3.h
+++ b/dist/sqlite-default/sqlite3.h
diff --git a/dist/sqlite3ext.h b/dist/sqlite-default/sqlite3ext.h
index 19e0300..19e0300 100644
--- a/dist/sqlite3ext.h
+++ b/dist/sqlite-default/sqlite3ext.h