blob: e0dbcb9b08e46a108a913c1bf1b00781dd042f1a (
plain)
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
|
#!yue -e
for file in *["luaminify.lua",]
text = ""
with io.open file
text = \read "*a"
\close!
indent = "\t"
count = 0
text = text\gsub "#!", "--#!"
bytes = indent .. string.gsub text, "(.)", (ch)->
sep = ""
count += 1
if count == 15
count = 0
sep = "\n" .. indent
string.format "%3u,%s", string.byte(ch), sep
name = file\gsub "%.", "_"
output = "#{name}.h"
with io.open output, "w"
\write "const char #{name}[] = {\n#{bytes}\n};"
\close!
print "file \"#{output}\"generated."
|