-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.dart
61 lines (55 loc) · 1.57 KB
/
build.dart
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
import "dart:io";
import "./build/winlib.dart" as winlib;
import "./build/deps.dart" as deps;
main() async {
await deps.fetch();
if (Platform.isWindows) {
winlib.generateLibFile();
}
if (Platform.isLinux) {
var binDir = Directory("./bin");
if (Platform.isLinux) {
var lnFile = File(binDir.path + "/libmkl_rt.so.2");
var lnLink = File(binDir.path + "/libmkl_rt.so");
if (lnFile.existsSync() && !lnLink.existsSync()) {
print("create symlink libmkl_rt.so");
var r = Process.runSync("ln", ["-s", "libmkl_rt.so.2", "libmkl_rt.so"],
workingDirectory: binDir.path);
if (r.exitCode != 0) {
print(" failed: ${r.stderr}");
}
}
}
}
print("compile library ...");
var flags = Platform.isWindows
? "-C target-feature=+crt-static"
: "-C target-feature=-crt-static";
var r = Process.runSync("cargo", ["build", "--release"],
environment: {"RUSTFLAGS": flags});
if (r.exitCode != 0) {
if (r.stderr != null) {
print("build failed:\n${r.stderr.toString()}");
} else {
print("build failed no error message present");
}
return;
}
if (r.stdout != null) {
print(r.stdout.toString());
}
var lib = _target();
var build = File("target/release/$lib");
if (!build.existsSync()) {
print("ERROR: build failed; ${build.path} does not exist");
return;
}
build.copySync("bin/$lib");
build.deleteSync();
}
String _target() {
if (Platform.isWindows) {
return "olcamkl.dll";
}
return Platform.isMacOS ? "libolcamkl.dylib" : "libolcamkl.so";
}