From c3280dc93a53cbf0a3a7192770484e55a9578d0c Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 23 Nov 2024 13:28:27 +0100 Subject: [PATCH] build: fix `--shared-sqlite` builds --- deps/sqlite/sqlite.gyp | 61 +++++++++++++++++++++++++++++------------- src/node_metadata.cc | 7 ++++- src/node_sqlite.cc | 7 ++++- src/node_sqlite.h | 8 +++++- src/node_webstorage.cc | 7 ++++- src/node_webstorage.h | 8 +++++- 6 files changed, 75 insertions(+), 23 deletions(-) diff --git a/deps/sqlite/sqlite.gyp b/deps/sqlite/sqlite.gyp index c3ecef214ad004..fce0225915e877 100644 --- a/deps/sqlite/sqlite.gyp +++ b/deps/sqlite/sqlite.gyp @@ -3,26 +3,51 @@ 'sqlite_sources': [ 'sqlite3.c', ], + 'use_system_sqlite%': 0, }, - 'targets': [ - { - 'target_name': 'sqlite', - 'type': 'static_library', - 'cflags': ['-fvisibility=hidden'], - 'xcode_settings': { - 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden - }, - 'defines': [ - 'SQLITE_ENABLE_SESSION', - 'SQLITE_ENABLE_PREUPDATE_HOOK' + 'conditions': [ + ['use_system_sqlite==0', { + 'targets': [ + { + 'target_name': 'sqlite', + 'type': 'static_library', + 'cflags': ['-fvisibility=hidden'], + 'xcode_settings': { + 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden + }, + 'defines': [ + 'SQLITE_ENABLE_SESSION', + 'SQLITE_ENABLE_PREUPDATE_HOOK' + ], + 'include_dirs': ['.'], + 'sources': [ + '<@(sqlite_sources)', + ], + 'direct_dependent_settings': { + 'include_dirs': ['.'], + }, + }, ], - 'include_dirs': ['.'], - 'sources': [ - '<@(sqlite_sources)', + }, { + 'targets': [ + { + 'target_name': 'sqlite', + 'type': 'static_library', + 'direct_dependent_settings': { + 'defines': [ + 'USE_SYSTEM_SQLITE', + ], + }, + 'defines': [ + 'USE_SYSTEM_SQLITE', + ], + 'link_settings': { + 'libraries': [ + '-lsqlite', + ], + }, + }, ], - 'direct_dependent_settings': { - 'include_dirs': ['.'], - }, - }, + }], ], } diff --git a/src/node_metadata.cc b/src/node_metadata.cc index db30578fb3014b..26547196516c5a 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -11,7 +11,6 @@ #include "node.h" #include "simdjson.h" #include "simdutf.h" -#include "sqlite3.h" #include "undici_version.h" #include "util.h" #include "uv.h" @@ -24,6 +23,12 @@ #include #endif // NODE_BUNDLED_ZLIB +#if defined(USE_SYSTEM_SQLITE) +#include +#else +#include "sqlite3.h" +#endif // USE_SYSTEM_SQLITE + #if HAVE_OPENSSL #include #include "ncrypto.h" diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index dd78f4e6dacf59..a2c508d7914e1c 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -6,9 +6,14 @@ #include "node.h" #include "node_errors.h" #include "node_mem-inl.h" -#include "sqlite3.h" #include "util-inl.h" +#if defined(USE_SYSTEM_SQLITE) +#include +#else +#include "sqlite3.h" +#endif // USE_SYSTEM_SQLITE + #include namespace node { diff --git a/src/node_sqlite.h b/src/node_sqlite.h index 256be0c6df9d40..450931cf1e9ca2 100644 --- a/src/node_sqlite.h +++ b/src/node_sqlite.h @@ -5,9 +5,15 @@ #include "base_object.h" #include "node_mem.h" -#include "sqlite3.h" #include "util.h" +#if defined(USE_SYSTEM_SQLITE) +#include +/* AOSP build requires relative paths. */ +#else +#include "sqlite3.h" +#endif // USE_SYSTEM_SQLITE + #include #include diff --git a/src/node_webstorage.cc b/src/node_webstorage.cc index 3d71ab33c5b41c..4785d9023fb758 100644 --- a/src/node_webstorage.cc +++ b/src/node_webstorage.cc @@ -7,9 +7,14 @@ #include "node_errors.h" #include "node_mem-inl.h" #include "path.h" -#include "sqlite3.h" #include "util-inl.h" +#if defined(USE_SYSTEM_SQLITE) +#include +#else +#include "sqlite3.h" +#endif // USE_SYSTEM_SQLITE + namespace node { namespace webstorage { diff --git a/src/node_webstorage.h b/src/node_webstorage.h index c2548d32e993fd..5c9a0003c86c53 100644 --- a/src/node_webstorage.h +++ b/src/node_webstorage.h @@ -5,9 +5,15 @@ #include "base_object.h" #include "node_mem.h" -#include "sqlite3.h" #include "util.h" +#if defined(USE_SYSTEM_SQLITE) +#include +/* AOSP build requires relative paths. */ +#else +#include "sqlite3.h" +#endif // USE_SYSTEM_SQLITE + namespace node { namespace webstorage {