Skip to content

Instantly share code, notes, and snippets.

@ultimateprogramer
Created October 17, 2018 09:59
Show Gist options
  • Select an option

  • Save ultimateprogramer/5b86ff6da31bd7be26bcaa9850033cc8 to your computer and use it in GitHub Desktop.

Select an option

Save ultimateprogramer/5b86ff6da31bd7be26bcaa9850033cc8 to your computer and use it in GitHub Desktop.
Compiling COCOS Studio for Linux from a Mac image

Since Cocos Creator is an electron app, I thought it should be easy to run it on Linux. As a result, successfully launched Cocos Creator app on Ubuntu.

Cocos Creator

To make it possible,

  • Clone electron tag 1.7.5 which is the version cocos creator uses. Modify atom/common/asar/archive.cc, atom/browser/net/url_request_asar_job.cc and lib/common/asar.js files to decrypt js files and asar header. You can find correct asar.js file from Cocos Creator itself by opening developer tools and find the file ELECTRON_ASAR.js. Finally build the electron by using ./script/create-dist.py

Folder view

  • Copy Resources folder from Mac version of Cocos Creator to resources folder of the newly built app.
  • Change node native libraries from mac versions to linux versions. The files are located under resources/app.asar-unpacked/

Why I did this because I need a docker image to build the game on CI. You can use sercand/cocos-creator:1.8.0-web image to build your game for web. An example .gitlab-ci.yml configuration which we use build game on Kubernetes:

stages:
  - build
thegame:
  stage: build
  image: sercand/cocos-creator:1.8.0-web
  script:
    - sh /opt/cocos-build.sh --path . --build "platform=web-mobile"
    - aws s3 sync ./build/web-mobile s3://$AWS_BUCKET/testing/$CI_COMMIT_SHA
  tags:
    - kubernetes
  artifacts:
    paths:
    - build/web-mobile

Here is the docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment