Fossil SCM
Initial *incomplete* attempt at integrating compile_commands.json support, for code editors which support it. This is a copy/paste port from the libfossil tree, but lacks one final piece which is difficult to emulate in POSIX make (as opposed to GNU make). Build file changes only, no code changes.
Commit
492787465dd7ebd6f3da7097e17ba5a8515daa18dcc195e6166aa1dfea9e2c8a
Parent
7ab1e1185031104…
4 files changed
+4
+32
+26
-2
+25
-1
+4
| --- Makefile.in | ||
| +++ Makefile.in | ||
| @@ -83,10 +83,14 @@ | ||
| 83 | 83 | # https://emscripten.org/docs/getting_started/downloads.html |
| 84 | 84 | EMSDK_HOME = @EMSDK_HOME@ |
| 85 | 85 | EMSDK_ENV = @EMSDK_ENV@ |
| 86 | 86 | EMCC_OPT = @EMCC_OPT@ |
| 87 | 87 | EMCC_WRAPPER = $(SRCDIR_tools)/emcc.sh |
| 88 | + | |
| 89 | +# MAKE_COMPILATION_DB (yes/no) determines whether or not the | |
| 90 | +# compile_commands.json file will be generated. | |
| 91 | +MAKE_COMPILATION_DB = @MAKE_COMPILATION_DB@ | |
| 88 | 92 | |
| 89 | 93 | .PHONY: all tags |
| 90 | 94 | |
| 91 | 95 | include $(SRCDIR)/main.mk |
| 92 | 96 | |
| 93 | 97 |
| --- Makefile.in | |
| +++ Makefile.in | |
| @@ -83,10 +83,14 @@ | |
| 83 | # https://emscripten.org/docs/getting_started/downloads.html |
| 84 | EMSDK_HOME = @EMSDK_HOME@ |
| 85 | EMSDK_ENV = @EMSDK_ENV@ |
| 86 | EMCC_OPT = @EMCC_OPT@ |
| 87 | EMCC_WRAPPER = $(SRCDIR_tools)/emcc.sh |
| 88 | |
| 89 | .PHONY: all tags |
| 90 | |
| 91 | include $(SRCDIR)/main.mk |
| 92 | |
| 93 |
| --- Makefile.in | |
| +++ Makefile.in | |
| @@ -83,10 +83,14 @@ | |
| 83 | # https://emscripten.org/docs/getting_started/downloads.html |
| 84 | EMSDK_HOME = @EMSDK_HOME@ |
| 85 | EMSDK_ENV = @EMSDK_ENV@ |
| 86 | EMCC_OPT = @EMCC_OPT@ |
| 87 | EMCC_WRAPPER = $(SRCDIR_tools)/emcc.sh |
| 88 | |
| 89 | # MAKE_COMPILATION_DB (yes/no) determines whether or not the |
| 90 | # compile_commands.json file will be generated. |
| 91 | MAKE_COMPILATION_DB = @MAKE_COMPILATION_DB@ |
| 92 | |
| 93 | .PHONY: all tags |
| 94 | |
| 95 | include $(SRCDIR)/main.mk |
| 96 | |
| 97 |
M
auto.def
+32
| --- auto.def | ||
| +++ auto.def | ||
| @@ -29,10 +29,12 @@ | ||
| 29 | 29 | fusefs=1 => {Disable the Fuse Filesystem} |
| 30 | 30 | fossil-debug=0 => {Build with fossil debugging enabled} |
| 31 | 31 | no-opt=0 => {Build without optimization} |
| 32 | 32 | json=0 => {Build with fossil JSON API enabled} |
| 33 | 33 | with-emsdk:path => {Directory containing the Emscripten SDK} |
| 34 | + no-compile-commands=0 => | |
| 35 | + "Disable compile_commands.json support even if detected (possibly incorrectly)." | |
| 34 | 36 | } |
| 35 | 37 | |
| 36 | 38 | # Update the minimum required SQLite version number here, and also |
| 37 | 39 | # in src/main.c near the sqlite3_libversion_number() call. Take care |
| 38 | 40 | # that both places agree! |
| @@ -729,10 +731,40 @@ | ||
| 729 | 731 | define FOSSIL_HAVE_FUSEFS 1 |
| 730 | 732 | define-append LIBS -lfuse |
| 731 | 733 | msg-result "FuseFS support enabled" |
| 732 | 734 | } |
| 733 | 735 | } |
| 736 | + | |
| 737 | +######################################################################## | |
| 738 | +# Checks the compiler for compile_commands.json support. If passed an | |
| 739 | +# argument it is assumed to be the name of an autosetup boolean config | |
| 740 | +# option to explicitly DISABLE the compile_commands.json support. | |
| 741 | +# | |
| 742 | +# Returns 1 if supported, else 0. Defines MAKE_COMPILATION_DB to "yes" | |
| 743 | +# if supported, "no" if not. | |
| 744 | +proc check-compile-commands {{configOpt no-compile-commands}} { | |
| 745 | + msg-checking "compile_commands.json support... " | |
| 746 | + if {"" ne $configOpt && [opt-bool $configOpt]} { | |
| 747 | + msg-result "explicitly disabled" | |
| 748 | + define MAKE_COMPILATION_DB no | |
| 749 | + return 0 | |
| 750 | + } else { | |
| 751 | + if {[cctest -lang c -cflags {/dev/null -MJ} -source {}]} { | |
| 752 | + # This test reportedly incorrectly succeeds on one of | |
| 753 | + # Martin G.'s older systems. | |
| 754 | + msg-result "compiler supports compile_commands.json" | |
| 755 | + define MAKE_COMPILATION_DB yes | |
| 756 | + return 1 | |
| 757 | + } else { | |
| 758 | + msg-result "compiler does not support compile_commands.json" | |
| 759 | + define MAKE_COMPILATION_DB no | |
| 760 | + return 0 | |
| 761 | + } | |
| 762 | + } | |
| 763 | +} | |
| 764 | + | |
| 765 | +check-compile-commands | |
| 734 | 766 | |
| 735 | 767 | # Add -fsanitize compile and link options late: we don't want the C |
| 736 | 768 | # checks above to run with those sanitizers enabled. It can not only |
| 737 | 769 | # be pointless, it can actually break correct tests. |
| 738 | 770 | set fsan [opt-val with-sanitizer] |
| 739 | 771 |
| --- auto.def | |
| +++ auto.def | |
| @@ -29,10 +29,12 @@ | |
| 29 | fusefs=1 => {Disable the Fuse Filesystem} |
| 30 | fossil-debug=0 => {Build with fossil debugging enabled} |
| 31 | no-opt=0 => {Build without optimization} |
| 32 | json=0 => {Build with fossil JSON API enabled} |
| 33 | with-emsdk:path => {Directory containing the Emscripten SDK} |
| 34 | } |
| 35 | |
| 36 | # Update the minimum required SQLite version number here, and also |
| 37 | # in src/main.c near the sqlite3_libversion_number() call. Take care |
| 38 | # that both places agree! |
| @@ -729,10 +731,40 @@ | |
| 729 | define FOSSIL_HAVE_FUSEFS 1 |
| 730 | define-append LIBS -lfuse |
| 731 | msg-result "FuseFS support enabled" |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | # Add -fsanitize compile and link options late: we don't want the C |
| 736 | # checks above to run with those sanitizers enabled. It can not only |
| 737 | # be pointless, it can actually break correct tests. |
| 738 | set fsan [opt-val with-sanitizer] |
| 739 |
| --- auto.def | |
| +++ auto.def | |
| @@ -29,10 +29,12 @@ | |
| 29 | fusefs=1 => {Disable the Fuse Filesystem} |
| 30 | fossil-debug=0 => {Build with fossil debugging enabled} |
| 31 | no-opt=0 => {Build without optimization} |
| 32 | json=0 => {Build with fossil JSON API enabled} |
| 33 | with-emsdk:path => {Directory containing the Emscripten SDK} |
| 34 | no-compile-commands=0 => |
| 35 | "Disable compile_commands.json support even if detected (possibly incorrectly)." |
| 36 | } |
| 37 | |
| 38 | # Update the minimum required SQLite version number here, and also |
| 39 | # in src/main.c near the sqlite3_libversion_number() call. Take care |
| 40 | # that both places agree! |
| @@ -729,10 +731,40 @@ | |
| 731 | define FOSSIL_HAVE_FUSEFS 1 |
| 732 | define-append LIBS -lfuse |
| 733 | msg-result "FuseFS support enabled" |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | ######################################################################## |
| 738 | # Checks the compiler for compile_commands.json support. If passed an |
| 739 | # argument it is assumed to be the name of an autosetup boolean config |
| 740 | # option to explicitly DISABLE the compile_commands.json support. |
| 741 | # |
| 742 | # Returns 1 if supported, else 0. Defines MAKE_COMPILATION_DB to "yes" |
| 743 | # if supported, "no" if not. |
| 744 | proc check-compile-commands {{configOpt no-compile-commands}} { |
| 745 | msg-checking "compile_commands.json support... " |
| 746 | if {"" ne $configOpt && [opt-bool $configOpt]} { |
| 747 | msg-result "explicitly disabled" |
| 748 | define MAKE_COMPILATION_DB no |
| 749 | return 0 |
| 750 | } else { |
| 751 | if {[cctest -lang c -cflags {/dev/null -MJ} -source {}]} { |
| 752 | # This test reportedly incorrectly succeeds on one of |
| 753 | # Martin G.'s older systems. |
| 754 | msg-result "compiler supports compile_commands.json" |
| 755 | define MAKE_COMPILATION_DB yes |
| 756 | return 1 |
| 757 | } else { |
| 758 | msg-result "compiler does not support compile_commands.json" |
| 759 | define MAKE_COMPILATION_DB no |
| 760 | return 0 |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | check-compile-commands |
| 766 | |
| 767 | # Add -fsanitize compile and link options late: we don't want the C |
| 768 | # checks above to run with those sanitizers enabled. It can not only |
| 769 | # be pointless, it can actually break correct tests. |
| 770 | set fsan [opt-val with-sanitizer] |
| 771 |
+26
-2
| --- src/main.mk | ||
| +++ src/main.mk | ||
| @@ -2115,21 +2115,45 @@ | ||
| 2115 | 2115 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR_extsrc)/cson_amalgamation.c |
| 2116 | 2116 | $(XTCC) -c $(SRCDIR_extsrc)/cson_amalgamation.c -o $@ |
| 2117 | 2117 | |
| 2118 | 2118 | $(SRCDIR_extsrc)/pikchr.js: $(SRCDIR_extsrc)/pikchr.c |
| 2119 | 2119 | $(EMCC_WRAPPER) -o $@ $(EMCC_OPT) --no-entry \ |
| 2120 | - -sEXPORTED_RUNTIME_METHODS=cwrap,setValue,getValue,stackSave,stackRestore,stackAlloc \ | |
| 2120 | + -sEXPORTED_RUNTIME_METHODS=cwrap,setValue,getValue,stackSave,stackRestore \ | |
| 2121 | 2121 | -sEXPORTED_FUNCTIONS=_pikchr $(SRCDIR_extsrc)/pikchr.c \ |
| 2122 | 2122 | -sENVIRONMENT=web \ |
| 2123 | 2123 | -sMODULARIZE \ |
| 2124 | 2124 | -sEXPORT_NAME=initPikchrModule \ |
| 2125 | 2125 | --minify 0 |
| 2126 | 2126 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 2127 | 2127 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2128 | 2128 | |
| 2129 | +compile-commands-no: | |
| 2130 | +compile-commands-yes: compile_commands.json | |
| 2131 | +all: compile-commands-$(MAKE_COMPILATION_DB) | |
| 2132 | +compile-commands-args-no = | |
| 2133 | +compile-commands-args-yes = -MJ $(compile-commands-file) | |
| 2134 | +compile-commands-args = compile-commands-args-$(MAKE_COMPILATION_DB) | |
| 2135 | +compile-commands-dir = compile_commands | |
| 2136 | +compile-commands-mkdir = $(SRCDIR)/$(compile-commands-dir) | |
| 2137 | +CFLAGS += $(compile-commands-args) | |
| 2138 | +$(compile-commands-mkdir): $(compile-commands-dir) | |
| 2139 | + mkdir -p $@ | |
| 2140 | +compile_commands.json: $(compile-commands-mkdir) | |
| 2141 | + @-rm -f $@ | |
| 2142 | + sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ | |
| 2143 | + @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi | |
| 2144 | + | |
| 2145 | +# We don't (yet?) have a way to replicate this part of the | |
| 2146 | +# compile_commands.json build in posix make unless we generate | |
| 2147 | +# separate build rules for the compile-commands case: | |
| 2148 | +# | |
| 2149 | +# compdb_file = $(TOP_SRCDIR_REL)/$(compdb_dir)/$(subst /,-,[email protected]) | |
| 2150 | +# compdb_args = -MJ $(compdb_file) | |
| 2151 | +# CFLAGS += $(compdb_args) | |
| 2152 | + | |
| 2129 | 2153 | # |
| 2130 | 2154 | # The list of all the targets that do not correspond to real files. This stops |
| 2131 | 2155 | # 'make' from getting confused when someone makes an error in a rule. |
| 2132 | 2156 | # |
| 2133 | 2157 | |
| 2134 | -.PHONY: all install test clean | |
| 2158 | +.PHONY: all install test clean compile-commands-no compile-commands-yes | |
| 2135 | 2159 | |
| 2136 | 2160 |
| --- src/main.mk | |
| +++ src/main.mk | |
| @@ -2115,21 +2115,45 @@ | |
| 2115 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR_extsrc)/cson_amalgamation.c |
| 2116 | $(XTCC) -c $(SRCDIR_extsrc)/cson_amalgamation.c -o $@ |
| 2117 | |
| 2118 | $(SRCDIR_extsrc)/pikchr.js: $(SRCDIR_extsrc)/pikchr.c |
| 2119 | $(EMCC_WRAPPER) -o $@ $(EMCC_OPT) --no-entry \ |
| 2120 | -sEXPORTED_RUNTIME_METHODS=cwrap,setValue,getValue,stackSave,stackRestore,stackAlloc \ |
| 2121 | -sEXPORTED_FUNCTIONS=_pikchr $(SRCDIR_extsrc)/pikchr.c \ |
| 2122 | -sENVIRONMENT=web \ |
| 2123 | -sMODULARIZE \ |
| 2124 | -sEXPORT_NAME=initPikchrModule \ |
| 2125 | --minify 0 |
| 2126 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 2127 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2128 | |
| 2129 | # |
| 2130 | # The list of all the targets that do not correspond to real files. This stops |
| 2131 | # 'make' from getting confused when someone makes an error in a rule. |
| 2132 | # |
| 2133 | |
| 2134 | .PHONY: all install test clean |
| 2135 | |
| 2136 |
| --- src/main.mk | |
| +++ src/main.mk | |
| @@ -2115,21 +2115,45 @@ | |
| 2115 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR_extsrc)/cson_amalgamation.c |
| 2116 | $(XTCC) -c $(SRCDIR_extsrc)/cson_amalgamation.c -o $@ |
| 2117 | |
| 2118 | $(SRCDIR_extsrc)/pikchr.js: $(SRCDIR_extsrc)/pikchr.c |
| 2119 | $(EMCC_WRAPPER) -o $@ $(EMCC_OPT) --no-entry \ |
| 2120 | -sEXPORTED_RUNTIME_METHODS=cwrap,setValue,getValue,stackSave,stackRestore \ |
| 2121 | -sEXPORTED_FUNCTIONS=_pikchr $(SRCDIR_extsrc)/pikchr.c \ |
| 2122 | -sENVIRONMENT=web \ |
| 2123 | -sMODULARIZE \ |
| 2124 | -sEXPORT_NAME=initPikchrModule \ |
| 2125 | --minify 0 |
| 2126 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 2127 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2128 | |
| 2129 | compile-commands-no: |
| 2130 | compile-commands-yes: compile_commands.json |
| 2131 | all: compile-commands-$(MAKE_COMPILATION_DB) |
| 2132 | compile-commands-args-no = |
| 2133 | compile-commands-args-yes = -MJ $(compile-commands-file) |
| 2134 | compile-commands-args = compile-commands-args-$(MAKE_COMPILATION_DB) |
| 2135 | compile-commands-dir = compile_commands |
| 2136 | compile-commands-mkdir = $(SRCDIR)/$(compile-commands-dir) |
| 2137 | CFLAGS += $(compile-commands-args) |
| 2138 | $(compile-commands-mkdir): $(compile-commands-dir) |
| 2139 | mkdir -p $@ |
| 2140 | compile_commands.json: $(compile-commands-mkdir) |
| 2141 | @-rm -f $@ |
| 2142 | sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ |
| 2143 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 2144 | |
| 2145 | # We don't (yet?) have a way to replicate this part of the |
| 2146 | # compile_commands.json build in posix make unless we generate |
| 2147 | # separate build rules for the compile-commands case: |
| 2148 | # |
| 2149 | # compdb_file = $(TOP_SRCDIR_REL)/$(compdb_dir)/$(subst /,-,[email protected]) |
| 2150 | # compdb_args = -MJ $(compdb_file) |
| 2151 | # CFLAGS += $(compdb_args) |
| 2152 | |
| 2153 | # |
| 2154 | # The list of all the targets that do not correspond to real files. This stops |
| 2155 | # 'make' from getting confused when someone makes an error in a rule. |
| 2156 | # |
| 2157 | |
| 2158 | .PHONY: all install test clean compile-commands-no compile-commands-yes |
| 2159 | |
| 2160 |
+25
-1
| --- tools/makemake.tcl | ||
| +++ tools/makemake.tcl | ||
| @@ -574,16 +574,40 @@ | ||
| 574 | 574 | -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>> |
| 575 | 575 | --minify 0 |
| 576 | 576 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 577 | 577 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 578 | 578 | |
| 579 | +compile-commands-no: | |
| 580 | +compile-commands-yes: compile_commands.json | |
| 581 | +all: compile-commands-$(MAKE_COMPILATION_DB) | |
| 582 | +compile-commands-args-no = | |
| 583 | +compile-commands-args-yes = -MJ $(compile-commands-file) | |
| 584 | +compile-commands-args = compile-commands-args-$(MAKE_COMPILATION_DB) | |
| 585 | +compile-commands-dir = compile_commands | |
| 586 | +compile-commands-mkdir = $(SRCDIR)/$(compile-commands-dir) | |
| 587 | +CFLAGS += $(compile-commands-args) | |
| 588 | +$(compile-commands-mkdir): $(compile-commands-dir) | |
| 589 | + mkdir -p $@ | |
| 590 | +compile_commands.json: $(compile-commands-mkdir) | |
| 591 | + @-rm -f $@ | |
| 592 | + sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ | |
| 593 | + @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi | |
| 594 | + | |
| 595 | +# We don't (yet?) have a way to replicate this part of the | |
| 596 | +# compile_commands.json build in posix make unless we generate | |
| 597 | +# separate build rules for the compile-commands case: | |
| 598 | +# | |
| 599 | +# compdb_file = $(TOP_SRCDIR_REL)/$(compdb_dir)/$(subst /,-,[email protected]) | |
| 600 | +# compdb_args = -MJ $(compdb_file) | |
| 601 | +# CFLAGS += $(compdb_args) | |
| 602 | + | |
| 579 | 603 | # |
| 580 | 604 | # The list of all the targets that do not correspond to real files. This stops |
| 581 | 605 | # 'make' from getting confused when someone makes an error in a rule. |
| 582 | 606 | # |
| 583 | 607 | |
| 584 | -.PHONY: all install test clean | |
| 608 | +.PHONY: all install test clean compile-commands-no compile-commands-yes | |
| 585 | 609 | }] |
| 586 | 610 | |
| 587 | 611 | close $output_file |
| 588 | 612 | # |
| 589 | 613 | # End of the main.mk output |
| 590 | 614 |
| --- tools/makemake.tcl | |
| +++ tools/makemake.tcl | |
| @@ -574,16 +574,40 @@ | |
| 574 | -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>> |
| 575 | --minify 0 |
| 576 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 577 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 578 | |
| 579 | # |
| 580 | # The list of all the targets that do not correspond to real files. This stops |
| 581 | # 'make' from getting confused when someone makes an error in a rule. |
| 582 | # |
| 583 | |
| 584 | .PHONY: all install test clean |
| 585 | }] |
| 586 | |
| 587 | close $output_file |
| 588 | # |
| 589 | # End of the main.mk output |
| 590 |
| --- tools/makemake.tcl | |
| +++ tools/makemake.tcl | |
| @@ -574,16 +574,40 @@ | |
| 574 | -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>> |
| 575 | --minify 0 |
| 576 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 577 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 578 | |
| 579 | compile-commands-no: |
| 580 | compile-commands-yes: compile_commands.json |
| 581 | all: compile-commands-$(MAKE_COMPILATION_DB) |
| 582 | compile-commands-args-no = |
| 583 | compile-commands-args-yes = -MJ $(compile-commands-file) |
| 584 | compile-commands-args = compile-commands-args-$(MAKE_COMPILATION_DB) |
| 585 | compile-commands-dir = compile_commands |
| 586 | compile-commands-mkdir = $(SRCDIR)/$(compile-commands-dir) |
| 587 | CFLAGS += $(compile-commands-args) |
| 588 | $(compile-commands-mkdir): $(compile-commands-dir) |
| 589 | mkdir -p $@ |
| 590 | compile_commands.json: $(compile-commands-mkdir) |
| 591 | @-rm -f $@ |
| 592 | sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ |
| 593 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 594 | |
| 595 | # We don't (yet?) have a way to replicate this part of the |
| 596 | # compile_commands.json build in posix make unless we generate |
| 597 | # separate build rules for the compile-commands case: |
| 598 | # |
| 599 | # compdb_file = $(TOP_SRCDIR_REL)/$(compdb_dir)/$(subst /,-,[email protected]) |
| 600 | # compdb_args = -MJ $(compdb_file) |
| 601 | # CFLAGS += $(compdb_args) |
| 602 | |
| 603 | # |
| 604 | # The list of all the targets that do not correspond to real files. This stops |
| 605 | # 'make' from getting confused when someone makes an error in a rule. |
| 606 | # |
| 607 | |
| 608 | .PHONY: all install test clean compile-commands-no compile-commands-yes |
| 609 | }] |
| 610 | |
| 611 | close $output_file |
| 612 | # |
| 613 | # End of the main.mk output |
| 614 |