Add option to disable getActiveSoftwareVersionInfo

Add metion option `get-dbus-active-software` to allow us to disable
calling getActiveSoftwareVersionInfo when we expect it to be failing and
depend completely on dev_id.json for the version.

Tested:
Build with both options and works fine.

Change-Id: Icad3ad72521af35370e74cea36aa12085448dc53
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/apphandler.cpp b/apphandler.cpp
index d0d77f8..6591afa 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -619,8 +619,6 @@
               >
     ipmiAppGetDeviceId([[maybe_unused]] ipmi::Context::ptr ctx)
 {
-    int r = -1;
-    Revision rev = {0, 0, 0, 0};
     static struct
     {
         uint8_t id;
@@ -633,13 +631,17 @@
         uint32_t aux;
     } devId;
     static bool dev_id_initialized = false;
-    static bool haveBMCVersion = false;
     static bool defaultActivationSetting = true;
     const char* filename = "/usr/share/ipmi-providers/dev_id.json";
     constexpr auto ipmiDevIdStateShift = 7;
     constexpr auto ipmiDevIdFw1Mask = ~(1 << ipmiDevIdStateShift);
+
+#ifdef GET_DBUS_ACTIVE_SOFTWARE
+    static bool haveBMCVersion = false;
     if (!haveBMCVersion || !dev_id_initialized)
     {
+        int r = -1;
+        Revision rev = {0, 0, 0, 0};
         try
         {
             auto version = getActiveSoftwareVersionInfo(ctx);
@@ -666,6 +668,7 @@
             haveBMCVersion = true;
         }
     }
+#endif
     if (!dev_id_initialized)
     {
         // IPMI Spec version 2.0
diff --git a/meson.build b/meson.build
index 0fbadc3..c3eed2e 100644
--- a/meson.build
+++ b/meson.build
@@ -52,6 +52,14 @@
   ]),
   language : 'cpp')
 
+if not get_option('get-dbus-active-software').disabled()
+  add_project_arguments(
+    cpp.get_supported_arguments([
+      '-DGET_DBUS_ACTIVE_SOFTWARE',
+    ]),
+    language : 'cpp')
+endif
+
 feature_map = {
   'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
   'i2c-whitelist-check'        : '-DENABLE_I2C_WHITELIST_CHECK',
diff --git a/meson_options.txt b/meson_options.txt
index af121c6..24ba60b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -64,3 +64,6 @@
 option('sensor-yaml-gen', type: 'string', value: 'sensor-example.yaml')
 option('invsensor-yaml-gen', type: 'string', value: 'inventory-sensor-example.yaml')
 option('fru-yaml-gen', type: 'string', value: 'fru-read-example.yaml')
+
+# Software Version
+option('get-dbus-active-software', type: 'feature', description: 'Use the  getActiveSoftwareVersionInfo for the BMC version and dev_id.json as backup')