{"id":18368644,"url":"https://github.com/openbmc/sdbusplus","last_synced_at":"2025-05-16T08:03:19.651Z","repository":{"id":13151940,"uuid":"63798142","full_name":"openbmc/sdbusplus","owner":"openbmc","description":"C++ bindings for systemd dbus APIs","archived":false,"fork":false,"pushed_at":"2025-05-08T19:33:02.000Z","size":5688,"stargazers_count":116,"open_issues_count":26,"forks_count":82,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-05-08T20:32:44.725Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openbmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-07-20T16:46:38.000Z","updated_at":"2025-05-08T19:33:05.000Z","dependencies_parsed_at":"2023-02-17T09:31:06.022Z","dependency_job_id":"2176ddbf-5822-4085-899b-34ab8e6278da","html_url":"https://github.com/openbmc/sdbusplus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fsdbusplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fsdbusplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fsdbusplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fsdbusplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openbmc","download_url":"https://codeload.github.com/openbmc/sdbusplus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493381,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T23:26:50.829Z","updated_at":"2025-05-16T08:03:19.595Z","avatar_url":"https://github.com/openbmc.png","language":"C++","readme":"# sdbusplus\n\nsdbusplus contains two parts:\n\n1. A C++ library (libsdbusplus) for interacting with D-Bus, built on top of the\n   sd-bus library from systemd.\n2. A tool (sdbus++) to generate C++ bindings to simplify the development of\n   D-Bus-based applications.\n\n## Dependencies\n\nThe sdbusplus library requires sd-bus, which is contained in libsystemd.\n\nThe sdbus++ application requires Python 3 and the Python libraries mako and\ninflection.\n\n## Building\n\nThe sdbusplus library is built using meson.\n\n```sh\nmeson build\ncd build\nninja\nninja test\nninja install\n```\n\nOptionally, building the tests and examples can be disabled by passing\n`-Dtests=disabled` and `-Dexamples=disabled` respectively to `meson`.\n\nThe sdbus++ application is installed as a standard Python package using\n`setuptools`.\n\n```sh\ncd tools\n./setup.py install\n```\n\n## C++ library\n\nThe sdbusplus library builds on top of the [sd-bus] library to create a modern\nC++ API for D-Bus. The library attempts to be as lightweight as possible,\nusually compiling to exactly the sd-bus API calls that would have been\nnecessary, while also providing compile-time type-safety and memory leak\nprotection afforded by modern C++ practices.\n\nConsider the following code:\n\n```cpp\nauto b = bus::new_default_system();\nauto m = b.new_method_call(\"org.freedesktop.login1\",\n                           \"/org/freedesktop/login1\",\n                           \"org.freedesktop.login1.Manager\",\n                           \"ListUsers\");\nauto reply = b.call(m);\n\nstd::vector\u003cstd::tuple\u003cuint32_t, std::string, message::object_path\u003e\u003e users;\nreply.read(users);\n    // or\nauto users = reply.unpack\u003c\n    std::vector\u003cstd::tuple\u003cuint32_t, std::string, message::object_path\u003e\u003e\u003e();\n```\n\nIn a few, relatively succinct, C++ lines this snippet will create a D-Bus\nconnection to the system bus, and call the systemd login manager to get a list\nof active users. The message and bus objects are automatically freed when they\nleave scope and the message format strings are generated at compile time based\non the types being read. Compare this to the corresponding server code within\n[logind].\n\nIn general, the library attempts to mimic the naming conventions of the sd-bus\nlibrary: ex. `sd_bus_call` becomes `sdbusplus::bus::call`,\n`sd_bus_get_unique_name` becomes `sdbusplus::bus::get_unique_name`,\n`sd_bus_message_get_signature` becomes `sdbusplus::message::get_signature`, etc.\nThis allows a relatively straight-forward translation back to the sd-bus\nfunctions for looking up the manpage details.\n\n[sd-bus]: http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html\n[logind]:\n  https://github.com/systemd/systemd/blob/d60c527009133a1ed3d69c14b8c837c790e78d10/src/login/logind-dbus.c#L496\n\n## Binding generation tool\n\nsdbusplus also contains a bindings generator tool: `sdbus++`. The purpose of a\nbindings generator is to reduce the boilerplate associated with creating D-Bus\nserver or client applications. When creating a server application, rather than\ncreating sd-bus vtables and writing C-style functions to handle each vtable\ncallback, you can create a small YAML file to define your D-Bus interface and\nthe `sdbus++` tool will create a C++ class that implements your D-Bus interface.\nThis class has a set of virtual functions for each method and property, which\nyou can overload to create your own customized behavior for the interface.\n\nThere are currently two types of YAML files: [interface](docs/yaml/interface.md)\nand [error](docs/yaml/error.md). Interfaces are used to create server and client\nD-Bus interfaces. Errors are used to define C++ exceptions which can be thrown\nand will automatically turn into D-Bus error responses.\n\n[[D-Bus client bindings are not yet implemented.  See openbmc/openbmc#851.]]\n\n### Generating bindings\n\n## How to use tools/sdbus++\n\nThe path of your file will be the interface name. For example, for an interface\n`org.freedesktop.Example`, you would create the files\n`org/freedesktop/Example.interface.yaml` and\n`org/freedesktop/Example.errors.yaml]` for interfaces and errors respectively.\nThese can then be used to generate the server and error bindings:\n\n```sh\nsdbus++ interface server-header org.freedesktop.Example \u003e \\\n    org/freedesktop/Example/server.hpp\nsdbus++ interface server-cpp org.freedesktop.Example \u003e \\\n    org/freedesktop/Example/server.cpp\nsdbus++ error exception-header org.freedesktop.Example \u003e \\\n    org/freedesktop/Example/error.hpp \\\nsdbus++ error exception-cpp org.freedesktop.Example \u003e \\\n    org/freedesktop/Example/error.cpp\n```\n\nMarkdown-based documentation can also be generated from the interface and\nexception files:\n\n```sh\nsdbus++ interface markdown org.freedesktop.Example \u003e \\\n    org/freedesktop/Example.md\nsdbus++ error markdown org.freedesktop.Example \u003e\u003e \\\n    org/freedesktop/Example.md\n```\n\nSee the `example/meson.build` for more details.\n\n## Installing sdbusplus on custom distributions\n\nInstallation of sdbusplus bindings on a custom distribution requires a few\npackages to be installed prior. Although these packages are the same for several\ndistributions the names of these packages do differ. Below are the packages\nneeded for Ubuntu and Fedora.\n\n### Installation on Ubuntu\n\n```sh\nsudo apt install git meson libtool pkg-config g++ libsystemd-dev \\\n    python3 python3-pip python3-yaml python3-mako python3-inflection\n```\n\n### Installation on Fedora\n\n```sh\nsudo dnf install git meson libtool gcc-c++ pkgconfig systemd-devel \\\n    python3 python3-pip python3-yaml python3-mako\n```\n\nInstall the inflection package using the pip utility (on Fedora)\n\n```sh\npip3 install inflection\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Fsdbusplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenbmc%2Fsdbusplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Fsdbusplus/lists"}