Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / sw / switch-to-configuration-ng / build.rs
blob41fed3086e690a741c810481a23fbc47cefb251c
1 use std::io::Write;
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 {
7             methodtype: None,
8             connectiontype: dbus_codegen::ConnectionType::Blocking,
9             ..Default::default()
10         },
11     )
12     .unwrap()
15 fn main() {
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();