diff --git a/SConscript b/SConscript index 0aa3aa34..1a79e388 100644 --- a/SConscript +++ b/SConscript @@ -101,7 +101,8 @@ def build_project(project_name, project, extra_flags): ASCOM="$AS $ASFLAGS -o $TARGET -c $SOURCES", BUILDERS={ 'Objcopy': Builder(generator=objcopy, suffix='.bin', src_suffix='.elf') - } + }, + tools=["default", "compilation_db"], ) startup = env.Object(f"obj/startup_{project_name}", project["STARTUP_FILE"]) diff --git a/SConstruct b/SConstruct index e7cd8d85..aa13f592 100644 --- a/SConstruct +++ b/SConstruct @@ -12,5 +12,17 @@ AddOption('--coverage', action='store_true', help='build with test coverage options') +AddOption('--compile_db', + action='store_true', + help='build clang compilation database') + +env = Environment( + COMPILATIONDB_USE_ABSPATH=True, + tools=["default", "compilation_db"], +) + +if GetOption('compile_db'): + env.CompilationDatabase("compile_commands.json") + # panda fw & test files SConscript('SConscript')