#!/usr/bin/env bash
clang --preprocess \
--no-line-commands \
--include-directory include/preprocess \
-nostdinc \
include/preprocess/preprocess.h > src/git2.h
clang --preprocess \
--no-line-commands \
include/preprocess/noattrs.h > /tmp/noattrd.h
cp include/preprocess/.clang-format /tmp
sed -i '/^$/d' /tmp/noattrd.h
echo '#define FFI_LIB "git2"' > src/git2.h
echo '#define FFI_SCOPE "git2"' >> src/git2.h
# Let's hope this shit is at least consistent.
clang-format --style file /tmp/noattrd.h >> src/git2.h
sed -i -r 's:^\s+:\t:' src/git2.h