-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
43 lines (37 loc) · 1.09 KB
/
main.ts
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
import { bold, red, yellow } from "https://deno.land/std@0.129.0/fmt/colors.ts";
import {
build,
installToolchain,
isInCargoProject,
isLLDInstalled,
isToolchainInstalled,
printLLDNotInstalledMessage,
} from "./utils/mod.ts";
/** Build an arm64 linux binary and send it to a pi */
async function rust2pi() {
const remote = Deno.args.at(1);
if (!remote) {
console.error(red(bold("Please supply a connection argument.")));
console.log("Example: " + yellow("pi@192.168.0.1"));
Deno.exit(1);
}
const inCargoProject = await isInCargoProject(Deno.cwd());
if (!inCargoProject) {
console.error(red(bold("You are not in a cargo project.")));
Deno.exit(1);
}
if (!isLLDInstalled()) {
printLLDNotInstalledMessage();
Deno.exit(1);
}
const hasToolchain = await isToolchainInstalled();
if (!hasToolchain) {
console.log(yellow(bold("Installing missing cross-toolchain for arm64")));
const status = await installToolchain();
if (status.success) {
console.log(yellow(bold("Installed cross toolchain.")));
}
}
build(remote);
}
await rust2pi();