-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilters.lua
More file actions
56 lines (50 loc) · 1.51 KB
/
filters.lua
File metadata and controls
56 lines (50 loc) · 1.51 KB
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
function build_scripts.env.when (fn)
return function (t)
if type(t) ~= 'table' then
fatal('Expected table!', nil, { t = be.util.sprint_r(t) })
end
return function (configured)
local func = fn
if type(func) ~= 'function' then
local err
func, err = load('return ' .. fn, 'when()', 't', configured)
if not func then
fatal(err .. ' When expression: ' .. fn, nil, { t = be.util.sprint_r(t) })
end
end
if func(configured) then
for i = 1, #t do
t[i](configured)
end
end
end
end
end
function build_scripts.env.toolchain (spec)
if type(spec) ~= 'table' then
spec = { spec }
end
return build_scripts.env.when(function (configured)
for i = 1, #spec do
local tc = interpolate_string(tostring(spec[i]), configured)
if tc == configured.toolchain then
return true
end
end
return false -- toolchain didn't match any values in provided spec
end)
end
function build_scripts.env.configuration (spec)
if type(spec) ~= 'table' then
spec = { spec }
end
return build_scripts.env.when(function (configured)
for i = 1, #spec do
local config = interpolate_string(tostring(spec[i]), configured)
if config == configured.configuration then
return true
end
end
return false -- configuration didn't match any values in provided spec
end)
end