-
Notifications
You must be signed in to change notification settings - Fork 3
/
prepare_files_for_include.lua
58 lines (53 loc) · 1.35 KB
/
prepare_files_for_include.lua
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
for file in io.popen([[dir "include_files" /b /A-d]]):lines()
do
local isLuaFile = file:match("%.lua") ~= nil
print(file, isLuaFile)
if not file:match("%.inc")
then
local f = io.open("include_files/"..file, "r")
local pr = "const char " .. file:gsub("%.", "_") .. "[] = "
for line in f:read("*all"):gmatch("[^\n]*") do
if isLuaFile
then
line = line:gsub("\\", "\\\\")
end
line = line:gsub("\"", "\\\"")
pr = pr .. "\"" .. line .. "\\n\""
end
pr = pr .. ";"
local pf = io.open("source/"..file..".inc", "w")
pf:write(pr)
end
end
--if true then return end
--
--for file in io.popen([[dir "include_files" /b /A-d]]):lines()
--do
-- local isLua = file:match("%.lua") != nil
-- if not file:match("%.inc")
-- then
-- print(file .. " -> " .. file .. ".inc")
-- local f = io.open("include_files/"..file, "r")
-- local pr = "const char " .. file:gsub("%.", "_") .. "[] = "
-- local skipNewline = false
-- for line in f:read("*all"):gmatch("([^\n]*)") do
-- if skipNewline
-- then
-- skipNewline = false
-- else
-- if isLua
-- then
-- line = line:gsub("\\", "\\\\")
-- line = line:gsub("\"", "\\\"")
-- end
--
-- pr = pr .. "\"" .. line .. "\\n\""
-- skipNewline = true
-- end
-- end
-- pr = pr .. ";"
-- local pf = io.open("source/"..file..".inc", "w")
-- pf:write(pr)
-- end
--
--end