This package provides the following services:
Cocos build for Atom
Runs cocos2d-x tasks like build, deploy, run, and release in the Atom
editor.
And captures build and runtime errors.
This package requires atom-build and cocos-console to be installed.
How It Works
A project are consider as a cocos2d-x project if there is a .cocos-project.json
at project root. And it takes project_type
key in this file for the project
type (cpp|lua|js).
For Run simulator without build
tasks, it find simulator executable name in:
init_cfg.name
inconfig.json
for lua projectsname
inmanifest.webapp
for js projects.
and runs debug build executables create by cocos compile -p mac|win32
as simulator.
Do make sure the above config are correct for your project and
cocos compile -p mac|win32
commands works well.
Features
Add Build Targets for Cocos2d-x Projects
Supports run build, deploy, run, and release tasks inside Atom
.
Build targets for a Lua project:
Captures Build and Runtime Errors
- Captures build errors and Lua script runtime errors.
- Provides error link to source code.
Cpp build errors:
Lua runtime errors:
Support Additional Configure in .cocos-project.json
Additional key for .cocos-project.json
:
androidABI
: SetAPP_ABI
for Android build, multiple abi can be set likearmeabi-v7a:x86
. Defaultarmeabi
.androidStudio
: Settrue
to build Android Studio project inproj.android-studio
rather thanproj.android
. Defaultfalse
.iosCodeSignIdentity
: iOS code sign identity used to runiOS: Release
target. eg.iPhone Distribution: xxx... (XXXXXXXXXX)
.luaEncrypt
: Setfalse
to disable encryption of Lua scripts when runRelease
targets. Defaulttrue
.luaEncryptKey
: The key used to encrypt Lua scripts when runRelease
targets. Default2dxLua
.luaEncryptSign
: File signature for encrypted Lua script files when runRelease
targets. DefaultXXTEA
Setup
- Install atom-build and this atom-build-cocos package
apm install build build-cocos
. - To setup cocos path you have two options either:
- In Atom -> Preferences... -> Packages -> build-cocos -> Settings -> Set the
Global cocos console path
. eg:/Users/xpol/Workspace/cocos2d-x/tools/cocos2d-console
. - Have a project local copy of cocos-console in you project in
framewroks/cocos2d-x/tools/cocos2d-console
.
- For Lua project
- You need master branch of my fork of
cocos-console
(up vote this pending pull request to make it official) to run simulator and captures the runtime Lua errors. - Set Lua package path to have
src/?.lua;
rather than addsrc/
to FileUtils' search path, see examplemain.lua
. - Make a
xpcall
to your main function and callos.exit(1)
in error handler. see examplemain.lua
.
- After that, in Atom open you project root directory which contains
.cocos-project.json
, runcmd-alt-t
/ctrl-alt-t
/f7
to displays the available build targets. - Set
.cocos-project.json
:
- Set
iosCodeSignIdentity
if you needs build iOS release ipa. - For lua projects, set
luaEncrypt
luaEncryptKey
andluaEncryptSign
to enable encryption for Lua scripts. - Android projects, set
androidStudio
if you want build in project inproj.android-studio
.
Examples
src/main.lua
package.path = 'src/?.lua;src/packages/?.lua'
local fu = cc.FileUtils:getInstance()
fu:setPopupNotify(false)
fu:addSearchPath("res/") -- only add 'res/' for cocos search path, do not add 'src/'.
local function main()
-- your code here...
end
local traceback = __G__TRACKBACK__
function __G__TRACKBACK__(msg)
traceback(msg)
os.exit(1) -- exit on error so that the error will be parsed by atom-build.
end
xpcall(main, __G__TRACKBACK__)
Contribute
Ideas, bugs and pull requests please go to GitHub xpol/atom-build-cocos.