summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2023-05-01 13:43:26 -0400
committerColin Walters <walters@verbum.org>2023-05-01 15:37:56 -0400
commitf56131976ea7e0945101a3ce97256dc1280cc0d3 (patch)
tree474202d5dfcb6a14da9ada97cae10d97b20d8cb6
parentd333f20b4a139387215017c9d52ee591ba6b199d (diff)
downloadostree-f56131976ea7e0945101a3ce97256dc1280cc0d3.tar.gz
Add clang formatting infrastructure
Prep for reformatting the codebase.
-rw-r--r--.clang-format4
-rw-r--r--Makefile.am4
-rwxr-xr-xci/codestyle.sh7
-rwxr-xr-xci/gh-install.sh1
-rwxr-xr-xci/rpmostree.sh2
5 files changed, 17 insertions, 1 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..59902b6c
--- /dev/null
+++ b/.clang-format
@@ -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']
diff --git a/Makefile.am b/Makefile.am
index 50282156..cccf6ae7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -132,6 +132,10 @@ include Makefile-bash.am
release-tag:
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}
git_version_rpm = $$(cd $(srcdir) && git describe | sed -e 's,-,\.,g' -e 's,^v,,')
diff --git a/ci/codestyle.sh b/ci/codestyle.sh
index 1cf0a23c..850661e5 100755
--- a/ci/codestyle.sh
+++ b/ci/codestyle.sh
@@ -15,6 +15,13 @@ done
echo "ok"
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... '
patterns=(glnx_fd_close)
for pat in "${patterns[@]}"; do
diff --git a/ci/gh-install.sh b/ci/gh-install.sh
index c2928665..966edb28 100755
--- a/ci/gh-install.sh
+++ b/ci/gh-install.sh
@@ -71,6 +71,7 @@ case "$ID" in
build-essential
bubblewrap
ca-certificates
+ clang-format
cpio
debhelper
dh-exec
diff --git a/ci/rpmostree.sh b/ci/rpmostree.sh
index 0a5f5df9..554cde69 100755
--- a/ci/rpmostree.sh
+++ b/ci/rpmostree.sh
@@ -22,7 +22,7 @@ pkg_install rpm-ostree && rpm -e rpm-ostree
pkg_install ostree{,-devel,-grub2} createrepo_c /usr/bin/jq python3-pyyaml \
libubsan libasan libtsan elfutils fuse sudo python3-gobject-base \
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
pkg_install openssh-clients ansible