Add clang formatting infrastructure
authorColin Walters <walters@verbum.org>
Mon, 1 May 2023 17:43:26 +0000 (13:43 -0400)
committerColin Walters <walters@verbum.org>
Mon, 1 May 2023 19:37:56 +0000 (15:37 -0400)
Prep for reformatting the codebase.

.clang-format [new file with mode: 0644]
Makefile.am
ci/codestyle.sh
ci/gh-install.sh
ci/rpmostree.sh

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..59902b6
--- /dev/null
@@ -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']
index 50282156c78f364b75d09505f5a42c70edab9f89..cccf6ae7eaa7ffa225f65d4819b042498dbf5c0a 100644 (file)
@@ -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,,')
index 1cf0a23c64f274442973010b846e5bcf43d20544..850661e576c7464fb0f1b7b7f2a5cb06d257c8de 100755 (executable)
@@ -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
index c2928665bc4af9ec9bf25a6e848776a33c92bdc0..966edb2896b729f42cd4524e498424a89ef8abc2 100755 (executable)
@@ -71,6 +71,7 @@ case "$ID" in
             build-essential
             bubblewrap
             ca-certificates
+            clang-format
             cpio
             debhelper
             dh-exec
index 0a5f5df9a945c23c08fd514bc307983eb1a63628..554cde69f24b7810cf26c2452768f464305ce122 100755 (executable)
@@ -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