@@ -259,7 +259,7 @@ endif
259259default : $(JULIA_BUILD_MODE ) # contains either "debug" or "release"
260260all : debug release
261261
262- release debug : % : libjulia-internal-% libjulia-codegen-% $( BUILDDIR ) / compile_commands.json
262+ release debug : % : libjulia-internal-% libjulia-codegen-% regenerate- compile_commands
263263
264264$(BUILDDIR ) :
265265 mkdir -p $(BUILDDIR )
@@ -558,6 +558,7 @@ clean:
558558 -rm -f $(BUILDDIR ) /* .dbg.obj $(BUILDDIR ) /* .o $(BUILDDIR ) /* .dwo $(BUILDDIR ) /* .$(SHLIB_EXT ) $(BUILDDIR ) /* .a $(BUILDDIR ) /* .h.gen
559559 -rm -f $(BUILDDIR ) /julia.expmap
560560 -rm -f $(BUILDDIR ) /julia_version.h
561+ -rm -f $(BUILDDIR ) /compile_commands.json
561562
562563clean-flisp :
563564 -$(MAKE ) -C $(SRCDIR ) /flisp clean BUILDDIR=' $(abspath $(BUILDDIR)/flisp)'
@@ -654,8 +655,10 @@ clean-analyzegc:
654655 rm -f $(build_shlibdir ) /libImplicitAtomicsPlugin.$(SHLIB_EXT )
655656
656657# Compilation database generation using existing clang infrastructure
657- $(BUILDDIR ) /compile_commands.json :
658- @{ \
658+ .PHONY : regenerate-compile_commands
659+ regenerate-compile_commands :
660+ TMPFILE=$$(mktemp -p $(BUILDDIR ) compile_commands.json.XXXXXX ) ; \
661+ { \
659662 CLANG_TOOLING_C_FLAGS=" $$ ($( JULIAHOME) /contrib/escape_json.sh clang $( CLANG_TOOLING_C_FLAGS) )" ; \
660663 CLANG_TOOLING_CXX_FLAGS=" $$ ($( JULIAHOME) /contrib/escape_json.sh clang $( CLANG_TOOLING_CXX_FLAGS) )" ; \
661664 echo " [" ; \
@@ -711,18 +714,17 @@ $(BUILDDIR)/compile_commands.json:
711714 printf ' {\n "directory": "%s",\n "file": "%s",\n "arguments": [%s]\n}' " $( abspath $( SRCDIR) ) " " $$ included_file" " $$ cmd" ; \
712715 done ; \
713716 echo " ]" ; \
714- } > $@ .tmp
715- @# This ensures we replace the file atomically, and avoid spurious rewrites
716- @if ! cmp -s $@ .tmp $@ ; then \
717- mv $@ .tmp $@ ; \
717+ } > $$ TMPFILE; \
718+ if ! cmp -s $$ TMPFILE $( BUILDDIR) /compile_commands.json; then \
719+ mv $$ TMPFILE $(BUILDDIR ) /compile_commands.json; \
718720 else \
719- rm -f $@ .tmp ; \
721+ rm -f $$ TMPFILE ; \
720722 fi
721723
722- compile-database : $( BUILDDIR ) / compile_commands.json
724+ compile-database : regenerate- compile_commands
723725 $(MAKE ) -C $(SRCDIR ) /flisp compile-database BUILDDIR=' $(abspath $(BUILDDIR)/flisp)'
724726 $(MAKE ) -C $(SRCDIR ) /support compile-database BUILDDIR=' $(abspath $(BUILDDIR)/support)'
725- @echo " Compilation database created: $< "
727+ @echo " Compilation database created for src "
726728
727729.FORCE :
728- .PHONY : default all debug release clean cleanall clean-* libccalltest libllvmcalltest julia_flisp.boot.inc.phony analyzegc analyzesrc compile-database $( BUILDDIR ) /compile_commands.json .FORCE
730+ .PHONY : default all debug release clean cleanall clean-* libccalltest libllvmcalltest julia_flisp.boot.inc.phony analyzegc analyzesrc compile-database .FORCE
0 commit comments