control: Split JSON and YAML based binaries

Effectively split the binary built for JSON based configurations from
YAML based configurations. Since each will have objects of the same
name, this split is necessary in order to keep the functional
differences apart while keeping the same object names since the JSON
based objects that are created will eventually replace the others.

Change-Id: I937606781fbfa5d23607f81c0fd445289f2bd036
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/Makefile.am b/control/Makefile.am
index f559a82..8367952 100644
--- a/control/Makefile.am
+++ b/control/Makefile.am
@@ -5,15 +5,7 @@
 	phosphor-fan-control
 
 phosphor_fan_control_SOURCES = \
-	argument.cpp \
-	fan.cpp \
-	main.cpp \
-	manager.cpp \
-	utility.cpp \
-	preconditions.cpp \
-	actions.cpp \
-	triggers.cpp \
-	zone.cpp
+	main.cpp
 
 phosphor_fan_control_LDADD = \
 	-lstdc++fs \
@@ -32,6 +24,8 @@
 
 if WANT_JSON_CONTROL
 phosphor_fan_control_SOURCES += \
+	fan.cpp \
+	zone.cpp \
 	json_parser.cpp \
 	json/manager.cpp \
 	json/profile.cpp \
@@ -41,6 +35,15 @@
 	json/event.cpp \
 	json/actions/default_floor.cpp
 else
+phosphor_fan_control_SOURCES += \
+	argument.cpp \
+	fan.cpp \
+	manager.cpp \
+	utility.cpp \
+	preconditions.cpp \
+	actions.cpp \
+	triggers.cpp \
+	zone.cpp
 BUILT_SOURCES = fan_zone_defs.cpp
 nodist_phosphor_fan_control_SOURCES = \
 	fan_zone_defs.cpp
diff --git a/control/main.cpp b/control/main.cpp
index 98edfb9..9170baf 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -13,12 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "config.h"
+
+#ifndef CONTROL_USE_JSON
 #include "argument.hpp"
 #include "manager.hpp"
-#include "sdbusplus.hpp"
-#ifdef CONTROL_USE_JSON
+#else
 #include "json/manager.hpp"
 #endif
+#include "sdbusplus.hpp"
 
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
diff --git a/control/manager.cpp b/control/manager.cpp
index 053861b..8109367 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -19,9 +19,6 @@
 
 #include "sdbusplus.hpp"
 #include "utility.hpp"
-#ifdef CONTROL_USE_JSON
-#include "json_parser.hpp"
-#endif
 
 #include <unistd.h>
 
@@ -91,20 +88,7 @@
 {
     // Create the appropriate Zone objects based on the
     // actual system configuration.
-#ifdef CONTROL_USE_JSON
-    for (auto& group : getZoneGroups(bus))
-    {
-        // Create a Zone object for each zone in the group
-        for (auto& z : std::get<zoneListPos>(group))
-        {
-            fs::path path{CONTROL_OBJPATH};
-            path /= std::to_string(std::get<zoneNumPos>(z));
-            _zones.emplace(
-                std::get<zoneNumPos>(z),
-                std::make_unique<Zone>(mode, _bus, path.string(), event, z));
-        }
-    }
-#else
+
     // Find the 1 ZoneGroup that meets all of its conditions
     for (auto& group : _zoneLayouts)
     {
@@ -130,7 +114,6 @@
             break;
         }
     }
-#endif
 
     if (mode == Mode::control)
     {
@@ -144,11 +127,7 @@
     {
         z.second->setFullSpeed();
     }
-#ifdef CONTROL_USE_JSON
-    auto delay = getPowerOnDelay(_bus, event);
-#else
     auto delay = _powerOnDelay;
-#endif
     while (delay > 0)
     {
         delay = sleep(delay);
diff --git a/control/manager.hpp b/control/manager.hpp
index 496b343..bb46a41 100644
--- a/control/manager.hpp
+++ b/control/manager.hpp
@@ -1,7 +1,5 @@
 #pragma once
 
-#include "config.h"
-
 #include "types.hpp"
 #include "zone.hpp"
 
@@ -67,7 +65,7 @@
      * The fan zones in the system
      */
     ZoneMap _zones;
-#ifndef CONTROL_USE_JSON
+
     /**
      * The fan zone layout for the system.
      * This is generated data.
@@ -80,7 +78,6 @@
      * to give them a chance to get there.
      */
     static const unsigned int _powerOnDelay;
-#endif
 };
 
 } // namespace control