diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-21 10:05:19 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-21 10:05:19 +0800 |
| commit | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (patch) | |
| tree | 18dca1f8314fe918d6173ed4acbdc84c5b541752 /src/3rdParty/gencode.yue | |
| parent | c6229c02564024d8c02c2d438b2fc180ce4c6bcf (diff) | |
| download | yuescript-main.tar.gz yuescript-main.tar.bz2 yuescript-main.zip | |
Diffstat (limited to 'src/3rdParty/gencode.yue')
| -rwxr-xr-x | src/3rdParty/gencode.yue | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/3rdParty/gencode.yue b/src/3rdParty/gencode.yue new file mode 100755 index 0000000..e0dbcb9 --- /dev/null +++ b/src/3rdParty/gencode.yue | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | #!yue -e | ||
| 2 | |||
| 3 | for file in *["luaminify.lua",] | ||
| 4 | text = "" | ||
| 5 | with io.open file | ||
| 6 | text = \read "*a" | ||
| 7 | \close! | ||
| 8 | |||
| 9 | indent = "\t" | ||
| 10 | count = 0 | ||
| 11 | text = text\gsub "#!", "--#!" | ||
| 12 | bytes = indent .. string.gsub text, "(.)", (ch)-> | ||
| 13 | sep = "" | ||
| 14 | count += 1 | ||
| 15 | if count == 15 | ||
| 16 | count = 0 | ||
| 17 | sep = "\n" .. indent | ||
| 18 | string.format "%3u,%s", string.byte(ch), sep | ||
| 19 | |||
| 20 | name = file\gsub "%.", "_" | ||
| 21 | output = "#{name}.h" | ||
| 22 | with io.open output, "w" | ||
| 23 | \write "const char #{name}[] = {\n#{bytes}\n};" | ||
| 24 | \close! | ||
| 25 | |||
| 26 | print "file \"#{output}\"generated." | ||
