button-handler: use sdeventplus loop

Use the sdeventplus event loop so that an upcoming commit can make use
of sdeventplus timers.

Change-Id: I596ee36141f16ceb5e95078bad9fbe6a12c832a6
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meson.build b/meson.build
index 4d1d370..dc55722 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,7 @@
 )
 
 sdbusplus_dep = dependency('sdbusplus')
+sdeventplus_dep = dependency('sdeventplus')
 phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
 phosphor_logging_dep = dependency('phosphor-logging')
 gpioplus_dep = dependency('gpioplus')
@@ -59,6 +60,7 @@
     phosphor_logging_dep,
     nlohmann_json_dep,
     gpioplus_dep,
+    sdeventplus_dep,
 ]
 
 sources_buttons = [
diff --git a/src/button_handler_main.cpp b/src/button_handler_main.cpp
index e71f8e4..7c21fe9 100644
--- a/src/button_handler_main.cpp
+++ b/src/button_handler_main.cpp
@@ -1,15 +1,15 @@
 #include "button_handler.hpp"
 
+#include <sdeventplus/event.hpp>
+
 int main(void)
 {
     auto bus = sdbusplus::bus::new_default();
+    auto event = sdeventplus::Event::get_default();
+
+    bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
 
     phosphor::button::Handler handler{bus};
 
-    while (true)
-    {
-        bus.process_discard();
-        bus.wait();
-    }
-    return 0;
+    return event.loop();
 }
diff --git a/subprojects/sdeventplus.wrap b/subprojects/sdeventplus.wrap
new file mode 100644
index 0000000..f871ac0
--- /dev/null
+++ b/subprojects/sdeventplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdeventplus.git
+revision = HEAD
+
+[provide]
+sdeventplus = sdeventplus_dep