Lua scripts automatically generate APK packages

Source: Internet
Author: User
Tags lua svn svn update

This article mainly introduces the Lua script automatically generates APK package, this article script applies to the Cocos2dx+lua project, needs the friend to be able to refer to under

The last time you wrote a script with pure bat to generate the APK package, the sense of bat scalability and poor syntax is outrageous, this time with Lua rewrite a script

can be expanded to suit your needs.

Use the previous tool path and the first two of the target path, or you need to set it yourself.

Some small functions jit_file copy_file I will not post it is simpler to Luajit and copy.

?

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-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5 86 87 88 89 90 91 92 93 94 95-96 --Authors:sails Kite @oschina--date:20th, August, 2014--Note:--------------used----- to making. APK file for Android platform--Make sure you have installed Java, ant, Android SDK, NDK, SVN, JIT--Also plz check and Rewrite following paths before you with this script--remarks:--the script would update your Cocos directory and Y Our LUA script which probably are resources--then it should jit your Lua files, with Asmaker to encrypt your file S--All files and would move to this folder Proj.android/assets--finally it'll make a. APK package with ANT require (' support ')  --tools paths local java_home = ' c:program filesjavajdk1.8.0_05 ' local Ant_ Home = ' d:programsoftwareapache-ant-1.9.4 ' local android_home = ' d:programsoftwareandroid sdksdk ', ' local NDK_HOME = ' D:P rogramsoftwareandroid-ndk-r9d-windows-x86_64android-ndk-r9d ' Local svn_home = ' C:Program FilesTortoiseSVNbin '   --target paths Local Engine_dir = ' D:engIne ' local work_dir = ' d:engineprojectsxxxxproj.android ' local resources_dir = Work_dir ... Resources ' Local Assets_dir = Work_dir ... ' Assets '  --function detect directory local function dir_exist (dir) return Os.execute (String.Format (' pushd '%s ' > Nul 2>nul && popd ', dir) ' End  --remove old assets if Dir_exist (Assets_dir) then rmdir (assets_dir) End &N Bsp --remove old APK The local old_apk, err = Io.open (Work_dir ... ' binxxxx-release.apk ') If err = = Nil then old_apk:close () delfile (Work_dir ... ') binxxxx-release.apk ') End  --SVN update--check--svn_up (engine_dir)--svn_up (Work_dir ... ' ... ')  --luajit Iter directory Local cmd = String.Format ("pushd%q &dir/b/S &POPD", resources_dir) Local file_list = Io.popen (c MD) for Line in File_list:lines () does line_to = String.gsub (line, "Resources", ' Resources_jit ') if Dir_exist (line) then Che Ck_mk_path (line_to) Else if (String.find (line, '. lua$ ')) then Jit_file (Work_dir, line, line_to) Else copy_file _To) the end of File_list:close ()  --encryption with asmaker local enc_cmd = Work_dir ... ' ASmaker.exe ' ... '-i '. Work_dir ..... Resources_jit ' ... "-o". Assets_dir. ' F. lua-e. exe ' local enc_re = Run_one_cmd (enc_cmd) if Enc_re:find ("failed") then print ("Asmaker Encrypted folder failed!", enc_ RE) os.exit (1) End  --NDK builds local ndk_cmd = ' call '. Ndk_home ... ' Ndk-build ' ... '-C '. Work_dir ... ' '..' Ndk_module_path= '.. Engine_dir ... '; Engine_dir ... ' Cocos2dxplatformthird_partyandroidprebuilt ' Local ndk_re = Run_one_cmd (ndk_cmd) if Ndk_re:find ("error") then Print (" NDK build Failed! ", Ndk_re) os.exit (1) End  --android Update local and_cmd = ' call '. Android_home ... ' Toolsandroid ' ... ' Update project-p '. Work_dir Local and_re = Run_one_cmd (and_cmd) and_cmd = ' call '. Android_home ... ' Toolsandroid "' ... ' Update lib-project-p '. Engine_dir ... ' Cocos2dxplatformandroidjava ' and_re = Run_one_cmd (and_cmd)  --ant local ant_cmd = ' pushd '. Work_dir ... ' &call '.. Ant_home ... ' Binant Release ' Local ant_re = run_one_cmD (ant_cmd) if Ant_re:find ("failed") then print ("Generate APK failed!", Ant_re) os.exit (1) End
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.