treewide: Leverage sdbus++-gen-meson

This makes us more consistent with other projects instead of writing
meson builds for sdbus++ by hand.

Change-Id: I38b69bc67b6a3d80cda1b508a76e106a50d8ab93
Signed-off-by: Willam A. Kennington III <wak@google.com>
diff --git a/test/gen/meson.build b/test/gen/meson.build
new file mode 100644
index 0000000..2756633
--- /dev/null
+++ b/test/gen/meson.build
@@ -0,0 +1,14 @@
+# Generated file; do not modify.
+sdbuspp_gen_meson_ver = run_command(
+    sdbuspp_gen_meson_prog,
+    '--version',
+).stdout().strip().split('\n')[0]
+
+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 4", got:',
+        sdbuspp_gen_meson_ver
+    )
+endif
+
diff --git a/test/gen/regenerate-meson b/test/gen/regenerate-meson
new file mode 100755
index 0000000..235d551
--- /dev/null
+++ b/test/gen/regenerate-meson
@@ -0,0 +1,4 @@
+#!/bin/bash
+cd "$(dirname "$0")" || exit
+export PATH="${PWD}/../../tools:${PATH}"
+exec sdbus++-gen-meson --command meson --directory ../yaml --output .
diff --git a/test/gen/run-ci b/test/gen/run-ci
new file mode 100755
index 0000000..0a248a0
--- /dev/null
+++ b/test/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/test/gen/server/Test/meson.build b/test/gen/server/Test/meson.build
new file mode 100644
index 0000000..7a1d3b7
--- /dev/null
+++ b/test/gen/server/Test/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'server/Test__cpp'.underscorify(),
+    input: [ '../../../yaml/server/Test.interface.yaml',  ],
+    output: [ 'server.cpp', 'server.hpp', 'client.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../yaml',
+        'server/Test',
+    ],
+)
+
diff --git a/test/gen/server/meson.build b/test/gen/server/meson.build
new file mode 100644
index 0000000..6ab2512
--- /dev/null
+++ b/test/gen/server/meson.build
@@ -0,0 +1,16 @@
+# Generated file; do not modify.
+subdir('Test')
+generated_others += custom_target(
+    'server/Test__markdown'.underscorify(),
+    input: [ '../../yaml/server/Test.interface.yaml',  ],
+    output: [ 'Test.md' ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../yaml',
+        'server/Test',
+    ],
+)
+
diff --git a/test/meson.build b/test/meson.build
index 64dbc0e..4fa39d2 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -81,23 +81,34 @@
     ),
 )
 
-subdir('server/Test')
+generated_sources = []
+generated_others = []
+subdir('gen')
+subdir('gen/server')
+
+server_test_pre = declare_dependency(
+    include_directories: include_directories('gen'),
+    dependencies: sdbusplus_dep)
+
 server_test_lib = static_library(
     'server-test',
-    server_test_sources,
-    dependencies: sdbusplus_dep,
-)
-server_test_hpp = []
-foreach f : server_test_sources.to_list()
-    if f.full_path().endswith('.hpp')
-        server_test_hpp += f
-    endif
+    generated_sources,
+    implicit_include_directories: false,
+    dependencies: server_test_pre)
+
+generated_sources_header = []
+foreach s : generated_sources
+    foreach f : s.to_list()
+        if f.full_path().endswith('.hpp')
+            generated_sources_header += f
+        endif
+    endforeach
 endforeach
+
 server_test_dep = declare_dependency(
-    link_with: server_test_lib,
-    dependencies: sdbusplus_dep,
-    sources: server_test_hpp,
-)
+  sources: generated_sources_header,
+  link_with: server_test_lib,
+  dependencies: server_test_pre)
 
 test(
     'test-server',
diff --git a/test/server/Test/meson.build b/test/server/Test/meson.build
deleted file mode 100644
index 37e56a5..0000000
--- a/test/server/Test/meson.build
+++ /dev/null
@@ -1,13 +0,0 @@
-server_test_sources = custom_target(
-    'server_test__cpp',
-    input: '../Test.interface.yaml',
-    output: [ 'server.cpp', 'server.hpp', 'client.hpp' ],
-    depend_files: sdbusplusplus_depfiles,
-    command: [
-        sdbuspp_gen_meson_prog, '--command', 'cpp',
-        '--output', meson.current_build_dir(),
-        '--tool', sdbusplusplus_prog,
-        '--directory', meson.current_source_dir() / '../..',
-        'server/Test',
-    ],
-)
diff --git a/test/server/Test.interface.yaml b/test/yaml/server/Test.interface.yaml
similarity index 100%
rename from test/server/Test.interface.yaml
rename to test/yaml/server/Test.interface.yaml