-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroups.lua
More file actions
144 lines (124 loc) · 3.5 KB
/
groups.lua
File metadata and controls
144 lines (124 loc) · 3.5 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
local fs = require('be.fs')
local groups = {
all = { }
}
protected_config_properties = {
name = true,
suffix = true,
type = true,
projects = true,
fns = true,
group = true,
project = true,
toolchain = true,
configuration = true,
configurations = true,
configured_group = true,
src = true,
limp_src = true,
include = true,
link = true,
link_internal = true,
link_project = true,
linked_configurations = true,
define = true,
export_define = true
}
local function group (group_type, name)
if not name then
fatal 'Group name not specified!'
end
local group = groups.all[name]
if not group then
group = {
name = name,
type = group_type,
path = fs.parent_path(current_build_script_path),
configurations = { },
projects = { },
fns = { },
define = { },
export_define = { }
}
groups.all[name] = group
groups[#groups + 1] = group
end
if group.type ~= group_type then
fatal('"' .. name .. '" is a ' .. group.type .. ', not a ' .. group_type .. '!')
end
return function (t)
if type(t) ~= 'table' then
fatal('Expected table!', nil, { t = be.util.sprint_r(t) })
end
for k, v in pairs(t) do
if type(k) == 'number' then
group.fns[#group.fns + 1] = v
elseif type(k) == 'string' and not protected_config_properties[k] then
group[k] = v
else
fatal('The ' .. k .. ' property cannot be set directly!')
end
end
end
end
function build_scripts.env.module (name)
return group('module', name)
end
function build_scripts.env.tool (name)
return group('tool', name)
end
function build_scripts.env.demo (name)
return group('demo', name)
end
function build_scripts.env.deps (t)
return group('deps', 'deps')(t)
end
function build_scripts.env.ext_include_dir (name)
return function (t)
for i = 1, #t do
t[i](t)
end
t.name = name
if not t.path then
t.path = t.name
end
return function (configured_group)
if t then
configured_group.ext_include_dirs = append_sequence({ t }, configured_group.ext_include_dirs)
t = nil
end
end
end
end
function configure_group (group, toolchain, configuration)
local configured = deep_copy(group)
group.configurations[configuration] = configured
configured.group = group
configured.toolchain = toolchain
configured.configuration = configuration
configured.configurations = group.configurations
configured.configuration_suffix = default_configuration_suffix(configuration)
for f = 1, #group.fns do
group.fns[f](configured)
end
configured.path = fs.canonical(configured.path)
local search_paths = { configured.path, root_dir }
if not configured.namespace_path then
configured.namespace_path = 'be'
end
if configured.ext_include_dirs then
for i = 1, #configured.ext_include_dirs do
local t = configured.ext_include_dirs[i]
local dest_path = fs.compose_path(ext_include_dir(), t.name)
local source_path = expand_path(t.path, search_paths)
configured.ext_include_dirs[i] = make_lndir_target(dest_path, source_path)
end
end
for k, v in pairs(configured) do
if not protected_config_properties[k] and type(v) == 'string' then
configured[k] = interpolate_string(v, configured)
end
end
return configured
end
return groups