entity-manager: Add meson option to cache config

For the development use-case configuration is often changed and the
general expectation is for a service to re-parse it's configuration when
it is restarted.

Add a meson option which controls if the configuration (usually in
/var/configuration/system.json) is cached there, or not cached at all.

The new meson option is 'new-device-detection' and by
default it is true, so there is no behavior change when it is not
configured.

Tested: on Tyan S5549 board.
The configuration is cached when the option is left as default and the
configuration is not written to cache when it is set to false.

```
Jan 21 15:50:22 s5549-bmc-a0423f63b4a5 systemd[1]: Starting Entity Manager...
Jan 21 15:50:22 s5549-bmc-a0423f63b4a5 systemd[1]: Started Entity Manager.
Jan 21 15:50:35 s5549-bmc-a0423f63b4a5 entity-manager[32126]: Inventory Added: Supermicro PWS 920P SQ 1
Jan 21 15:50:35 s5549-bmc-a0423f63b4a5 entity-manager[32126]: Inventory Added: MBX 1.60 Chassis
Jan 21 15:50:35 s5549-bmc-a0423f63b4a5 entity-manager[32126]: Inventory Added: Tyan S5549 Baseboard
```

The cache directory now only contains the 'version' file which is
separate from the caching concern, and not affected by this patch.

```
ls -l /var/configuration/
-rw-r--r--    1 root     root            10 Jan 16 11:50 version
```

Change-Id: I584d87c549d3115da04b464702c7fda8ee7720ed
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/meson.options b/meson.options
index d53e7d6..8cdd903 100644
--- a/meson.options
+++ b/meson.options
@@ -47,3 +47,9 @@
     value: true,
     description: 'Build gpio presence daemon',
 )
+option(
+    'new-device-detection',
+    type: 'boolean',
+    value: true,
+    description: 'Cache the current configuration to support new-device detection. This option can be set to false for development, which will force re-parsing of configuration.',
+)
diff --git a/src/entity_manager/configuration.cpp b/src/entity_manager/configuration.cpp
index 9463133..7532fc1 100644
--- a/src/entity_manager/configuration.cpp
+++ b/src/entity_manager/configuration.cpp
@@ -181,6 +181,11 @@
 
 bool writeJsonFiles(const nlohmann::json& systemConfiguration)
 {
+    if (!EM_CACHE_CONFIGURATION)
+    {
+        return true;
+    }
+
     std::filesystem::create_directory(configurationOutDir);
     std::ofstream output(currentConfiguration);
     if (!output.good())
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index 3835cc1..1511662 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -566,7 +566,7 @@
 
 void EntityManager::handleCurrentConfigurationJson()
 {
-    if (em_utils::fwVersionIsSame())
+    if (EM_CACHE_CONFIGURATION && em_utils::fwVersionIsSame())
     {
         if (std::filesystem::is_regular_file(currentConfiguration))
         {
diff --git a/src/entity_manager/log_device_inventory.cpp b/src/entity_manager/log_device_inventory.cpp
index 02a888d..5a8a918 100644
--- a/src/entity_manager/log_device_inventory.cpp
+++ b/src/entity_manager/log_device_inventory.cpp
@@ -9,6 +9,10 @@
 
 void logDeviceAdded(const nlohmann::json& record)
 {
+    if (!EM_CACHE_CONFIGURATION)
+    {
+        return;
+    }
     if (!deviceHasLogging(record))
     {
         return;
diff --git a/src/entity_manager/meson.build b/src/entity_manager/meson.build
index 0ea941a..1fe9b08 100644
--- a/src/entity_manager/meson.build
+++ b/src/entity_manager/meson.build
@@ -6,6 +6,9 @@
     cpp_args_em += ['-DENABLE_RUNTIME_VALIDATE_JSON=false']
 endif
 
+allowed = get_option('new-device-detection')
+cpp_args_em += '-DEM_CACHE_CONFIGURATION=' + allowed.to_string()
+
 em_deps = [boost, nlohmann_json_dep, phosphor_logging_dep, sdbusplus, valijson]
 
 entity_manager_lib = static_library(