追求游戏之道 2013-11-27
使用luaJit编译成二进制
1.安装luaJit
下载http://luajit.org/LuaJIT2.0.2
安装sudomakeinstall
2.使用luabinary.py,此处只是输出cmd
3.到luajit路径下,运行上步骤输出的cmd,
luaJit/luaJit
输出刚才cmd
4.复制luajitScript的文件到Resource/luaScript
5.xcode运行测试验证
6.android运行测试验证
import os,sys srcdir = '~/Documents/' destdir = '~/Documents/' def luabinaryDir(srcdir, dstdir): if not os.path.exists( srcdir ): os.system( 'mkdir ' + srcdir ) if not os.path.exists( dstdir ): os.system( 'mkdir ' + dstdir ) flist = os.listdir(srcdir) for item in flist: filepath = os.path.join(srcdir, item) # print item # print filepath if os.path.isdir(filepath): luabinaryDir( os.path.join(srcdir, item), os.path.join(dstdir, item) ) elif os.path.splitext( item )[1] == '.lua': # print 'Y' srcfile = os.path.join(srcdir, item) dstfile = os.path.join(dstdir, item) cmd = 'luajit -b %s %s' % (srcfile, dstfile) print cmd # os.system(cmd) luabinaryDir('sourcePath',"destPath')
#此处2个路径,分别为lua原文件路径和lua二进制后输出路径