File: build.rs

package info (click to toggle)
rust-rsop 0.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: makefile: 16
file content (58 lines) | stat: -rw-r--r-- 1,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
struct Version {
    name: &'static str,
}

impl sop::ops::Version<'_> for Version {
    fn frontend(&self) -> sop::Result<sop::ops::VersionInfo> {
        Ok(sop::ops::VersionInfo {
            name: self.name.into(),
            version: env!("CARGO_PKG_VERSION").into(),
        })
    }
    fn backend(&self) -> sop::Result<sop::ops::VersionInfo> {
        todo!()
    }
    fn extended(&self) -> sop::Result<String> {
        todo!()
    }
}

fn main() {
    #[cfg(any(feature = "cli", feature = "cliv"))]
    {
        #[allow(dead_code)]
        let outdir = std::env::var_os("CARGO_TARGET_DIR")
            .or(std::env::var_os("OUT_DIR"))
            .expect("cargo to set OUT_DIR");

        #[cfg(feature = "cli")]
        {
            sop::cli::write_shell_completions2(sop::cli::Variant::Full, "rsop", &outdir).unwrap();
            sop::cli::write_man_pages(
                sop::cli::Variant::Full,
                &Version { name: "rsop" },
                std::env::var_os("CARGO_PKG_AUTHORS")
                    .unwrap()
                    .to_str()
                    .unwrap(),
                &outdir,
            )
            .unwrap();
        }
        #[cfg(all(feature = "cliv", not(feature = "cli")))]
        {
            sop::cli::write_shell_completions2(sop::cli::Variant::Verification, "rsopv", &outdir)
                .unwrap();
            sop::cli::write_man_pages(
                sop::cli::Variant::Verification,
                &Version { name: "rsopv" },
                std::env::var_os("CARGO_PKG_AUTHORS")
                    .unwrap()
                    .to_str()
                    .unwrap(),
                &outdir,
            )
            .unwrap();
        }
    }
}