platform-plugins: load plugins

Introduced the "platform-plugins" option to allow gbmcweb load
platform-specific plugins at start-up time. When the option is enabled,
gbmcweb will link with a static library that will be delivered via a
separate recipe.

We will upload an example plugin recipe and plugin repo for reference.

Tested: bmcweb compiles with the platform-plugins option enabled.
Plugins are loaded and behavior of certain routes changed accordingly.

Change-Id: If393d363e8455e7c3750201a1e33794c2c5bad70
Signed-off-by: Nan Zhou <nanzhou@google.com>
diff --git a/meson.build b/meson.build
index 26dbece..f87499c 100644
--- a/meson.build
+++ b/meson.build
@@ -93,6 +93,7 @@
     'static-hosting'                              : '-DBMCWEB_ENABLE_STATIC_HOSTING',
     'vm-websocket'                                : '-DBMCWEB_ENABLE_VM_WEBSOCKET',
     'xtoken-auth'                                 : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION',
+    'platform-plugins'                            : '-DPLATFORM_PLUGINS_ENABLED',
     #'vm-nbdproxy'                                : '-DBMCWEB_ENABLE_VM_NBDPROXY',
   }
 
@@ -391,6 +392,11 @@
     subdir('grpc-redfish')
   endif
 
+  if get_option('platform-plugins').enabled()
+    platform_plugin = dependency('gbmcweb_platform_plugin')
+    bmcweb_dependencies += platform_plugin
+  endif
+
   # Generate the bmcweb executable
   executable(
     'bmcweb',
@@ -473,6 +479,7 @@
     'include/managed_store.hpp',
     'include/managed_store_types.hpp',
     'include/managed_store_clock.hpp',
+    'plugins/interface.hpp',
     'plugins/macros.hpp',
     'redfish-core/include/registries/privilege_registry.hpp',
     'redfish-core/include/utils/dbus_utils.hpp',
diff --git a/meson_options.txt b/meson_options.txt
index 036bafe..2da8b6d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -589,4 +589,12 @@
     type: 'feature',
     value: 'disabled',
     description: 'Install the headers for plugins and do nothing else.'
-)
\ No newline at end of file
+)
+
+option(
+    'platform-plugins',
+    type: 'feature',
+    value: 'disabled',
+    description: '''Enable per platform plugin. This makes bmcweb depend on a
+                    static libary gbmcweb_platform_plugin'''
+)
diff --git a/plugins/interface.hpp b/plugins/interface.hpp
new file mode 100644
index 0000000..9dcf995
--- /dev/null
+++ b/plugins/interface.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+namespace redfish_plugin
+{
+
+void loadPlatformPlugins();
+
+}
\ No newline at end of file
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index 76a9bf0..6d3ac75 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -21,6 +21,7 @@
 #include "user_monitor.hpp"
 #include "vm_websocket.hpp"
 #include "webassets.hpp"
+#include "plugins/interface.hpp"
 
 #include <systemd/sd-daemon.h>
 
@@ -325,6 +326,11 @@
 #endif
 
 #endif
+
+#ifdef PLATFORM_PLUGINS_ENABLED
+    redfish_plugin::loadPlatformPlugins();
+#endif
+
     app.validate();
     app.run();
     io->run();