Add creating compile_commands.json to the build system.
I'm really not proud of how I did this though. It must be run from the same environment as one's editor (ie. not in the docker image) so that the paths are correct.
This commit is contained in:
parent
69aa33eed5
commit
9bcc7685d2
|
@ -42,6 +42,7 @@ packaging/msi/FDBInstaller.wix*
|
|||
.ccache
|
||||
.deps/
|
||||
.objs/
|
||||
.cmds/
|
||||
bindings/c/fdb_c.symbols
|
||||
bindings/go/build
|
||||
bindings/go/godoc
|
||||
|
@ -71,6 +72,7 @@ FoundationDB.xcodeproj
|
|||
foundationdb.VC.db
|
||||
foundationdb.VC.VC.opendb
|
||||
ipch/
|
||||
compile_commands.json
|
||||
|
||||
# Temporary and user configuration files
|
||||
*~
|
||||
|
|
6
Makefile
6
Makefile
|
@ -160,6 +160,11 @@ $(CPP_MK_GENERATED): build/vcxprojtom4.py build/vcxproj.mk Makefile
|
|||
|
||||
DEPSDIR := .deps
|
||||
OBJDIR := .objs
|
||||
CMDDIR := .cmds
|
||||
|
||||
COMPILE_COMMANDS_JSONS := $(addprefix $(CMDDIR)/,$(addsuffix /compile_commands.json,${CPP_PROJECTS}))
|
||||
compile_commands.json: build/concatinate_jsons.py ${COMPILE_COMMANDS_JSONS}
|
||||
@build/concatinate_jsons.py ${COMPILE_COMMANDS_JSONS}
|
||||
|
||||
include $(MK_INCLUDE)
|
||||
|
||||
|
@ -169,6 +174,7 @@ clean: $(CLEAN_TARGETS) docpreview_clean
|
|||
@rm -rf $(DEPSDIR)
|
||||
@rm -rf lib/
|
||||
@rm -rf bin/coverage.*.xml
|
||||
@rm -rf $(CMDDIR) compile_commands.json
|
||||
@find . -name "*.g.cpp" -exec rm -f {} \; -or -name "*.g.h" -exec rm -f {} \;
|
||||
|
||||
targets:
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
lst = []
|
||||
for filename in sys.argv[1:]:
|
||||
commands = json.load(open(filename))
|
||||
lst.extend(commands)
|
||||
|
||||
json.dump(lst, open("compile_commands.json", "w"))
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import json
|
||||
|
||||
flags = sys.argv[1]
|
||||
all_files = sys.argv[2]
|
||||
outfile = sys.argv[3]
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
commands = []
|
||||
for fname in all_files.split(' '):
|
||||
d = {}
|
||||
d["directory"] = cwd
|
||||
if fname.endswith("cpp") or fname.endswith(".h"):
|
||||
compiler = "clang++ -x c++ "
|
||||
if fname.endswith("c"):
|
||||
compiler = "clang -x c "
|
||||
d["command"] = compiler + flags.replace('-DNO_INTELLISENSE', '').replace("/opt/boost", cwd+"/../boost") + "-c " + fname
|
||||
d["file"] = fname
|
||||
commands.append(d)
|
||||
|
||||
json.dump(commands, open(outfile, "w"))
|
|
@ -58,6 +58,10 @@ GENNAME()_DEPS := $(addprefix $(DEPSDIR)/,$(GENNAME()_BUILD_SOURCES:=.d))
|
|||
|
||||
GENNAME: GENTARGET
|
||||
|
||||
$(CMDDIR)/GENDIR/compile_commands.json: build/project_commands.py ${GENNAME()_ALL_SOURCES}
|
||||
@mkdir -p $(basename $@)
|
||||
@build/project_commands.py "$(CFLAGS) $(CXXFLAGS) $(GENNAME()_CFLAGS) $(GENNAME()_CXXFLAGS)" "$(GENNAME()_ALL_SOURCES)" "$@"
|
||||
|
||||
-include $(GENNAME()_DEPS)
|
||||
|
||||
$(OBJDIR)/GENDIR/%.actor.g.cpp: GENDIR/%.actor.cpp $(ACTORCOMPILER)
|
||||
|
|
Loading…
Reference in New Issue