Fix sdbus++-gen-meson version warning
WARNING: Generated meson files from wrong version of
sdbus++-gen-meson.
WARNING: Expected "sdbus++-gen-meson version 1",
got: sdbus++-gen-meson version 3
Add the regenerate-meson file to automatically update meson.build.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: If1ce533bc0f6bafbe75d05595f9d36f5f652bd45
diff --git a/gen/README b/gen/README
new file mode 100644
index 0000000..71182b5
--- /dev/null
+++ b/gen/README
@@ -0,0 +1,2 @@
+This directory contains generated meson.build files from sdbus++-gen-meson.
+Do not edit them by hand.
diff --git a/gen/meson.build b/gen/meson.build
index 50bb831..56193c7 100644
--- a/gen/meson.build
+++ b/gen/meson.build
@@ -4,10 +4,10 @@
'--version',
).stdout().strip().split('\n')[0]
-if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 1'
+if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 3'
warning('Generated meson files from wrong version of sdbus++-gen-meson.')
warning(
- 'Expected "sdbus++-gen-meson version 1", got:',
+ 'Expected "sdbus++-gen-meson version 3", got:',
sdbuspp_gen_meson_ver
)
endif
diff --git a/gen/regenerate-meson b/gen/regenerate-meson
new file mode 100755
index 0000000..a39ad64
--- /dev/null
+++ b/gen/regenerate-meson
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+REPO_ROOT=$(git rev-parse --show-toplevel)
+
+# Find sdbus++-gen-meson
+# 1. Check $SDBUSPP_GEN_MESON
+# 2. Check in $PATH
+# 3. Check in subprojects/sdbusplus
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ SDBUSPP_GEN_MESON="$(which sdbus++-gen-meson 2> /dev/null)"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ SDBUSPP_GEN_MESON="$REPO_ROOT/subprojects/sdbusplus/tools/sdbus++-gen-meson"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ echo "Cannot find sdbus++-gen-meson ($SDBUSPP_GEN_MESON)."
+ exit 1
+fi
+
+$SDBUSPP_GEN_MESON \
+ --command meson \
+ --directory "$REPO_ROOT/yaml" \
+ --output "$REPO_ROOT/gen"
diff --git a/gen/run-ci b/gen/run-ci
new file mode 100755
index 0000000..d38927a
--- /dev/null
+++ b/gen/run-ci
@@ -0,0 +1,15 @@
+#!/bin/bash
+cd "$(dirname "$0")" || exit
+./regenerate-meson || exit
+rc=0
+git --no-pager diff --exit-code -- . || rc=$?
+untracked="$(git ls-files --others --exclude-standard -- .)" || rc=$?
+if [ -n "$untracked" ]; then
+ echo "Untracked files:" >&2
+ echo "$untracked" >&2
+ rc=1
+fi
+if (( rc != 0 )); then
+ echo "Generated meson files differ from expected values" >&2
+ exit 1
+fi
diff --git a/meson.build b/meson.build
index 46b90af..7ec6d03 100644
--- a/meson.build
+++ b/meson.build
@@ -6,7 +6,7 @@
'warning_level=3',
'werror=true',
'cpp_std=c++20',
- 'buildtype=debugoptimized'
+ 'buildtype=debugoptimized',
]
)