summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lebon <jonathan@jlebon.com>2023-05-01 16:48:26 -0400
committerGitHub <noreply@github.com>2023-05-01 16:48:26 -0400
commitdd70c9b78cc34ccc7e638eda4c2df1ddd8ee3add (patch)
tree017d194ea6def4434d165bd4e261253228f28ae0
parent919212d73bce677fb1fbd2f9a43a270155348328 (diff)
parent0e4768094c826a8d7f1ce638a0909357b9a45b07 (diff)
downloadostree-dd70c9b78cc34ccc7e638eda4c2df1ddd8ee3add.tar.gz
Merge pull request #2854 from cgwalters/clang-format-prep
-rw-r--r--.clang-format4
-rw-r--r--Makefile-man.am4
-rw-r--r--Makefile.am4
-rwxr-xr-xci/codestyle.sh7
-rwxr-xr-xci/gh-install.sh1
-rwxr-xr-xci/rpmostree.sh2
-rw-r--r--src/libostree/ostree-bootloader.c1
-rw-r--r--src/libostree/ostree-bootloader.h3
-rw-r--r--src/libostree/ostree-repo-static-delta-compilation.c3
-rw-r--r--src/libostree/ostree.h24
-rw-r--r--src/ostree/main.c1
-rw-r--r--src/ostree/ot-admin-builtins.h2
-rw-r--r--src/ostree/ot-admin-instutil-builtins.h2
-rw-r--r--src/ostree/ot-admin-kargs-builtins.h2
-rw-r--r--src/ostree/ot-builtins.h1
15 files changed, 41 insertions, 20 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-man.am b/Makefile-man.am
index 41c59327..0cb80f4d 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -17,6 +17,9 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
+# This needs to be outside the conditional to avoid a warning
+.PHONY: manhtml
+
if ENABLE_MAN
# If you add a new man page here, add a reference to it in index.xml and
@@ -65,7 +68,6 @@ noinst_DATA += $(manhtml_files)
# Convenience target for building the just the HTML man pages
manhtml: $(manhtml_files)
-.PHONY: manhtml
endif
EXTRA_DIST += man/index.xml $(man1_MANS:.1=.xml) $(man5_MANS:.5=.xml)
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
diff --git a/src/libostree/ostree-bootloader.c b/src/libostree/ostree-bootloader.c
index 790bf502..788fb2c4 100644
--- a/src/libostree/ostree-bootloader.c
+++ b/src/libostree/ostree-bootloader.c
@@ -16,6 +16,7 @@
*/
#include "config.h"
+
#include "ostree-bootloader.h"
G_DEFINE_INTERFACE (OstreeBootloader, _ostree_bootloader, G_TYPE_OBJECT)
diff --git a/src/libostree/ostree-bootloader.h b/src/libostree/ostree-bootloader.h
index ca1b453e..00f5632c 100644
--- a/src/libostree/ostree-bootloader.h
+++ b/src/libostree/ostree-bootloader.h
@@ -17,7 +17,8 @@
#pragma once
-#include <gio/gio.h>
+#include <ostree.h>
+
#include "otutil.h"
G_BEGIN_DECLS
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c
index 1e3af0d8..1f536903 100644
--- a/src/libostree/ostree-repo-static-delta-compilation.c
+++ b/src/libostree/ostree-repo-static-delta-compilation.c
@@ -19,10 +19,9 @@
#include "config.h"
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <gio/gunixoutputstream.h>
-#include <gio/gmemoryoutputstream.h>
#include "ostree-core-private.h"
#include "ostree-repo-private.h"
diff --git a/src/libostree/ostree.h b/src/libostree/ostree.h
index 8422823e..6c52ba0e 100644
--- a/src/libostree/ostree.h
+++ b/src/libostree/ostree.h
@@ -20,26 +20,28 @@
#pragma once
#include <ostree-async-progress.h>
+#include <ostree-bootconfig-parser.h>
#include <ostree-content-writer.h>
#include <ostree-core.h>
-#include <ostree-repo.h>
-#include <ostree-repo-os.h>
-#include <ostree-mutable-tree.h>
-#include <ostree-remote.h>
-#include <ostree-repo-file.h>
-#include <ostree-sysroot.h>
-#include <ostree-sysroot-upgrader.h>
#include <ostree-deployment.h>
-#include <ostree-bootconfig-parser.h>
#include <ostree-diff.h>
#include <ostree-gpg-verify-result.h>
+#include <ostree-kernel-args.h>
+#include <ostree-mutable-tree.h>
#include <ostree-ref.h>
-#include <ostree-repo-finder.h>
+#include <ostree-remote.h>
+#include <ostree-repo-file.h>
#include <ostree-repo-finder-avahi.h>
#include <ostree-repo-finder-config.h>
#include <ostree-repo-finder-mount.h>
#include <ostree-repo-finder-override.h>
-#include <ostree-kernel-args.h>
+#include <ostree-repo-finder.h>
+#include <ostree-repo-os.h>
+#include <ostree-repo.h>
#include <ostree-sign.h>
-#include <ostree-autocleanups.h>
+#include <ostree-sysroot-upgrader.h>
+#include <ostree-sysroot.h>
#include <ostree-version.h>
+
+// Include after type definitions
+#include <ostree-autocleanups.h>
diff --git a/src/ostree/main.c b/src/ostree/main.c
index badfa6df..0b886c1f 100644
--- a/src/ostree/main.c
+++ b/src/ostree/main.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <unistd.h>
-#include "ot-main.h"
#include "ot-builtins.h"
static OstreeCommand commands[] = {
diff --git a/src/ostree/ot-admin-builtins.h b/src/ostree/ot-admin-builtins.h
index 8bac1c56..10af1ec2 100644
--- a/src/ostree/ot-admin-builtins.h
+++ b/src/ostree/ot-admin-builtins.h
@@ -21,7 +21,7 @@
#pragma once
-#include <ostree.h>
+#include "ot-main.h"
G_BEGIN_DECLS
diff --git a/src/ostree/ot-admin-instutil-builtins.h b/src/ostree/ot-admin-instutil-builtins.h
index 03a0bb69..832193db 100644
--- a/src/ostree/ot-admin-instutil-builtins.h
+++ b/src/ostree/ot-admin-instutil-builtins.h
@@ -19,7 +19,7 @@
#pragma once
-#include <ostree.h>
+#include "ot-main.h"
G_BEGIN_DECLS
diff --git a/src/ostree/ot-admin-kargs-builtins.h b/src/ostree/ot-admin-kargs-builtins.h
index f3837c34..5d345f2a 100644
--- a/src/ostree/ot-admin-kargs-builtins.h
+++ b/src/ostree/ot-admin-kargs-builtins.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ostree.h>
+#include "ot-main.h"
G_BEGIN_DECLS
diff --git a/src/ostree/ot-builtins.h b/src/ostree/ot-builtins.h
index 286c2e99..63b1ea38 100644
--- a/src/ostree/ot-builtins.h
+++ b/src/ostree/ot-builtins.h
@@ -24,6 +24,7 @@
#include "config.h"
#include "ostree.h"
+#include "ot-main.h"
G_BEGIN_DECLS