This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinyrick.rs
130 lines (102 loc) · 2.93 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
//! Build configuration
extern crate tinyrick;
extern crate tinyrick_extras;
extern crate zip;
extern crate glob;
use std::io;
use std::fs;
use std::path;
/// Generate documentation
fn doc() {
tinyrick_extras::doc();
}
/// Run clippy
fn clippy() {
tinyrick_extras::clippy();
}
/// Validate documentation and run linters
fn lint() {
tinyrick::deps(doc);
tinyrick::deps(clippy);
}
/// Install binaries
fn install() {
tinyrick_extras::install_binaries();
}
/// Uninstall binaries
fn uninstall() {
tinyrick_extras::uninstall_binaries();
}
/// Doc, lint, and run tests
fn test() {
tinyrick::deps(lint);
tinyrick::deps(install);
tinyrick_extras::unit_test();
tinyrick::exec!("ios7crypt", &["-e", "monkey"]);
assert!(tinyrick::exec_stdout_utf8!("ios7crypt", &["-d", "060b002f474b10"]) == "monkey\n");
assert!(!tinyrick::exec_status!("ios7crypt").success());
}
/// Doc, lint, test, and compile
fn build() {
tinyrick::deps(test);
tinyrick_extras::build();
}
/// Generate and archive ports
fn port() {
let architectures : &[&str] = &["x86_64", "i686"];
let libcs : &[&str] = &["gnu", "musl"];
for architecture in architectures {
for libc in libcs {
tinyrick::exec!("sh", &["crosscompile-linux", architecture, libc]);
}
}
let archive_path : &str = &format!("{}-{}.zip", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
let zip_file : fs::File = fs::File::create(archive_path).unwrap();
let zip_writer : &mut zip::ZipWriter<fs::File> = &mut zip::ZipWriter::new(zip_file);
let file_options : zip::write::FileOptions = zip::write::FileOptions::default();
let target_path : &path::Path = path::Path::new("target");
for architecture in architectures {
for libc in libcs {
let target_with_environment : path::PathBuf = target_path.join(format!("{}-unknown-linux-{}", architecture, libc));
let binary_path : path::PathBuf = target_with_environment
.join("release")
.join("ios7crypt");
let binary_path_str : &str = binary_path.to_str().unwrap();
let entry_file : &mut fs::File = &mut fs::File::open(binary_path_str).unwrap();
zip_writer.start_file(binary_path_str, file_options).unwrap();
io::copy(entry_file, zip_writer).unwrap();
}
}
}
/// Publish to crate repository
fn publish() {
tinyrick_extras::publish();
}
/// Delete archives
fn clean_archives() {
for p in glob::glob("*.zip").unwrap() {
fs::remove_file(p.unwrap()).unwrap();
}
}
/// Clean workspaces
fn clean() {
tinyrick::deps(clean_archives);
tinyrick_extras::clean_cargo();
}
/// CLI entrypoint
fn main() {
tinyrick::phony!(clean);
tinyrick::wubba_lubba_dub_dub!(
build;
doc,
clippy,
lint,
install,
uninstall,
test,
port,
publish,
clean_archives,
clean
);
}