fw-update: Break circular dependency
```
In file included from ../pldmd/pldmd.cpp:2:
In file included from ../common/flight_recorder.hpp:3:
In file included from ../common/utils.hpp:15:
In file included from ../subprojects/nlohmann_json/single_include/nlohmann/json.hpp:29:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/memory:78:
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:91:16: error: invalid application of 'sizeof' to an incomplete type 'pldm::fw_update::Activation'
91 | static_assert(sizeof(_Tp)>0,
| ^~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:398:4: note: in instantiation of member function 'std::default_delete<pldm::fw_update::Activation>::opera
tor()' requested here
398 | get_deleter()(std::move(__ptr));
| ^
../fw-update/update_manager.hpp:46:14: note: in instantiation of member function 'std::unique_ptr<pldm::fw_update::Activation>::~unique_ptr' requested here
46 | explicit UpdateManager(
| ^
../fw-update/update_manager.hpp:33:7: note: forward declaration of 'pldm::fw_update::Activation'
33 | class Activation;
| ^
In file included from ../pldmd/pldmd.cpp:2:
In file included from ../common/flight_recorder.hpp:3:
In file included from ../common/utils.hpp:15:
In file included from ../subprojects/nlohmann_json/single_include/nlohmann/json.hpp:29:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/memory:78:
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:91:16: error: invalid application of 'sizeof' to an incomplete type 'pldm::fw_update::ActivationProgress'
91 | static_assert(sizeof(_Tp)>0,
| ^~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:398:4: note: in instantiation of member function 'std::default_delete<pldm::fw_update::ActivationProgress
>::operator()' requested here
398 | get_deleter()(std::move(__ptr));
| ^
../fw-update/update_manager.hpp:46:14: note: in instantiation of member function 'std::unique_ptr<pldm::fw_update::ActivationProgress>::~unique_ptr' requested here
46 | explicit UpdateManager(
| ^
../fw-update/update_manager.hpp:34:7: note: forward declaration of 'pldm::fw_update::ActivationProgress'
34 | class ActivationProgress;
| ^
```
Change-Id: I2820cbe134d1f37a43e6a5056eed87dde6e63b08
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/fw-update/activation.cpp b/fw-update/activation.cpp
new file mode 100644
index 0000000..d39cf9f
--- /dev/null
+++ b/fw-update/activation.cpp
@@ -0,0 +1,35 @@
+#include "fw-update/activation.hpp"
+
+#include "fw-update/update_manager.hpp"
+
+namespace pldm
+{
+namespace fw_update
+{
+
+ActivationIntf::Activations
+ Activation::activation(ActivationIntf::Activations value)
+{
+ if (value == ActivationIntf::Activations::Activating)
+ {
+ deleteImpl.reset();
+ updateManager->activatePackage();
+ }
+ else if (value == ActivationIntf::Activations::Active ||
+ value == ActivationIntf::Activations::Failed)
+ {
+ if (!deleteImpl)
+ {
+ deleteImpl = std::make_unique<Delete>(bus, objPath, updateManager);
+ }
+ }
+
+ return ActivationIntf::activation(value);
+}
+
+void Delete::delete_()
+{
+ updateManager->clearActivationInfo();
+}
+} // namespace fw_update
+} // namespace pldm
diff --git a/fw-update/activation.hpp b/fw-update/activation.hpp
index 50a6dbb..4af7c44 100644
--- a/fw-update/activation.hpp
+++ b/fw-update/activation.hpp
@@ -1,7 +1,5 @@
#pragma once
-#include "fw-update/update_manager.hpp"
-
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>
#include <xyz/openbmc_project/Software/Activation/server.hpp>
@@ -15,6 +13,8 @@
namespace fw_update
{
+class UpdateManager;
+
using ActivationIntf = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Software::server::Activation>;
using ActivationProgressIntf = sdbusplus::server::object_t<
@@ -63,10 +63,7 @@
{}
/** @brief Delete the Activation D-Bus object for the FW update package */
- void delete_() override
- {
- updateManager->clearActivationInfo();
- }
+ void delete_() override;
private:
UpdateManager* updateManager;
@@ -104,24 +101,7 @@
/** @brief Overriding Activation property setter function
*/
- Activations activation(Activations value) override
- {
- if (value == Activations::Activating)
- {
- deleteImpl.reset();
- updateManager->activatePackage();
- }
- else if (value == Activations::Active || value == Activations::Failed)
- {
- if (!deleteImpl)
- {
- deleteImpl = std::make_unique<Delete>(bus, objPath,
- updateManager);
- }
- }
-
- return ActivationIntf::activation(value);
- }
+ Activations activation(Activations value) override;
/** @brief Overriding RequestedActivations property setter function
*/
diff --git a/fw-update/test/meson.build b/fw-update/test/meson.build
index 5749e14..5af5dc9 100644
--- a/fw-update/test/meson.build
+++ b/fw-update/test/meson.build
@@ -1,5 +1,6 @@
fw_update_test_src = declare_dependency(
sources: [
+ '../activation.cpp',
'../inventory_manager.cpp',
'../package_parser.cpp',
'../device_updater.cpp',
diff --git a/fw-update/update_manager.hpp b/fw-update/update_manager.hpp
index 780ce49..26a1de9 100644
--- a/fw-update/update_manager.hpp
+++ b/fw-update/update_manager.hpp
@@ -3,6 +3,7 @@
#include "common/instance_id.hpp"
#include "common/types.hpp"
#include "device_updater.hpp"
+#include "fw-update/activation.hpp"
#include "package_parser.hpp"
#include "requester/handler.hpp"
#include "watch.hpp"
@@ -30,9 +31,6 @@
using DeviceUpdaterInfos = std::vector<DeviceUpdaterInfo>;
using TotalComponentUpdates = size_t;
-class Activation;
-class ActivationProgress;
-
class UpdateManager
{
public: