]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Experimentally add the --compile-commands configure flag to generate compile_commands... compile-commands
authorstephan <stephan@noemail.net>
Tue, 2 Sep 2025 13:14:40 +0000 (13:14 +0000)
committerstephan <stephan@noemail.net>
Tue, 2 Sep 2025 13:14:40 +0000 (13:14 +0000)
FossilOrigin-Name: 37fb15720f03a4ecc2d1662eab5b4241d6a9b990ea23612a8ef6211ccef3dae7

Makefile.in
autosetup/sqlite-config.tcl
main.mk
manifest
manifest.tags
manifest.uuid

index a597a86a351a72cc436b3458ec34d3bc6be57dce..a609c44d2fa5a19165f10dfdc379489569dd984a 100644 (file)
@@ -117,6 +117,7 @@ LDFLAGS.libsqlite3.os-specific = \
 # - https://sqlite.org/forum/forumpost/9dfd5b8fd525a5d7
 # - https://sqlite.org/forum/forumpost/0c7fc097b2
 # - https://sqlite.org/forum/forumpost/5651662b8875ec0a
+CFLAGS.compile_commands =
 
 libsqlite3.DLL.basename = @SQLITE_DLL_BASENAME@
 # DLL.basename: see https://sqlite.org/forum/forumpost/828fdfe904
@@ -336,4 +337,21 @@ distclean: distclean-autosetup
 version-info$(T.exe): $(TOP)/tool/version-info.c Makefile sqlite3.h
        $(T.link) $(ST_OPT) -o $@ $(TOP)/tool/version-info.c
 
+@if HAVE_COMPILE_COMMANDS
+########################################################################
+# <compile_commands>
+CFLAGS.compile_commands = -MJ $@.json
+compile_commands.json: # deps are set up in main.mk
+       @rm -f $@
+       @{ echo -n '['; cat *.o.json | tr '\n' ' ' | sed -e 's/, $$//'; echo ']'; } > $@
+       @echo "Generated $@"
+all: compile_commands.json
+clean: clean-compile_commands
+clean-compile_commands:
+       rm -f compile_commands.json *.o.json
+# </compile_commands>
+########################################################################
+@endif # HAVE_COMPILE_COMMANDS
+
+
 include $(TOP)/main.mk
index 8fb3b80b991ca1f0b4921231ac37c1a4732657f3..dcf3783ecc3f83c3e0d5edb3915ccc6ab7674f13 100644 (file)
@@ -402,6 +402,10 @@ proc sqlite-configure {buildMode configScript} {
           => {Comma- or space-separated list of -fsanitize flags for use with the
               fuzzcheck-asan tool. Only those which the compiler claims to support
               will actually be used. May be provided multiple times.}
+        compile-commands=0
+          => {Enable the check for compile_commands.json support,
+              noting that it may detects a false positive. If CC is clang
+              then it defaults to on instead of off.}
       }
       {*} {
         dump-defines=0
@@ -484,6 +488,19 @@ proc sqlite-configure-phase1 {buildMode} {
     define SQLITE_OS_UNIX 1
     define SQLITE_OS_WIN 0
   }
+  #
+  # --compile-commands must be checked relatively early or else flags
+  # added later, like -Werror, break it.
+  #
+  if {![proj-check-compile-commands -assume-for-clang compile-commands]} {
+    if {[proj-opt-was-provided compile-commands] && [opt-bool compile-commands]} {
+      proj-indented-notice -error {
+        --compile-commands was provided but the compiler does not
+        support it. Use --compile-commands=0 to proceed without that
+        support.
+      }
+    }
+  }
   sqlite-setup-default-cflags
   define HAVE_LFS 0
   if {[opt-bool largefile]} {
diff --git a/main.mk b/main.mk
index 6304a0ad30ea2b0188d40954d0cf659febf0a9cf..234edb3cc4dad0183118a824f4c1dc1e7f952e3d 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -406,7 +406,12 @@ T.cc.sqlite.extras = -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite $(T.cc.TARGET_DEBUG)
 # will normally get initially populated with flags by the
 # configure-generated makefile.
 #
-T.cc.sqlite ?= $(T.compile) $(T.cc.sqlite.extras)
+# This is split into $(T.cc.sqlite) and $(T.cc.sqlite.common) so
+# that we can add compile-commands flags to $(T.cc.sqlite) without
+# having $(T.link) inherit those.
+#
+T.cc.sqlite.common ?= $(T.compile) $(T.cc.sqlite.extras)
+T.cc.sqlite = $(T.cc.sqlite.common) $(CFLAGS.compile_commands)
 
 #
 # $(CFLAGS.intree_includes) = -I... flags relevant specifically to
@@ -417,7 +422,7 @@ CFLAGS.intree_includes = \
     -I. -I$(TOP)/src -I$(TOP)/ext/rtree -I$(TOP)/ext/icu \
     -I$(TOP)/ext/fts3 -I$(TOP)/ext/session \
     -I$(TOP)/ext/misc
-T.cc.sqlite += $(CFLAGS.intree_includes)
+T.cc.sqlite.common += $(CFLAGS.intree_includes)
 
 #
 # $(T.cc.extension) = compiler invocation for loadable extensions.
@@ -431,7 +436,7 @@ T.cc.extension = $(T.compile) -I. -I$(TOP)/src $(T.cc.sqlite.extras) -DSQLITE_CO
 # $(T.link.gcov) = optional config-specific flags for $(T.link),
 # intended for use with gcov-related flags.
 #
-T.link = $(T.cc.sqlite) $(T.link.gcov)
+T.link = $(T.cc.sqlite.common) $(T.link.gcov)
 #
 # $(T.link.shared) = $(T.link) invocation specifically for shared libraries
 #
@@ -572,6 +577,8 @@ LIBOBJS1 = sqlite3.o
 LIBOBJ = $(LIBOBJS$(USE_AMALGAMATION))
 $(LIBOBJ): $(MAKE_SANITY_CHECK)
 
+compile_commands.json: $(LIBOBJ)
+
 #
 # All of the source code files.
 #
index 4bc03108fdea23a1dce6def6be3623e907b7d77d..e0566e7b96d39d4025d6a619cf303387ce47a58e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,10 +1,10 @@
-C Latest\sside-stream\sautosetup/proj.tcl\sfor\simproved\scompile-commands\sfeature\sdetection.
-D 2025-09-01T13:01:20.088
+C Experimentally\sadd\sthe\s--compile-commands\sconfigure\sflag\sto\sgenerate\scompile_commands.json\sfor\scompilers\swhich\ssupport\sit\s(clang),\sto\senable\sLanguage\sServer\sProtocol\s(LSP)\sinspection\sof\sthe\ssources.\sThis\sis\sprobably\snot\sterribly\suseful\swithout\sthe\s--disable-amalgamation\sflag,\sas\sthe\samalgamation\sis\sso\slarge\sas\sto\smake\sIDE/LSP\sprocessing\svery\sslow.
+D 2025-09-02T13:14:40.866
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
-F Makefile.in 3ce07126d7e87c7464301482e161fdae6a51d0a2aa06b200b8f0000ef4d6163b
+F Makefile.in 4926b6ba538803f95486f87baced15b5c2a8e1516e85ff80b96e5eb5550254d3
 F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
 F Makefile.msc b87ac9041d87f61fabd6074e6d8b71dd7f78c884a2307bbb9301f9d436ce9242
 F README.md e28077cfbef795e99c9c75ed95aa7257a1166709b562076441a8506ac421b7c1
@@ -47,7 +47,7 @@ F autosetup/find_tclconfig.tcl e64886ffe3b982d4df42cd28ed91fe0b5940c2c5785e126c1
 F autosetup/jimsh0.c 563b966c137a4ce3c9333e5196723b7ac0919140a9d7989eb440463cd855c367
 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba
 F autosetup/proj.tcl 0582bccdd45ae01f4f6874bdc84109648869b1e09c9746402de176f63cd8044e
-F autosetup/sqlite-config.tcl f2d2cf0917a17068ab2897b2009e31a05a4481a0786cd6ea15f643fef325bbe3
+F autosetup/sqlite-config.tcl 2a236ed73f73518fbb2c8f710d8975835fb522a72e7361e7aca391e6fe377e59
 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9
 F autosetup/teaish/README.txt b40071e6f8506500a2f7f71d5fc69e0bf87b9d7678dd9da1e5b4d0acbf40b1ca
 F autosetup/teaish/core.tcl aee092fc71986d1272b835ea7492bb55ffc213a289502e4f14da80cf67b7e3c3
@@ -665,7 +665,7 @@ F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36
 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
 F ext/wasm/wasmfs.make 411dd94b40406572caddf88392a1ccc4deed0f88d260516e59ca6e0c887ee861
 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
-F main.mk d865589aa95918787659459f7dddd0680f99034e7b111fc161035d736c670a47
+F main.mk e050b915d04fb11c3759a09c01f1dceb5d9fe606a083b4f14222cfabbc93414b
 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
@@ -2171,8 +2171,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 321938063e2d6c579b992bbbed5210c8a051a8b2fe858bb88f95dbd8fb0f35dc
-R e267cd26b1b9022ad2ef2c0d79c6fc0b
+P 55744ca8b8f2f95ba8bd3e01ef89e21e26c8547912c9d5637afe772d17f34486
+R 81957e660080ad2fb82d7e329b14d67f
+T *branch * compile-commands
+T *sym-compile-commands *
+T -sym-trunk * Cancelled\sby\sbranch.
 U stephan
-Z d017608f1f8f249c42675a4c86d9b660
+Z 0965114e40d8bbb5ee6f0a32256d58b2
 # Remove this line to create a well-formed Fossil manifest.
index bec971799ff1b8ee641c166c7aeb22d12c785393..7f58db83982c988ec979a2e665284484d3f41388 100644 (file)
@@ -1,2 +1,2 @@
-branch trunk
-tag trunk
+branch compile-commands
+tag compile-commands
index 41be768f0c4ce9ce2d505322f04cb4b1fa36e48b..fddd55b10b199a7cced437e1f66551cf9b1445f4 100644 (file)
@@ -1 +1 @@
-55744ca8b8f2f95ba8bd3e01ef89e21e26c8547912c9d5637afe772d17f34486
+37fb15720f03a4ecc2d1662eab5b4241d6a9b990ea23612a8ef6211ccef3dae7