-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdub.d
61 lines (56 loc) · 1.29 KB
/
dub.d
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 std.file;
import std.json;
import std.stdio;
import std.path;
import std.process;
import load_package;
import globals;
bool getDubPackage(Package* p) {
if (exists("package.json") && exists("./source")) {
loadDubPackage(p);
return true;
}
return false;
}
void loadDubPackage(Package* p) {
auto t = readText("package.json");
auto json = parseJSON(t);
p.name = json["name"].str;
p.isDubPackage = true;
//p.isLibrary = json[""];
try {
if (json["version"].type == JSON_TYPE.STRING)
p.version_str = json["version"].str;
} catch (Exception e) {}
if (json["configurations"].type==JSON_TYPE.ARRAY) {
foreach (v; json["configurations"].array) {
if (v.type==JSON_TYPE.OBJECT) {
try {
if (v["name"].str=="library") {
p.isLibrary = true;
}
} catch (Exception e) {}
try {
if (v["excludedSourceFiles"].type==JSON_TYPE.ARRAY) {
foreach (f; v["excludedSourceFiles"].array) {
p.skipDFiles ~= f.str;
}
}
} catch (Exception e) {}
}
}
}
try {
if (json["dip-dependencies"].type==JSON_TYPE.OBJECT) {
foreach (k,v; json["dip-dependencies"].object) {
p.dependencies ~= Dependency(k, v.str);
}
}
} finally {}
}
void buildDubPackage(Package p) {
assert(p.isDubPackage);
if (auto ret = shell("dub build")) {
writeln(ret);
}
}