3 fn code_for_dbus_xml(xml: impl AsRef<std::path::Path>) -> String {
4 dbus_codegen::generate(
5 &std::fs::read_to_string(xml).unwrap(),
6 &dbus_codegen::GenOpts {
8 connectiontype: dbus_codegen::ConnectionType::Blocking,
16 let systemd_dbus_interface_dir = std::env::var("SYSTEMD_DBUS_INTERFACE_DIR").unwrap();
17 let systemd_dbus_interface_dir = std::path::Path::new(systemd_dbus_interface_dir.as_str());
19 let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
21 let systemd_manager_code =
22 code_for_dbus_xml(systemd_dbus_interface_dir.join("org.freedesktop.systemd1.Manager.xml"));
23 let mut file = std::fs::File::create(out_path.join("systemd_manager.rs")).unwrap();
24 file.write_all(systemd_manager_code.as_bytes()).unwrap();
26 let logind_manager_code =
27 code_for_dbus_xml(systemd_dbus_interface_dir.join("org.freedesktop.login1.Manager.xml"));
28 let mut file = std::fs::File::create(out_path.join("logind_manager.rs")).unwrap();
29 file.write_all(logind_manager_code.as_bytes()).unwrap();