From d333f20b4a139387215017c9d52ee591ba6b199d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 1 May 2023 14:21:19 -0400 Subject: build-sys: Squash automake conditional warning re `.PHONY` --- Makefile-man.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 . +# 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) -- cgit v1.2.1 From f56131976ea7e0945101a3ce97256dc1280cc0d3 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 1 May 2023 13:43:26 -0400 Subject: Add clang formatting infrastructure Prep for reformatting the codebase. --- .clang-format | 4 ++++ Makefile.am | 4 ++++ ci/codestyle.sh | 7 +++++++ ci/gh-install.sh | 1 + ci/rpmostree.sh | 2 +- 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .clang-format 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 -- cgit v1.2.1 From abd5427c3b7c8a125dfb29f42b6798774ed62bac Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 1 May 2023 13:51:47 -0400 Subject: lib: clang-format `ostree.h` In order to make this work, we need to move the autocleanup definitions after the other headers. --- src/libostree/ostree.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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 +#include #include #include -#include -#include -#include -#include -#include -#include -#include #include -#include #include #include +#include +#include #include -#include +#include +#include #include #include #include #include -#include +#include +#include +#include #include -#include +#include +#include #include + +// Include after type definitions +#include -- cgit v1.2.1 From 0e4768094c826a8d7f1ce638a0909357b9a45b07 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 1 May 2023 14:02:09 -0400 Subject: tree-wide: Fix various include ordering issues This fixes the build with `clang-format`. --- src/libostree/ostree-bootloader.c | 1 + src/libostree/ostree-bootloader.h | 3 ++- src/libostree/ostree-repo-static-delta-compilation.c | 3 +-- src/ostree/main.c | 1 - src/ostree/ot-admin-builtins.h | 2 +- src/ostree/ot-admin-instutil-builtins.h | 2 +- src/ostree/ot-admin-kargs-builtins.h | 2 +- src/ostree/ot-builtins.h | 1 + 8 files changed, 8 insertions(+), 7 deletions(-) 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 +#include + #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 #include +#include #include -#include #include "ostree-core-private.h" #include "ostree-repo-private.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 #include -#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 +#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 +#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 +#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 -- cgit v1.2.1