-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_scripts.lua
More file actions
43 lines (35 loc) · 1.02 KB
/
build_scripts.lua
File metadata and controls
43 lines (35 loc) · 1.02 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
local fs = require('be.fs')
current_build_script_path = nil
build_scripts = {
env = { }
}
register_template_dir(fs.compose_path(limp_dir, 'build', 'templates'))
local n = 0
local function search_relative (path, parent_path)
local build_script = fs.compose_path(parent_path, path, 'build.lua')
if fs.exists(build_script) then
local contents = fs.get_file_contents(build_script)
local fn = load(contents, '@' .. build_script .. '.lua', 'bt', build_scripts.env)
n = n + 1
build_scripts[n] = function ()
current_build_script_path = build_script
fn()
current_build_script_path = nil
end
end
end
function build_scripts.try (path)
search_relative(path, root_dir)
end
function build_scripts.search (path)
local abs_path = fs.compose_path(root_dir, path)
local dirs = table.pack(fs.get_dirs(abs_path))
for i = 1, #dirs do
search_relative(dirs[i], abs_path)
end
end
function build_scripts.execute ()
for i = 1, n do
build_scripts[i]()
end
end