Skip to content

Instantly share code, notes, and snippets.

@fwyzard
fwyzard / llvm-ccdb-add
Last active November 1, 2016 05:29
Python tool to add entries to an LLVM compilation database
#! /usr/bin/env python
import sys
import os
import fcntl
import argparse
import json
# the default location for the compilation database is the file 'compile_commands.json' in the current directory
def_dbname = 'compile_commands.json'
@fwyzard
fwyzard / Makefile.rules.diff
Last active November 1, 2016 05:31
patch .../config/SCRAM/GMake/Makefile.rules to call llvm-ccdb-add
--- config/SCRAM/GMake/Makefile.rules 2016-09-09 13:00:19.000000000 +0200
+++ config/SCRAM/GMake/Makefile.rules 2016-10-31 19:31:37.061151791 +0100
@@ -515,6 +515,7 @@ define run_compile_command
$(CMD_echo) ">> Compiling $(2) $< " &&\
$(VERB_ECHO) $4 $5 $< -o $@ &&\
($4 $5 $< -o $@ || ($(if $(strip $6),$4 $6 $< -o $(basename $@).d && $(CMD_sed) -i -e 's|.*:|$@:|' $(basename $@).d && exit 1,exit 1))) $3 $(endlog_$(1))
+ @llvm-ccdb-add -p "$(CMSSW_BASE)/.SCRAM/$(SCRAM_ARCH)/compile_commands.json" "$<" "$4 $5 $< -o $@"
endef
define compile_cxx_common
$(call run_compile_command,$2,$4,$5,$(CXX) -c $(3) $(CXXOPTIMISEDFLAGS) $(CXXSHAREDOBJECTFLAGS),$(if $(6),,$(CXX_MMD) $(CXX_MF) $(basename $@).d),$(if $(6),,$(CXX_MM)))
#! /bin/bash
# to launch a container using this profile:
# lxc launch <container> -p default -p $USER
set -eu
#UID=$(id -u)
GID=$(id -g)
SUBUID=root:$UID:1
SUBGID=root:$GID:1