sdbus++: add common header file

There are some items generated under server and client which are
overlapping and some currently in server that will also be needed
for async bindings.  Create a common header file that they can
all include in order to reduce the content generated across all these
types.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Id7af8542613503dbd745158c89892ca252eadf5a
diff --git a/example/gen/meson.build b/example/gen/meson.build
index a7da0a7..23394ac 100644
--- a/example/gen/meson.build
+++ b/example/gen/meson.build
@@ -5,10 +5,10 @@
     check: true,
 ).stdout().strip().split('\n')[0]
 
-if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 5'
+if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 6'
     warning('Generated meson files from wrong version of sdbus++-gen-meson.')
     warning(
-        'Expected "sdbus++-gen-meson version 5", got:',
+        'Expected "sdbus++-gen-meson version 6", got:',
         sdbuspp_gen_meson_ver
     )
 endif
diff --git a/example/gen/net/poettering/Calculator/meson.build b/example/gen/net/poettering/Calculator/meson.build
index 6b469e6..e906ab2 100644
--- a/example/gen/net/poettering/Calculator/meson.build
+++ b/example/gen/net/poettering/Calculator/meson.build
@@ -2,7 +2,7 @@
 generated_sources += custom_target(
     'net/poettering/Calculator__cpp'.underscorify(),
     input: [ '../../../../yaml/net/poettering/Calculator.interface.yaml',  ],
-    output: [ 'error.cpp', 'error.hpp', 'server.cpp', 'server.hpp', 'client.hpp',  ],
+    output: [ 'error.cpp', 'error.hpp', 'common.hpp', 'server.cpp', 'server.hpp', 'client.hpp',  ],
     depend_files: sdbusplusplus_depfiles,
     command: [
         sdbuspp_gen_meson_prog, '--command', 'cpp',
diff --git a/test/gen/meson.build b/test/gen/meson.build
index a7da0a7..23394ac 100644
--- a/test/gen/meson.build
+++ b/test/gen/meson.build
@@ -5,10 +5,10 @@
     check: true,
 ).stdout().strip().split('\n')[0]
 
-if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 5'
+if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 6'
     warning('Generated meson files from wrong version of sdbus++-gen-meson.')
     warning(
-        'Expected "sdbus++-gen-meson version 5", got:',
+        'Expected "sdbus++-gen-meson version 6", got:',
         sdbuspp_gen_meson_ver
     )
 endif
diff --git a/test/gen/server/Test/meson.build b/test/gen/server/Test/meson.build
index 7a1d3b7..829f238 100644
--- a/test/gen/server/Test/meson.build
+++ b/test/gen/server/Test/meson.build
@@ -2,7 +2,7 @@
 generated_sources += custom_target(
     'server/Test__cpp'.underscorify(),
     input: [ '../../../yaml/server/Test.interface.yaml',  ],
-    output: [ 'server.cpp', 'server.hpp', 'client.hpp',  ],
+    output: [ 'common.hpp', 'server.cpp', 'server.hpp', 'client.hpp',  ],
     depend_files: sdbusplusplus_depfiles,
     command: [
         sdbuspp_gen_meson_prog, '--command', 'cpp',
diff --git a/tools/meson.build b/tools/meson.build
index f260f61..f7406c9 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,8 +1,8 @@
 sdbusplusplus_depfiles = files(
   'sdbus++',
+  'sdbusplus/__init__.py',
   'sdbusplus/enum.py',
   'sdbusplus/error.py',
-  'sdbusplus/__init__.py',
   'sdbusplus/interface.py',
   'sdbusplus/main.py',
   'sdbusplus/method.py',
@@ -14,6 +14,7 @@
   'sdbusplus/templates/error.hpp.mako',
   'sdbusplus/templates/error.md.mako',
   'sdbusplus/templates/interface.client.hpp.mako',
+  'sdbusplus/templates/interface.common.hpp.mako',
   'sdbusplus/templates/interface.md.mako',
   'sdbusplus/templates/interface.server.cpp.mako',
   'sdbusplus/templates/interface.server.hpp.mako',
diff --git a/tools/sdbus++-gen-meson b/tools/sdbus++-gen-meson
index 7f85514..9dcae96 100755
--- a/tools/sdbus++-gen-meson
+++ b/tools/sdbus++-gen-meson
@@ -36,7 +36,7 @@
 ## if a repository contains old copies of the generated meson.build files and
 ## needs an update.  We should increment the version number whenever the
 ## resulting meson.build would change.
-tool_version="sdbus++-gen-meson version 5"
+tool_version="sdbus++-gen-meson version 6"
 function show_version() {
     echo "${tool_version}"
 }
@@ -188,6 +188,7 @@
                 ;;
 
             interface.yaml)
+                outputs="${outputs}'common.hpp', "
                 outputs="${outputs}'server.cpp', 'server.hpp', "
                 outputs="${outputs}'client.hpp', "
                 ;;
@@ -302,6 +303,7 @@
     intf="${1//\//.}"
 
     if [[ -e "${rootdir}/$1.interface.yaml" ]]; then
+        ${sdbusppcmd} interface common-header "${intf}" > "${outputdir}/common.hpp"
         ${sdbusppcmd} interface server-header "${intf}" > "${outputdir}/server.hpp"
         ${sdbusppcmd} interface server-cpp "${intf}" > "${outputdir}/server.cpp"
         ${sdbusppcmd} interface client-header "${intf}" > "${outputdir}/client.hpp"
diff --git a/tools/sdbusplus/interface.py b/tools/sdbusplus/interface.py
index c12c5c7..fd5cccb 100644
--- a/tools/sdbusplus/interface.py
+++ b/tools/sdbusplus/interface.py
@@ -54,3 +54,7 @@
     def client_header(self, loader):
         self.typename = "client"
         return self.render(loader, "interface.client.hpp.mako", interface=self)
+
+    def common_header(self, loader):
+        self.typename = "common"
+        return self.render(loader, "interface.common.hpp.mako", interface=self)
diff --git a/tools/sdbusplus/main.py b/tools/sdbusplus/main.py
index e056942..c40cee6 100644
--- a/tools/sdbusplus/main.py
+++ b/tools/sdbusplus/main.py
@@ -11,12 +11,13 @@
 
     valid_types = {"interface": sdbusplus.Interface, "error": sdbusplus.Error}
     valid_processes = {
-        "markdown": "markdown",
-        "server-header": "server_header",
-        "server-cpp": "server_cpp",
-        "exception-header": "exception_header",
-        "exception-cpp": "exception_cpp",
         "client-header": "client_header",
+        "common-header": "common_header",
+        "exception-cpp": "exception_cpp",
+        "exception-header": "exception_header",
+        "markdown": "markdown",
+        "server-cpp": "server_cpp",
+        "server-header": "server_header",
     }
 
     parser = argparse.ArgumentParser(description="Process sdbus++ YAML files.")
diff --git a/tools/sdbusplus/templates/interface.common.hpp.mako b/tools/sdbusplus/templates/interface.common.hpp.mako
new file mode 100644
index 0000000..cc93d94
--- /dev/null
+++ b/tools/sdbusplus/templates/interface.common.hpp.mako
@@ -0,0 +1,11 @@
+#pragma once
+
+namespace sdbusplus::common::${interface.cppNamespace()}
+{
+
+struct ${interface.classname}
+{
+    static constexpr auto interface = "${interface.name}";
+};
+
+} // sdbusplus::common::${interface.cppNamespace()}