diff options
author | chai <chaifix@163.com> | 2018-12-21 00:11:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-12-21 00:11:54 +0800 |
commit | ceea627416494935ed2fcf14263792711e35cf8b (patch) | |
tree | 3d4d3a6128e8486e20170180be304625cfc61722 | |
parent | a567e2277d241be6a03bc5f0f6b3ba71b0efa536 (diff) |
-wrapy.py
-rw-r--r-- | tools/README | 2 | ||||
-rw-r--r-- | tools/wrapy.py | 57 |
2 files changed, 0 insertions, 59 deletions
diff --git a/tools/README b/tools/README deleted file mode 100644 index f3aa23e..0000000 --- a/tools/README +++ /dev/null @@ -1,2 +0,0 @@ -* cwrap.c for compile lua file to Cpp code. -
\ No newline at end of file diff --git a/tools/wrapy.py b/tools/wrapy.py deleted file mode 100644 index a1975ea..0000000 --- a/tools/wrapy.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python2.7 -import os, sys, random, re - -def fmt(fmt, dic): - for k in dic: - fmt = fmt.replace("{%s}" % k, str(dic[k])) - return fmt - - -def makeArray(data): - i = [0] - def fn(x): - x = str(ord(x)) + "," - if i[0] + len(x) > 78: - i[0] = len(x) - x = '\n' + x - else: - i[0] += len(x) - return x - return '{' + "".join(map(fn, data)).rstrip(",") + '}' - - -def safename(filename): - return re.sub("[^a-z0-9]", "_", os.path.basename(filename).lower()) - - -def process(filenames): - if type(filenames) is str: - filenames = [filenames] - - strings = [] - - for filename in filenames: - data = open(filename, "rb").read() - strings.append( - fmt("/* {filename} */\n" +\ - "static const char {name}[] = \n{array};", - { - "filename" : os.path.basename(filename), - "name" : safename(filename), - "array" : makeArray(data), - })) - - return "/* Automatically generated; do not edit */\n\n" +\ - "\n\n".join(strings) - - -def main(): - if len(sys.argv) < 2: - print "usage: embed FILENAMES" - sys.exit(1) - - print process(sys.argv[1:]) - - -if __name__ == "__main__": - main()
\ No newline at end of file |