kcsbridge: Daemon rewrite

This focuses on improving compile time, output size, and correctness
of command handling. Notably, it adds the ability for the host to cancel
outstanding IPMI calls when the host decides they should time out. It
ensures that canceled calls do not end up writing over the response for
an incoming request. Since the host can now cancel calls, we remove
internal DBus timeouts and instead require the host to drive any timeout
logic it desires for communications. This gives the host more control
and better adheres to the wishes of the specification.

Change-Id: I526169253931b9bcc4910afa0b54b304d4a9bef3
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/meson.build b/src/meson.build
index 7d57e5a..68b6f9a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,35 +1,49 @@
-# CLI11 might not have a pkg-config. It is header only so just make
-# sure we can access the needed symbols from the header.
-cli11_dep = dependency('cli11', required: false)
-has_cli11 = meson.get_compiler('cpp').has_header_symbol(
-  'CLI/CLI.hpp',
-  'CLI::App',
-  dependencies: cli11_dep,
-  required: false)
-assert(has_cli11, 'CLI11 is required')
+headers = include_directories('.')
+
+fmt_dep = dependency('fmt', required: false)
+if not fmt_dep.found()
+  fmt_opts = import('cmake').subproject_options()
+  fmt_opts.add_cmake_defines({
+    'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
+    'MASTER_PROJECT': 'OFF',
+  })
+  fmt_proj = import('cmake').subproject(
+    'fmt',
+    options: fmt_opts,
+    required: false)
+  assert(fmt_proj.found(), 'fmtlib is required')
+  fmt_dep = fmt_proj.dependency('fmt')
+endif
+
+
+deps = [
+  fmt_dep,
+  dependency('stdplus', fallback: ['stdplus', 'stdplus_dep']),
+  dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep']),
+]
+
+lib = static_library(
+  'kcsbridged',
+  'args.cpp',
+  'cmd.cpp',
+  'server.cpp',
+  include_directories: headers,
+  implicit_include_directories: false,
+  dependencies: deps)
+
+dep = declare_dependency(
+  dependencies: deps,
+  include_directories: headers,
+  link_with: lib)
 
 kcsbridged = executable(
   'kcsbridged',
-  'kcsbridged.cpp',
+  'main.cpp',
   implicit_include_directories: false,
   dependencies: [
-    dependency(
-      'boost',
-      modules: [
-        'coroutine',
-        'context',
-      ],
-    ),
-    cli11_dep,
-    dependency('phosphor-logging'),
-    dependency('sdbusplus'),
-  ],
-  cpp_args: [
-    '-DBOOST_ASIO_DISABLE_THREADS',
-    '-DBOOST_ALL_NO_LIB',
-    '-DBOOST_SYSTEM_NO_DEPRECATED',
-    '-DBOOST_ERROR_CODE_HEADER_ONLY',
-    '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
+    dep,
+    dependency('sdeventplus', fallback: ['sdeventplus', 'sdeventplus_dep']),
+    dependency('libsystemd'),
   ],
   install: true,
   install_dir: get_option('libexecdir'))