-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinyrick.rs
147 lines (124 loc) · 2.65 KB
/
tinyrick.rs
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! Build configuration
extern crate tinyrick;
extern crate tinyrick_extras;
use std::path;
/// Generate documentation
fn doc() {
tinyrick_extras::build();
}
/// Security audit
fn audit() {
tinyrick::deps(cargo_audit);
}
/// Run cargo audit
fn cargo_audit() {
tinyrick::exec!("cargo", &["audit"]);
}
/// Run clippy
fn clippy() {
tinyrick_extras::clippy();
}
/// Run rustfmt
fn rustfmt() {
tinyrick_extras::rustfmt();
}
/// Run unmake
fn unmake() {
tinyrick::exec!("unmake", &["."]);
tinyrick::exec!("unmake", &["-n", "."]);
}
/// Validate documentation and run linters
fn lint() {
tinyrick::deps(doc);
tinyrick::deps(clippy);
tinyrick::deps(rustfmt);
tinyrick::deps(unmake);
}
/// Lint, and then install artifacts
fn install() {
tinyrick::deps(lint);
tinyrick::exec!("cargo", &["install", "--force", "--path", "."]);
}
/// Uninstall artifacts
fn uninstall() {
tinyrick::exec!("cargo", &["uninstall"]);
}
/// Run tests
fn test() {
tinyrick::deps(install);
assert!(tinyrick::exec_mut!("crit", &["-l"])
.current_dir("example")
.status()
.unwrap()
.success());
}
/// Build: Doc, lint, test, and compile
fn build() {
tinyrick::deps(lint);
tinyrick::deps(test);
tinyrick_extras::build();
}
/// banner generates artifact labels.
fn banner() -> String {
format!("{}-{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"))
}
/// archive bundles executables.
fn archive() {
tinyrick_extras::archive(
path::Path::new(".crit").join("bin").display().to_string(),
banner(),
);
}
/// Prepare cross-platform release media.
fn port() {
tinyrick_extras::crit(vec!["-b".to_string(), banner()]);
tinyrick::deps(archive);
}
/// Publish to crate repository
fn publish() {
tinyrick_extras::publish();
}
/// Clean example project
fn clean_example() {
assert!(tinyrick::exec_mut!("crit", &["-c"])
.current_dir("example")
.status()
.unwrap()
.success());
}
/// Clean ports
fn clean_ports() {
assert!(tinyrick::exec_mut!("crit", &["-c"])
.status()
.unwrap()
.success());
}
/// Clean workspaces
fn clean() {
tinyrick_extras::clean_cargo();
tinyrick::deps(clean_example);
tinyrick::deps(clean_ports);
}
/// CLI entrypoint
fn main() {
tinyrick::phony!(clean);
tinyrick::wubba_lubba_dub_dub!(
build;
doc,
install,
uninstall,
audit,
cargo_audit,
clippy,
rustfmt,
unmake,
lint,
test,
archive,
port,
publish,
clean_example,
clean_ports,
clean
);
}