Atom Packages Directory

a package directory for a text editor of the 21st Century

Build Cocos

Install with:
    apm install build-cocos
  

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:

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:

Targets

Captures Build and Runtime Errors

Cpp build errors:

Cpp Errors

Lua runtime errors:

Lua Errors

Support Additional Configure in .cocos-project.json

Additional key for .cocos-project.json:

Setup

  1. Install atom-build and this atom-build-cocos package apm install build build-cocos.
  2. 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.
  3. 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 add src/ to FileUtils’ search path, see example main.lua.
    • Make a xpcall to your main function and call os.exit(1) in error handler. see example main.lua.
  4. After that, in Atom open you project root directory which contains .cocos-project.json, run cmd-alt-t / ctrl-alt-t / f7 to displays the available build targets.
  5. Set .cocos-project.json:
    • Set iosCodeSignIdentity if you needs build iOS release ipa.
    • For lua projects, set luaEncrypt luaEncryptKey and luaEncryptSign to enable encryption for Lua scripts.
    • Android projects, set androidStudio if you want build in project in proj.android-studio.

Examples

src/main.lua

```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.

Keywords: build, compile, run, cocos2d-x, c++, lua, javascript, productivity Suggest keywords
Fork me on GitHub