Computer Laboratory

Research

Firmament development environment

This page contains a set of recommendations for working with the Firmament code base.

git setup

For better legibility of git diffs, set the color.diff option to always.

$ git config --global color.diff=always

Code style

The Firmament project tries to, with some exceptions, adhere to the Google C++ style guide.

Lint checking

To check style guide adherence of your code, run the cpplint.py script that is automatically installed in the Firmament build environment:

$ make lint

For a more verbose version, use:

$ make lint-verb

git commit hook

To automatically check style guide adherence at git commit time, install the following commit hook in your repository by pasting the code into new file .git/hooks/pre-commit:

#!/bin/sh

echo "Running pre-commit lint pass... (skip with --no-verify)"

git stash -q --keep-index

make lint
RESULT=$?
git stash pop -q

if [ ${RESULT} != 0 ]; then
  echo
  echo "-----------------------------------------------"
  echo "  LINTING FAILED -- please fix above errors.   "
  echo ""
  echo " [Bypass by passing --no-verify to git commit] "
  echo "-----------------------------------------------"
  exit 1
else
  exit 0
fi