-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_makeinstall.lua
More file actions
61 lines (51 loc) · 1.07 KB
/
_makeinstall.lua
File metadata and controls
61 lines (51 loc) · 1.07 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
-- List of files to pack
files = {
"sha256.lua",
"peripheralsinfo.lua",
"luaide.lua",
"tankfiller.lua",
"mfrbioreac.lua"
}
-- Output table
outputs = {}
function wr(ite)
outputs[#outputs+1] = ite
end
function packFile(name)
--[[ ensure you can open file, write "header", write content, write footer ]]
-- Check that file exists
local file = assert(io.open(name,"r"))
-- find cc name (i.e. strip .lua extension)
local ccname = name:match("(.+)%.lua")
print ("Adding file " .. ccname)
-- write header
wr ("writefile('")
wr (ccname)
wr ("', [=====[")
-- write content
local content
repeat
content = file:read("*a")
wr (content)
until content == "";
-- write footer
wr("]=====]);\n\n")
end
fileheader = [[
function writefile(name,content)
file = io.open(name,"w")
file:write(content)
file:close()
end
]]
-- syntax check it
assert (load (fileheader, "fileheader"))
outfile = assert(io.open ("installer","w"))
outfile:write(fileheader)
local _,v
for _,v in ipairs(files) do
packFile(v)
outfile:write(table.concat(outputs))
outputs={}
end
outfile:close()