ptx_builder/executable/
mod.rs1use semver::{Version, VersionReq};
2
3use crate::error::*;
4
5pub mod runner;
6pub use self::runner::{ExecutableRunner, Output};
7
8pub trait Executable {
10 fn get_name(&self) -> String;
12
13 fn get_verification_hint(&self) -> String;
15
16 fn get_version_hint(&self) -> String;
18
19 fn get_required_version(&self) -> Option<VersionReq>;
21
22 fn get_current_version(&self) -> Result<Version>
24 where
25 Self: Sized,
26 {
27 self::runner::parse_executable_version(self)
28 }
29}
30
31pub struct Cargo;
33
34pub struct Linker;
36
37impl Executable for Cargo {
38 fn get_name(&self) -> String {
39 String::from("cargo")
40 }
41
42 fn get_verification_hint(&self) -> String {
43 String::from("Please make sure you have it installed and in PATH")
44 }
45
46 fn get_version_hint(&self) -> String {
47 String::from("Please update Rust and Cargo to latest nightly versions")
48 }
49
50 fn get_required_version(&self) -> Option<VersionReq> {
51 Some(VersionReq::parse(">= 1.34.0-nightly").unwrap())
52 }
53
54 fn get_current_version(&self) -> Result<Version> {
55 self::runner::parse_executable_version(self).map(|mut version| {
59 version.pre = vec![];
60 version
61 })
62 }
63}
64
65impl Executable for Linker {
66 fn get_name(&self) -> String {
67 String::from("rust-ptx-linker")
68 }
69
70 fn get_verification_hint(&self) -> String {
71 String::from("You can install it with: 'cargo install ptx-linker'")
72 }
73
74 fn get_version_hint(&self) -> String {
75 String::from("You can update it with: 'cargo install -f ptx-linker'")
76 }
77
78 fn get_required_version(&self) -> Option<VersionReq> {
79 Some(VersionReq::parse(">= 0.9.0").unwrap())
80 }
81}