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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use semver::{Version, VersionReq};
use crate::error::*;
pub mod runner;
pub use self::runner::{ExecutableRunner, Output};
pub trait Executable {
fn get_name(&self) -> String;
fn get_verification_hint(&self) -> String;
fn get_version_hint(&self) -> String;
fn get_required_version(&self) -> Option<VersionReq>;
fn get_current_version(&self) -> Result<Version>
where
Self: Sized,
{
self::runner::parse_executable_version(self)
}
}
pub struct Cargo;
pub struct Linker;
impl Executable for Cargo {
fn get_name(&self) -> String {
String::from("cargo")
}
fn get_verification_hint(&self) -> String {
String::from("Please make sure you have it installed and in PATH")
}
fn get_version_hint(&self) -> String {
String::from("Please update Rust and Cargo to latest nightly versions")
}
fn get_required_version(&self) -> Option<VersionReq> {
Some(VersionReq::parse(">= 1.34.0-nightly").unwrap())
}
fn get_current_version(&self) -> Result<Version> {
self::runner::parse_executable_version(self).map(|mut version| {
version.pre = vec![];
version
})
}
}
impl Executable for Linker {
fn get_name(&self) -> String {
String::from("rust-ptx-linker")
}
fn get_verification_hint(&self) -> String {
String::from("You can install it with: 'cargo install ptx-linker'")
}
fn get_version_hint(&self) -> String {
String::from("You can update it with: 'cargo install -f ptx-linker'")
}
fn get_required_version(&self) -> Option<VersionReq> {
Some(VersionReq::parse(">= 0.9.0").unwrap())
}
}