Refactor the way device backends are built and registered
ClosedPublic

Authored by pino on Jan 5 2019, 4:19 PM.

Details

Summary

Currently, the bits of information of each device backend (e.g. udev,
upower, etc) are spread in different files:

  • their sources in each CMakeLists.txt
  • their libraries in the CMakeLists.txt that assembles the devices part of libKF5Solid
  • their cmake bits in different places

Also, the logic for building the backends in the library, and then
registering them in the DeviceManager, are repeated as cmake, and C++
bits, with small differences between them.

To overcome these limitations, introduce a set of cmake macros, and
functions to deal with the addition of a device backend:

  • a single place, in the top-level CMakeLists.txt, determine which backends are built
  • the CMakeLists.txt of each backend has just their sources (with no paths), and their libraries needed too
  • the cmake bits create a config-backends.h file with the #define's of the enabled backends
  • the cmake bits set cmake variables, so other cmake bits can perform other operations depending whether a backend is built
  • the backends are registered in the DeviceManager depending solely on the fact that they are built
  • there is a new cmake option() variable to disable the build of a backend
  • the cmake feature_info stuff is used to show which backends are enabled, in a more visibile way
Test Plan
  • build solid
  • check that the enabled backends are the same as before (see the list in the cmake output for enabled features)
  • check that the reported devices are the same as before

Diff Detail

Repository
R245 Solid
Branch
cmake-backends-refactor (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 10415
Build 10433: arc lint + arc unit
pino created this revision.Jan 5 2019, 4:19 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 5 2019, 4:19 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
pino requested review of this revision.Jan 5 2019, 4:19 PM
pino added a comment.Jan 5 2019, 4:23 PM

This is tested so far only on Linux, where the cmake output for the device backends is:

-- The following features have been enabled:

 * fakehw, Solid device 'fakehw' backend.
 * udev, Solid device 'udev' backend.
 * udisks2, Solid device 'udisks2' backend.
 * fstab, Solid device 'fstab' backend.
 * upower, Solid device 'upower' backend.

People working on FreeBSD/macOS/Windows: can you please give this a try? Thanks.

apol added a subscriber: apol.Jan 29 2019, 12:17 PM

Looks good to me. +1

pino updated this revision to Diff 51891.Feb 17 2019, 7:37 AM

Rebased on master.

pino updated this revision to Diff 51892.Feb 17 2019, 7:38 AM

Hopefully rebase on master.

Restricted Application removed a subscriber: Frameworks. · View Herald TranscriptFeb 17 2019, 7:54 AM
pino updated this revision to Diff 55373.Apr 3 2019, 9:00 PM

Rebase on master.

pino added a comment.Apr 3 2019, 9:52 PM

BTW if nobody will comment on this within one month, I will commit it as-is.

4 months without a review will be enough, considering also other reviews for Solid got comments/approvals.

This revision was not accepted when it landed; it landed in state Needs Review.May 11 2019, 10:00 AM
This revision was automatically updated to reflect the committed changes.