Cocos Luacompile
- Cocos Luacompile
- Overview
- Usage
- Available Arguments
- Samples
Overview
Compile the.luafiles to.luac.
Usage
cocos luacompile [arguments]
Available Arguments
Arg |
Available Value |
Sample |
Description |
necessary |
-H,--help |
- |
- |
Show the help message and exit |
No |
-S,--src |
SOURCE Directory |
./projects/MyLuaGame/src |
Specify source directory of LUA files needed to be compiled. |
Yes |
-D,--DST |
Destination Directory |
./projects/MyLuaGame/src |
Specify destination directory bytecode files to be stored. |
Yes |
-E,--encrypt |
- |
- |
Enable the encrypting of Lua files. |
No |
-K,--encryptkey |
Any string |
MyLuaKey |
Specify the Encrypt key for the encrypting of Lua scripts. It's only take effect when is-e, --encryptenabled. Default value is2dxLua. |
No |
-B,--encryptsign |
Any string |
MyLuaSign |
Specify the Encrypt sign for the encrypting of Lua scripts. It's only take effect when is--encryptenabled. Default value isXXTEA. |
No |
Samples
- cocos luacompile -h. Show the help message.
- cocos luacompile -s ./projects/MyLuaGame/src -d ./projects/MyLuaGame/src -e -k MyLuaKey -b MyLuaSign
Compile the in*.luadirectory./projects/MyLuaGame/srcto*.luac. Then encrypt the Luac files with key are and sign areMyLuaKeyMyLuaSign.
We have some problems during the experiment, supporting 64-bit solutions:
out/-e-k testkey123456-b testSign123456--disable-compile
The whole process and test engineering are given below
1.0 Cocos Luacompile usage
I use the ordinary cocos2d lua, useless quick,quick seems to be able to the entire resources including images and audio are encrypted, packaged into a zip. But I didn't use quick. Look at the next Luacompile help, relatively simple AH.
Set up an Out folder at the root of the project, and then try it with this command:
Cocos luacompile-s src/out /
A lot of luac files are seen in the Out directory, which is smoother than expected. As the command says, the subdirectory is supported. Online said Luac will still be anti-compilation. It adds a key.
out/-e-k testkey123456-b testSign123456
He uses the Xxtea encryption algorithm, can see this article "Xxtea Reversible encryption and decryption algorithm C + + C # compatible version"
You also need to add setxxteakeyandsign to the Applicationdidfinishlaunching method of the AppDelegate.cpp file . This is the first pit where the Luacompile help did not mention it.
LuaStack* stack = engine->getLuaStack();
stack->setXXTEAKeyAndSign("testKey123456", strlen("testKey123456"), "testSign123456", strlen("testSign123456"));
if (engine->executeScriptFile("src/main.lua")) {
return false;
2.64bit is not supported
The second pit is coming: Just beginning to run well in the Iphone4s simulator, iphone5s is dark. It turned out that Lua compiled, although faster, but not yet support 64-bit system, it is said Cocos2d end will give Luajit 64-bit solution, because Apple asked for AH.
and then because of the problem I got stuck for a while. Search on the Internet has no results, it is recommended to use quick. The game is finished, and it's a bit troublesome to turn quick.
suddenly notice the last option in Luacompile Help: –disable-compile, then change the command to the following:
out/-e-k testkey123456-b testSign123456--disable-compile
Also comes out luac files, but simply encrypts with Xxtea. This little game is completely enough.
Cocos LUA encryption and decryption obfuscation (version cocos3.4)