-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.wren
76 lines (52 loc) · 1.6 KB
/
build.wren
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
// This Source Form is subject to the terms of the AQUA Software License, v. 1.0.
// Copyright (c) 2023 Aymeric Wibo
var DEVSET_ENV = "DEVSET"
var DEVSET_FILE = "devset"
var DEFAULT_DEVSET = "core"
var DEPS_FILE = "deps"
// get options from environment variables
var devset = Meta.getenv(DEVSET_ENV)
var just_read = false
if (devset == null) {
devset = File.read(DEVSET_FILE)
just_read = devset != null
}
if (devset == null) {
devset = DEFAULT_DEVSET
}
devset = devset.trim()
if (!just_read) {
File.write(DEVSET_FILE, devset + "\n")
}
// compile all devsets
// combine this with the creation of the installation map
var install = {}
var devset_stack = devset.split(",")
Meta.setenv("DEVSET_INC_PATH", "%(Meta.cwd())/src")
var instruction = Meta.instruction()
if (!["build", "lsp"].contains(instruction)) {
instruction = "build"
}
while (devset_stack.count > 0) {
devset = devset_stack.removeAt(0) // TODO just make this .pop in Bob's dialect of Wren
// read dependent devsets and add them to the stack
var deps = File.read("src/%(devset)/%(DEPS_FILE)").trim().split(",")
if (deps[0] != "") {
devset_stack = devset_stack + deps // TODO allow +=
}
// compile all devices of devset
var devices = File.list("src/%(devset)", 1)
.where { |path| path.startsWith("src/%(devset)/") && !path.endsWith(DEPS_FILE) && !path.endsWith("README.md") }
devices.each { |path|
if (File.bob(path, [instruction]) != 0) {
return
}
var name = path.split("/")[-1]
var filename = "%(devset).%(name).vdev"
install[filename] = "share/aqua/devices/%(filename)"
}
}
// TODO testing
class Tests {
}
var tests = []