-
Notifications
You must be signed in to change notification settings - Fork 10
/
checks.ts
86 lines (84 loc) · 2.7 KB
/
checks.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
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
import * as util from "./util";
import * as config from "./config";
import * as path from "path";
import { PrustiLocation } from "./dependencies";
export async function hasPrerequisites(): Promise<[boolean, string]> {
util.log("Checking Java home...");
if (await config.javaHome() === null) {
const msg = (
"[Prusti] Could not find Java home. Please install Java 1.8+ " +
"64bit or set the 'javaHome' setting, then restart the IDE."
);
return [false, msg];
}
util.log("Checking Rustup and Cargo...");
try {
await util.spawn("rustup", ["--version"]);
await util.spawn("cargo", ["--version"]);
} catch (err) {
console.error(err);
util.log(`Error: ${err}`);
const msg = (
"[Prusti] Could not run Rustup. Please visit https://rustup.rs/ " +
"and install Rustup, then restart the IDE."
);
return [false, msg];
}
util.log("Checking Java...");
try {
const javaPath = path.join(
(await config.javaHome())!.javaExecutable
);
await util.spawn(javaPath, ["-version"]);
} catch (err) {
console.error(err);
util.log(`Error: ${err}`);
const msg = (
"[Prusti] Could not run Java. Please install Java 12+ 64bit, " +
"then restart the IDE."
);
return [false, msg];
}
return [true, ""];
}
export async function checkPrusti(prusti: PrustiLocation): Promise<[boolean, string]> {
util.log("Checking Z3...");
try {
await util.spawn(prusti.z3, ["--version"]);
} catch (err) {
console.error(err);
util.log(`Error: ${err}`);
const msg = (
"[Prusti] Could not run Z3. Please try updating the dependencies, " +
"then restart the IDE."
);
return [false, msg];
}
util.log("Checking Prusti...");
try {
await util.spawn(prusti.prustiRustc, ["--version"]);
} catch (err) {
console.error(err);
util.log("Could not run prusti-rustc");
util.log(`Error: ${err}`);
const msg = (
"Could not run Prusti. Please try updating the dependencies, " +
"then restart the IDE."
);
return [false, msg];
}
util.log("Checking Cargo-Prusti...");
try {
await util.spawn(prusti.cargoPrusti, ["--help"]);
} catch (err) {
console.error(err);
util.log("Could not run cargo-prusti");
util.log(`Error: ${err}`);
const msg = (
"Could not run Prusti. Please try updating the dependencies, " +
"then restart the IDE."
);
return [false, msg];
}
return [true, ""];
}