yaml: move to subdirectory

A pending sdbusplus change (I38b69bc67b6a3d80cda1b508a76e106a50d8ab93)
is going to require YAML to be in a specific subdirectory and not in
the root.  Move here in prep for that change.

Also add in the regenerate-meson script as a helper to regenerate
the sdbusplus meson files for this repository.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I2c9e74b85550e3e8f0f5cb56a82e85c5b13c6d00
diff --git a/gen/meson.build b/gen/meson.build
index af850f2..2756633 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 2'
+if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 4'
     warning('Generated meson files from wrong version of sdbus++-gen-meson.')
     warning(
-        'Expected "sdbus++-gen-meson version 2", got:',
+        'Expected "sdbus++-gen-meson version 4", got:',
         sdbuspp_gen_meson_ver
     )
 endif
diff --git a/gen/org/open_power/Host/Boot/meson.build b/gen/org/open_power/Host/Boot/meson.build
index 718b2c2..6a86ba3 100644
--- a/gen/org/open_power/Host/Boot/meson.build
+++ b/gen/org/open_power/Host/Boot/meson.build
@@ -1,13 +1,14 @@
 # Generated file; do not modify.
 generated_sources += custom_target(
     'org/open_power/Host/Boot__cpp'.underscorify(),
-    input: [ meson.project_source_root() / 'org/open_power/Host/Boot.errors.yaml',  ],
+    input: [ '../../../../../yaml/org/open_power/Host/Boot.errors.yaml',  ],
     output: [ 'error.cpp', 'error.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
     command: [
         sdbuspp_gen_meson_prog, '--command', 'cpp',
         '--output', meson.current_build_dir(),
         '--tool', sdbusplusplus_prog,
-        '--directory', meson.project_source_root(),
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
         'org/open_power/Host/Boot',
     ],
 )
diff --git a/gen/org/open_power/Host/meson.build b/gen/org/open_power/Host/meson.build
index fed2c12..4c34ff4 100644
--- a/gen/org/open_power/Host/meson.build
+++ b/gen/org/open_power/Host/meson.build
@@ -2,15 +2,15 @@
 subdir('Boot')
 generated_others += custom_target(
     'org/open_power/Host/Boot__markdown'.underscorify(),
-    input: [ meson.project_source_root() / 'org/open_power/Host/Boot.errors.yaml',  ],
+    input: [ '../../../../yaml/org/open_power/Host/Boot.errors.yaml',  ],
     output: [ 'Boot.md' ],
+    depend_files: sdbusplusplus_depfiles,
     command: [
         sdbuspp_gen_meson_prog, '--command', 'markdown',
         '--output', meson.current_build_dir(),
         '--tool', sdbusplusplus_prog,
-        '--directory', meson.project_source_root(),
+        '--directory', meson.current_source_dir() / '../../../../yaml',
         'org/open_power/Host/Boot',
     ],
-    build_by_default: true,
 )
 
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..dba8109
--- /dev/null
+++ b/gen/run-ci
@@ -0,0 +1,16 @@
+#!/bin/bash
+cd "$(dirname "$0")" || exit
+find . -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \;
+./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 4f3415c..6006b8c 100644
--- a/meson.build
+++ b/meson.build
@@ -13,15 +13,13 @@
 
 systemd = dependency('systemd', required : true)
 
-sdbusplus = dependency(
-    'sdbusplus',
-    fallback: [
-        'sdbusplus',
-        'sdbusplus_dep'
-    ]
-)
-sdbusplusplus_prog = find_program('sdbus++', required : true)
-sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', required : true)
+sdbusplus_dep = dependency('sdbusplus')
+sdbusplusplus_prog = find_program('sdbus++')
+sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
+sdbusplusplus_depfiles = files()
+if sdbusplus_dep.type_name() == 'internal'
+    sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles')
+endif
 
 phosphorlogging = dependency(
     'phosphor-logging',
@@ -100,7 +98,7 @@
 
 deps = [
     systemd,
-    sdbusplus,
+    sdbusplus_dep,
     phosphorlogging,
     fmt_dep,
     extra_deps
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
index d470130..edd9a31 100644
--- a/subprojects/sdbusplus.wrap
+++ b/subprojects/sdbusplus.wrap
@@ -1,3 +1,7 @@
 [wrap-git]
 url = https://github.com/openbmc/sdbusplus.git
 revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep
+program_names = sdbus++, sdbus++-gen-meson
diff --git a/org/open_power/Host/Boot.errors.yaml b/yaml/org/open_power/Host/Boot.errors.yaml
similarity index 100%
rename from org/open_power/Host/Boot.errors.yaml
rename to yaml/org/open_power/Host/Boot.errors.yaml