Add clang formatting infrastructure

Prep for reformatting the codebase.
This commit is contained in:
Colin Walters 2023-05-01 13:43:26 -04:00
parent d333f20b4a
commit f56131976e
5 changed files with 17 additions and 1 deletions

4
.clang-format Normal file
View File

@ -0,0 +1,4 @@
Language: Cpp
BasedOnStyle: GNU
ColumnLimit: 100
ForEachMacros: ['GLNX_HASH_TABLE_FOREACH', 'GLNX_HASH_TABLE_FOREACH_V', 'GLNX_HASH_TABLE_FOREACH_KV', 'GLNX_HASH_TABLE_FOREACH_IT']

View File

@ -132,6 +132,10 @@ include Makefile-bash.am
release-tag: release-tag:
cd $(srcdir) && git $(srcdir) tag -m "Release $(VERSION)" v$(VERSION) cd $(srcdir) && git $(srcdir) tag -m "Release $(VERSION)" v$(VERSION)
.PHONY: clang-format
clang-format:
git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format -i
embed_dependency=tar -C $(srcdir) --append --exclude='.git/*' --transform="s,^embedded-dependencies/,ostree-embeddeps-$${GITVERSION}/embedded-dependencies/," --file=$${TARFILE_TMP} embed_dependency=tar -C $(srcdir) --append --exclude='.git/*' --transform="s,^embedded-dependencies/,ostree-embeddeps-$${GITVERSION}/embedded-dependencies/," --file=$${TARFILE_TMP}
git_version_rpm = $$(cd $(srcdir) && git describe | sed -e 's,-,\.,g' -e 's,^v,,') git_version_rpm = $$(cd $(srcdir) && git describe | sed -e 's,-,\.,g' -e 's,^v,,')

View File

@ -15,6 +15,13 @@ done
echo "ok" echo "ok"
fi fi
# Will uncomment this once we reformat
#if command -v clang-format; then
# echo -n "checking clang-format... "
# git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format --Werror --dry-run
# echo "ok"
#fi
echo -n 'grep-based static analysis... ' echo -n 'grep-based static analysis... '
patterns=(glnx_fd_close) patterns=(glnx_fd_close)
for pat in "${patterns[@]}"; do for pat in "${patterns[@]}"; do

View File

@ -71,6 +71,7 @@ case "$ID" in
build-essential build-essential
bubblewrap bubblewrap
ca-certificates ca-certificates
clang-format
cpio cpio
debhelper debhelper
dh-exec dh-exec

View File

@ -22,7 +22,7 @@ pkg_install rpm-ostree && rpm -e rpm-ostree
pkg_install ostree{,-devel,-grub2} createrepo_c /usr/bin/jq python3-pyyaml \ pkg_install ostree{,-devel,-grub2} createrepo_c /usr/bin/jq python3-pyyaml \
libubsan libasan libtsan elfutils fuse sudo python3-gobject-base \ libubsan libasan libtsan elfutils fuse sudo python3-gobject-base \
selinux-policy-devel selinux-policy-targeted python3-createrepo_c \ selinux-policy-devel selinux-policy-targeted python3-createrepo_c \
rsync python3-rpm parallel clang rustfmt-preview rsync python3-rpm parallel clang rustfmt-preview clang-tools-extra
# From rpm-ostree/ci/vmcheck-provision.sh # From rpm-ostree/ci/vmcheck-provision.sh
pkg_install openssh-clients ansible pkg_install openssh-clients ansible