Fossil SCM

Rework the elimination of the trailing comma in compile_commands.json to be more platform-portable.

stephan 2023-06-19 17:37 compile_commands.json
Commit 49c53e0bb8ca7db1e1411e412e9541adb0619142f7e2bf5f062c6b6cab320e8c
2 files changed +2 -2 +2 -2
+2 -2
--- src/main.mk
+++ src/main.mk
@@ -2153,12 +2153,12 @@
21532153
#
21542154
# This obscure sed bit ensures that the resulting JSON array does not
21552155
# have a trailing comma.
21562156
$(compile_commands.json): $(OBJ)
21572157
@-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
2158
+ @{ echo '['; cat $(compile-commands-dir)/*.o.json | tr '\n' ' ' | sed -e 's/, $$//'; echo ']'; } > $@
2159
+ @echo "Generated $@"
21602160
compile-commands.no:
21612161
compile-commands.yes: $(compile_commands.json)
21622162
all: compile-commands.$(MAKE_COMPILATION_DB)
21632163
clean: compile-commands-clean
21642164
compile-commands-clean:
21652165
--- src/main.mk
+++ src/main.mk
@@ -2153,12 +2153,12 @@
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
--- src/main.mk
+++ src/main.mk
@@ -2153,12 +2153,12 @@
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 @{ echo '['; cat $(compile-commands-dir)/*.o.json | tr '\n' ' ' | sed -e 's/, $$//'; echo ']'; } > $@
2159 @echo "Generated $@"
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
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -603,12 +603,12 @@
603603
#
604604
# This obscure sed bit ensures that the resulting JSON array does not
605605
# have a trailing comma.
606606
$(compile_commands.json): $(OBJ)
607607
@-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
608
+ @{ echo '['; cat $(compile-commands-dir)/*.o.json | tr '\n' ' ' | sed -e 's/, $$//'; echo ']'; } > $@
609
+ @echo "Generated $@"
610610
compile-commands.no:
611611
compile-commands.yes: $(compile_commands.json)
612612
all: compile-commands.$(MAKE_COMPILATION_DB)
613613
clean: compile-commands-clean
614614
compile-commands-clean:
615615
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -603,12 +603,12 @@
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
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -603,12 +603,12 @@
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 @{ echo '['; cat $(compile-commands-dir)/*.o.json | tr '\n' ' ' | sed -e 's/, $$//'; echo ']'; } > $@
609 @echo "Generated $@"
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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button