Fossil SCM
Get the -MJ ... flags working for the in-binary objects and generate the top-level compile_commands.json.
Commit
e330509cd4b02a979c5efe4739db307930a65e14b9f745994a7cf0637f1c70b5
Parent
0e6ad145d480dc3…
2 files changed
+32
-18
+32
-18
+32
-18
| --- src/main.mk | ||
| +++ src/main.mk | ||
| @@ -569,20 +569,10 @@ | ||
| 569 | 569 | $(OBJDIR)/winfile.o \ |
| 570 | 570 | $(OBJDIR)/winhttp.o \ |
| 571 | 571 | $(OBJDIR)/xfer.o \ |
| 572 | 572 | $(OBJDIR)/xfersetup.o \ |
| 573 | 573 | $(OBJDIR)/zip.o |
| 574 | -compile-commands-dir = compile_commands | |
| 575 | -compile-commands-mkdir.yes = $(TOPDIR)/$(compile-commands-dir) | |
| 576 | -compile-commands-mkdir.no = | |
| 577 | -all: $(compile-commands-mkdir.$(MAKE_COMPILATION_DB)) | |
| 578 | -$(compile-commands-mkdir.no): | |
| 579 | -$(compile-commands-mkdir.yes): $(compile-commands-dir) | |
| 580 | - mkdir -p $@ | |
| 581 | -#$(OBJ): $(compile-commands-mkdir) | |
| 582 | - | |
| 583 | - | |
| 584 | 574 | all: $(OBJDIR) $(APPNAME) |
| 585 | 575 | |
| 586 | 576 | install: all |
| 587 | 577 | mkdir -p $(INSTALLDIR) |
| 588 | 578 | cp $(APPNAME) $(INSTALLDIR) |
| @@ -2137,21 +2127,44 @@ | ||
| 2137 | 2127 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2138 | 2128 | |
| 2139 | 2129 | # |
| 2140 | 2130 | # compile_commands.json support... |
| 2141 | 2131 | # |
| 2142 | -compile-commands-file = $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) | |
| 2143 | -compile-command-args.yes = -MJ $(compile-commands-file) | |
| 2132 | +# We have to avoid applying compile_commands support to the in-tree | |
| 2133 | +# tools, as those compile with BCC, which may differ from TCC. | |
| 2134 | +# e.g. BCC might be gcc (which does not support -MJ ...) while TCC is | |
| 2135 | +# clang (which does). | |
| 2136 | +# | |
| 2137 | +# What follows is more verbose than strictly necessary because we're | |
| 2138 | +# limited to POSIX make syntax. | |
| 2139 | +all: | |
| 2140 | +compile-commands-dir.yes = $(OBJDIR) | |
| 2141 | +compile-commands-dir.no = | |
| 2142 | +compile-commands-dir = $(compile-commands-dir.$(MAKE_COMPILATION_DB)) | |
| 2143 | +compile-command-args.yes = -MJ $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) | |
| 2144 | 2144 | compile-command-args.no = |
| 2145 | -CFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) | |
| 2146 | -compile_commands.json: | |
| 2145 | +TCCFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) | |
| 2146 | +compile_commands.json = $(TOPDIR)/compile_commands.json | |
| 2147 | +# compile_commands.json is a concatenation of the .o.json files | |
| 2148 | +# generated by the compilation process via TCCFLAGS. We have a | |
| 2149 | +# potential race condition in parallel builds, where a .o.json file is | |
| 2150 | +# not yet written to completion before compile_commands.json is | |
| 2151 | +# processed. How to resolve that in a way compatible with POSIX make | |
| 2152 | +# is unclear. | |
| 2153 | +# | |
| 2154 | +# This obscure sed bit ensures that the resulting JSON array does not | |
| 2155 | +# have a trailing comma. | |
| 2156 | +$(compile_commands.json): $(OBJ) | |
| 2147 | 2157 | @-rm -f $@ |
| 2148 | - sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ | |
| 2158 | + sed -e '1s/^/[''\n''/' -e '$$s/,$$/''\n'']/' $(compile-commands-dir)/*.o.json > $@+ | |
| 2149 | 2159 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 2150 | 2160 | compile-commands.no: |
| 2151 | -compile-commands.yes: compile_commands.json | |
| 2152 | -all: $(compile-commands.$(MAKE_COMPILATION_DB)) | |
| 2161 | +compile-commands.yes: $(compile_commands.json) | |
| 2162 | +all: compile-commands.$(MAKE_COMPILATION_DB) | |
| 2163 | +clean: compile-commands-clean | |
| 2164 | +compile-commands-clean: | |
| 2165 | + rm -fr $(compile_commands.json) | |
| 2153 | 2166 | |
| 2154 | 2167 | # |
| 2155 | 2168 | # End compile_commands.json support |
| 2156 | 2169 | # |
| 2157 | 2170 | |
| @@ -2158,7 +2171,8 @@ | ||
| 2158 | 2171 | # |
| 2159 | 2172 | # The list of all the targets that do not correspond to real files. This stops |
| 2160 | 2173 | # 'make' from getting confused when someone makes an error in a rule. |
| 2161 | 2174 | # |
| 2162 | 2175 | |
| 2163 | -.PHONY: all install test clean compile-commands-no compile-commands-yes | |
| 2176 | +.PHONY: all install test clean | |
| 2177 | +.PHONY: compile-commands-clean compile-commands-dir | |
| 2164 | 2178 | |
| 2165 | 2179 |
| --- src/main.mk | |
| +++ src/main.mk | |
| @@ -569,20 +569,10 @@ | |
| 569 | $(OBJDIR)/winfile.o \ |
| 570 | $(OBJDIR)/winhttp.o \ |
| 571 | $(OBJDIR)/xfer.o \ |
| 572 | $(OBJDIR)/xfersetup.o \ |
| 573 | $(OBJDIR)/zip.o |
| 574 | compile-commands-dir = compile_commands |
| 575 | compile-commands-mkdir.yes = $(TOPDIR)/$(compile-commands-dir) |
| 576 | compile-commands-mkdir.no = |
| 577 | all: $(compile-commands-mkdir.$(MAKE_COMPILATION_DB)) |
| 578 | $(compile-commands-mkdir.no): |
| 579 | $(compile-commands-mkdir.yes): $(compile-commands-dir) |
| 580 | mkdir -p $@ |
| 581 | #$(OBJ): $(compile-commands-mkdir) |
| 582 | |
| 583 | |
| 584 | all: $(OBJDIR) $(APPNAME) |
| 585 | |
| 586 | install: all |
| 587 | mkdir -p $(INSTALLDIR) |
| 588 | cp $(APPNAME) $(INSTALLDIR) |
| @@ -2137,21 +2127,44 @@ | |
| 2137 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2138 | |
| 2139 | # |
| 2140 | # compile_commands.json support... |
| 2141 | # |
| 2142 | compile-commands-file = $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) |
| 2143 | compile-command-args.yes = -MJ $(compile-commands-file) |
| 2144 | compile-command-args.no = |
| 2145 | CFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) |
| 2146 | compile_commands.json: |
| 2147 | @-rm -f $@ |
| 2148 | sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ |
| 2149 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 2150 | compile-commands.no: |
| 2151 | compile-commands.yes: compile_commands.json |
| 2152 | all: $(compile-commands.$(MAKE_COMPILATION_DB)) |
| 2153 | |
| 2154 | # |
| 2155 | # End compile_commands.json support |
| 2156 | # |
| 2157 | |
| @@ -2158,7 +2171,8 @@ | |
| 2158 | # |
| 2159 | # The list of all the targets that do not correspond to real files. This stops |
| 2160 | # 'make' from getting confused when someone makes an error in a rule. |
| 2161 | # |
| 2162 | |
| 2163 | .PHONY: all install test clean compile-commands-no compile-commands-yes |
| 2164 | |
| 2165 |
| --- src/main.mk | |
| +++ src/main.mk | |
| @@ -569,20 +569,10 @@ | |
| 569 | $(OBJDIR)/winfile.o \ |
| 570 | $(OBJDIR)/winhttp.o \ |
| 571 | $(OBJDIR)/xfer.o \ |
| 572 | $(OBJDIR)/xfersetup.o \ |
| 573 | $(OBJDIR)/zip.o |
| 574 | all: $(OBJDIR) $(APPNAME) |
| 575 | |
| 576 | install: all |
| 577 | mkdir -p $(INSTALLDIR) |
| 578 | cp $(APPNAME) $(INSTALLDIR) |
| @@ -2137,21 +2127,44 @@ | |
| 2127 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2128 | |
| 2129 | # |
| 2130 | # compile_commands.json support... |
| 2131 | # |
| 2132 | # We have to avoid applying compile_commands support to the in-tree |
| 2133 | # tools, as those compile with BCC, which may differ from TCC. |
| 2134 | # e.g. BCC might be gcc (which does not support -MJ ...) while TCC is |
| 2135 | # clang (which does). |
| 2136 | # |
| 2137 | # What follows is more verbose than strictly necessary because we're |
| 2138 | # limited to POSIX make syntax. |
| 2139 | all: |
| 2140 | compile-commands-dir.yes = $(OBJDIR) |
| 2141 | compile-commands-dir.no = |
| 2142 | compile-commands-dir = $(compile-commands-dir.$(MAKE_COMPILATION_DB)) |
| 2143 | compile-command-args.yes = -MJ $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) |
| 2144 | compile-command-args.no = |
| 2145 | TCCFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) |
| 2146 | compile_commands.json = $(TOPDIR)/compile_commands.json |
| 2147 | # compile_commands.json is a concatenation of the .o.json files |
| 2148 | # generated by the compilation process via TCCFLAGS. We have a |
| 2149 | # potential race condition in parallel builds, where a .o.json file is |
| 2150 | # not yet written to completion before compile_commands.json is |
| 2151 | # processed. How to resolve that in a way compatible with POSIX make |
| 2152 | # is unclear. |
| 2153 | # |
| 2154 | # This obscure sed bit ensures that the resulting JSON array does not |
| 2155 | # have a trailing comma. |
| 2156 | $(compile_commands.json): $(OBJ) |
| 2157 | @-rm -f $@ |
| 2158 | sed -e '1s/^/[''\n''/' -e '$$s/,$$/''\n'']/' $(compile-commands-dir)/*.o.json > $@+ |
| 2159 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 2160 | compile-commands.no: |
| 2161 | compile-commands.yes: $(compile_commands.json) |
| 2162 | all: compile-commands.$(MAKE_COMPILATION_DB) |
| 2163 | clean: compile-commands-clean |
| 2164 | compile-commands-clean: |
| 2165 | rm -fr $(compile_commands.json) |
| 2166 | |
| 2167 | # |
| 2168 | # End compile_commands.json support |
| 2169 | # |
| 2170 | |
| @@ -2158,7 +2171,8 @@ | |
| 2171 | # |
| 2172 | # The list of all the targets that do not correspond to real files. This stops |
| 2173 | # 'make' from getting confused when someone makes an error in a rule. |
| 2174 | # |
| 2175 | |
| 2176 | .PHONY: all install test clean |
| 2177 | .PHONY: compile-commands-clean compile-commands-dir |
| 2178 | |
| 2179 |
+32
-18
| --- tools/makemake.tcl | ||
| +++ tools/makemake.tcl | ||
| @@ -359,20 +359,10 @@ | ||
| 359 | 359 | writeln "\n" |
| 360 | 360 | writeln -nonewline "OBJ =" |
| 361 | 361 | foreach s [lsort $src] { |
| 362 | 362 | writeln -nonewline " \\\n \$(OBJDIR)/$s.o" |
| 363 | 363 | } |
| 364 | -writeln { | |
| 365 | -compile-commands-dir = compile_commands | |
| 366 | -compile-commands-mkdir.yes = $(TOPDIR)/$(compile-commands-dir) | |
| 367 | -compile-commands-mkdir.no = | |
| 368 | -all: $(compile-commands-mkdir.$(MAKE_COMPILATION_DB)) | |
| 369 | -$(compile-commands-mkdir.no): | |
| 370 | -$(compile-commands-mkdir.yes): $(compile-commands-dir) | |
| 371 | - mkdir -p $@ | |
| 372 | -#$(OBJ): $(compile-commands-mkdir) | |
| 373 | -} | |
| 374 | 364 | |
| 375 | 365 | writeln [string map [list \ |
| 376 | 366 | <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n "] \ |
| 377 | 367 | <<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n "] \ |
| 378 | 368 | <<<PIKCHR_OPTIONS>>> [join $PIKCHR_OPTIONS " \\\n "] \ |
| @@ -587,21 +577,44 @@ | ||
| 587 | 577 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 588 | 578 | |
| 589 | 579 | # |
| 590 | 580 | # compile_commands.json support... |
| 591 | 581 | # |
| 592 | -compile-commands-file = $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) | |
| 593 | -compile-command-args.yes = -MJ $(compile-commands-file) | |
| 582 | +# We have to avoid applying compile_commands support to the in-tree | |
| 583 | +# tools, as those compile with BCC, which may differ from TCC. | |
| 584 | +# e.g. BCC might be gcc (which does not support -MJ ...) while TCC is | |
| 585 | +# clang (which does). | |
| 586 | +# | |
| 587 | +# What follows is more verbose than strictly necessary because we're | |
| 588 | +# limited to POSIX make syntax. | |
| 589 | +all: | |
| 590 | +compile-commands-dir.yes = $(OBJDIR) | |
| 591 | +compile-commands-dir.no = | |
| 592 | +compile-commands-dir = $(compile-commands-dir.$(MAKE_COMPILATION_DB)) | |
| 593 | +compile-command-args.yes = -MJ $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) | |
| 594 | 594 | compile-command-args.no = |
| 595 | -CFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) | |
| 596 | -compile_commands.json: | |
| 595 | +TCCFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) | |
| 596 | +compile_commands.json = $(TOPDIR)/compile_commands.json | |
| 597 | +# compile_commands.json is a concatenation of the .o.json files | |
| 598 | +# generated by the compilation process via TCCFLAGS. We have a | |
| 599 | +# potential race condition in parallel builds, where a .o.json file is | |
| 600 | +# not yet written to completion before compile_commands.json is | |
| 601 | +# processed. How to resolve that in a way compatible with POSIX make | |
| 602 | +# is unclear. | |
| 603 | +# | |
| 604 | +# This obscure sed bit ensures that the resulting JSON array does not | |
| 605 | +# have a trailing comma. | |
| 606 | +$(compile_commands.json): $(OBJ) | |
| 597 | 607 | @-rm -f $@ |
| 598 | - sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ | |
| 608 | + sed -e '1s/^/[''\n''/' -e '$$s/,$$/''\n'']/' $(compile-commands-dir)/*.o.json > $@+ | |
| 599 | 609 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 600 | 610 | compile-commands.no: |
| 601 | -compile-commands.yes: compile_commands.json | |
| 602 | -all: $(compile-commands.$(MAKE_COMPILATION_DB)) | |
| 611 | +compile-commands.yes: $(compile_commands.json) | |
| 612 | +all: compile-commands.$(MAKE_COMPILATION_DB) | |
| 613 | +clean: compile-commands-clean | |
| 614 | +compile-commands-clean: | |
| 615 | + rm -fr $(compile_commands.json) | |
| 603 | 616 | |
| 604 | 617 | # |
| 605 | 618 | # End compile_commands.json support |
| 606 | 619 | # |
| 607 | 620 | |
| @@ -608,11 +621,12 @@ | ||
| 608 | 621 | # |
| 609 | 622 | # The list of all the targets that do not correspond to real files. This stops |
| 610 | 623 | # 'make' from getting confused when someone makes an error in a rule. |
| 611 | 624 | # |
| 612 | 625 | |
| 613 | -.PHONY: all install test clean compile-commands-no compile-commands-yes | |
| 626 | +.PHONY: all install test clean | |
| 627 | +.PHONY: compile-commands-clean compile-commands-dir | |
| 614 | 628 | }] |
| 615 | 629 | |
| 616 | 630 | close $output_file |
| 617 | 631 | # |
| 618 | 632 | # End of the main.mk output |
| 619 | 633 |
| --- tools/makemake.tcl | |
| +++ tools/makemake.tcl | |
| @@ -359,20 +359,10 @@ | |
| 359 | writeln "\n" |
| 360 | writeln -nonewline "OBJ =" |
| 361 | foreach s [lsort $src] { |
| 362 | writeln -nonewline " \\\n \$(OBJDIR)/$s.o" |
| 363 | } |
| 364 | writeln { |
| 365 | compile-commands-dir = compile_commands |
| 366 | compile-commands-mkdir.yes = $(TOPDIR)/$(compile-commands-dir) |
| 367 | compile-commands-mkdir.no = |
| 368 | all: $(compile-commands-mkdir.$(MAKE_COMPILATION_DB)) |
| 369 | $(compile-commands-mkdir.no): |
| 370 | $(compile-commands-mkdir.yes): $(compile-commands-dir) |
| 371 | mkdir -p $@ |
| 372 | #$(OBJ): $(compile-commands-mkdir) |
| 373 | } |
| 374 | |
| 375 | writeln [string map [list \ |
| 376 | <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n "] \ |
| 377 | <<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n "] \ |
| 378 | <<<PIKCHR_OPTIONS>>> [join $PIKCHR_OPTIONS " \\\n "] \ |
| @@ -587,21 +577,44 @@ | |
| 587 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 588 | |
| 589 | # |
| 590 | # compile_commands.json support... |
| 591 | # |
| 592 | compile-commands-file = $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) |
| 593 | compile-command-args.yes = -MJ $(compile-commands-file) |
| 594 | compile-command-args.no = |
| 595 | CFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) |
| 596 | compile_commands.json: |
| 597 | @-rm -f $@ |
| 598 | sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $(compile-commands-dir)/*.o.json > $@+ |
| 599 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 600 | compile-commands.no: |
| 601 | compile-commands.yes: compile_commands.json |
| 602 | all: $(compile-commands.$(MAKE_COMPILATION_DB)) |
| 603 | |
| 604 | # |
| 605 | # End compile_commands.json support |
| 606 | # |
| 607 | |
| @@ -608,11 +621,12 @@ | |
| 608 | # |
| 609 | # The list of all the targets that do not correspond to real files. This stops |
| 610 | # 'make' from getting confused when someone makes an error in a rule. |
| 611 | # |
| 612 | |
| 613 | .PHONY: all install test clean compile-commands-no compile-commands-yes |
| 614 | }] |
| 615 | |
| 616 | close $output_file |
| 617 | # |
| 618 | # End of the main.mk output |
| 619 |
| --- tools/makemake.tcl | |
| +++ tools/makemake.tcl | |
| @@ -359,20 +359,10 @@ | |
| 359 | writeln "\n" |
| 360 | writeln -nonewline "OBJ =" |
| 361 | foreach s [lsort $src] { |
| 362 | writeln -nonewline " \\\n \$(OBJDIR)/$s.o" |
| 363 | } |
| 364 | |
| 365 | writeln [string map [list \ |
| 366 | <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n "] \ |
| 367 | <<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n "] \ |
| 368 | <<<PIKCHR_OPTIONS>>> [join $PIKCHR_OPTIONS " \\\n "] \ |
| @@ -587,21 +577,44 @@ | |
| 577 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 578 | |
| 579 | # |
| 580 | # compile_commands.json support... |
| 581 | # |
| 582 | # We have to avoid applying compile_commands support to the in-tree |
| 583 | # tools, as those compile with BCC, which may differ from TCC. |
| 584 | # e.g. BCC might be gcc (which does not support -MJ ...) while TCC is |
| 585 | # clang (which does). |
| 586 | # |
| 587 | # What follows is more verbose than strictly necessary because we're |
| 588 | # limited to POSIX make syntax. |
| 589 | all: |
| 590 | compile-commands-dir.yes = $(OBJDIR) |
| 591 | compile-commands-dir.no = |
| 592 | compile-commands-dir = $(compile-commands-dir.$(MAKE_COMPILATION_DB)) |
| 593 | compile-command-args.yes = -MJ $(TOPDIR)/$(compile-commands-dir)/$(@F:.o=.o.json) |
| 594 | compile-command-args.no = |
| 595 | TCCFLAGS += $(compile-command-args.$(MAKE_COMPILATION_DB)) |
| 596 | compile_commands.json = $(TOPDIR)/compile_commands.json |
| 597 | # compile_commands.json is a concatenation of the .o.json files |
| 598 | # generated by the compilation process via TCCFLAGS. We have a |
| 599 | # potential race condition in parallel builds, where a .o.json file is |
| 600 | # not yet written to completion before compile_commands.json is |
| 601 | # processed. How to resolve that in a way compatible with POSIX make |
| 602 | # is unclear. |
| 603 | # |
| 604 | # This obscure sed bit ensures that the resulting JSON array does not |
| 605 | # have a trailing comma. |
| 606 | $(compile_commands.json): $(OBJ) |
| 607 | @-rm -f $@ |
| 608 | sed -e '1s/^/[''\n''/' -e '$$s/,$$/''\n'']/' $(compile-commands-dir)/*.o.json > $@+ |
| 609 | @if test -s $@+; then mv $@+ $@; else rm -f $@+; fi |
| 610 | compile-commands.no: |
| 611 | compile-commands.yes: $(compile_commands.json) |
| 612 | all: compile-commands.$(MAKE_COMPILATION_DB) |
| 613 | clean: compile-commands-clean |
| 614 | compile-commands-clean: |
| 615 | rm -fr $(compile_commands.json) |
| 616 | |
| 617 | # |
| 618 | # End compile_commands.json support |
| 619 | # |
| 620 | |
| @@ -608,11 +621,12 @@ | |
| 621 | # |
| 622 | # The list of all the targets that do not correspond to real files. This stops |
| 623 | # 'make' from getting confused when someone makes an error in a rule. |
| 624 | # |
| 625 | |
| 626 | .PHONY: all install test clean |
| 627 | .PHONY: compile-commands-clean compile-commands-dir |
| 628 | }] |
| 629 | |
| 630 | close $output_file |
| 631 | # |
| 632 | # End of the main.mk output |
| 633 |