-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrelease.rs
95 lines (80 loc) · 2.44 KB
/
release.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
///
/// This is a binary targets, which is an executable program
/// that can be run after crate compilation.
///
/// It will basically build release versions of
/// each android target.
///
/// ## Examples
/// ```
/// $ cd cryptor_jni/
/// $ cargo run --bin release
/// ```
///
/// For more information, refer to the official doc:
/// - https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries
///
// https://doc.rust-lang.org/reference/items/modules.html
#[path="../../build.rs"]
mod build;
use cryptor_global::console;
///
/// Release android targets from Configuration.
/// Check ['build.rs'] File.
///
/// ## Example
///
/// ```
/// cargo build --target armv7-linux-androideabi --release
/// cargo build --target aarch64-linux-android --release
/// cargo build --target i686-linux-android --release
/// cargo build --target x86_64-linux-android --release
/// ```
fn release_android_targets() {
for target in build::ANDROID_TARGET_ABI_CONFIG.keys() {
console::print(format!("Building Android Target --> {}", &target));
let command_args = build_command_args_for_target(&target);
console::run_command("cargo", &command_args);
}
}
///
/// Build `cargo` arguments for building android targets.
///
/// ## Example
///
/// ```
/// cargo build --target armv7-linux-androideabi --release
/// ```
fn build_command_args_for_target(target: &str) -> Vec<&str> {
let mut command_args = Vec::new();
command_args.push("build");
command_args.push("--target");
command_args.push(target);
command_args.push("--release");
command_args
}
fn main() {
console::out("Releasing Android Targets...Be patient... :)");
release_android_targets();
}
//
// T E S T S
//
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_build_android_release_argument() {
let command_args = build_command_args_for_target("armv7-linux-androideabi");
let expected_result = "build --target armv7-linux-androideabi --release";
assert_eq!(command_args.join(" "), expected_result.trim());
}
#[test]
fn test_build_android_release_arguments_for_all_targets() {
for target in build::ANDROID_TARGET_ABI_CONFIG.keys() {
let command_args = build_command_args_for_target(&target);
let expected_result = format!("build --target {target} --release", target = &target);
assert_eq!(command_args.join(" "), expected_result.trim());
}
}
}