How to use CCache to speed up cocos2d-x android compilation

CCache is a compiler cache for C/C++. It speeds up recompilation by caching the result of previous compilations and detecting
when the same compilation is being done again. We can use this tool to speed up cocos2d-x android compilation.

The following  instructions are tested on Mac:

Installation:

You can use homebrew:

brew install --HEAD ccache

Or install by source:

git clone https://github.com/jrosdahl/ccache.git

    cd ccache

    ./autogen.sh

   ./configure

    make

    make install

If bash prompts it can not find autoheader, you need install automake:

    brew install automake

But, if bash complains it can not find brew, you need install one:

  ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

make sure ccache can be found in your $PATH, run command:

ccache

If you can not see the help message, check your installation.

Configuration

To use CCache, you need setup some environment variables:

   vim ~/.bash_profile  

Add following lines:

export USE_CCACHE=1

  export NDK_CCACHE=/usr/local/bin/ccache

Then run command:

  ccache -M 10G

This command will set max cache size to 10G, If your mac have a large hard disk, you can set the cache size to 50G.

Then, find your NDK path, if you forget where you put it, try the following command:

which ndk-build

This is the result on my mbp:

/developer/android/android-ndk-r9b/ndk-build

So my NDK_ROOT is:

/developer/android/android-ndk-r9b

Open file: $NDK_ROOT/build/core/default-build-commands.mk

find the following section,Add ccache as shown:

# IMPORTANT: The following definitions must use lazy assignment because

# the value of TOOLCHAIN_PREFIX or TARGET_CFLAGS can be changed later by

# the toolchain‘s setup.mk script.

#

ifneq ($(findstring ccc-analyzer,$(CC)),)

TARGET_CC       = $(CC)

else

TARGET_CC       = ccache $(TOOLCHAIN_PREFIX)gcc    #Add ccache support

endif

TARGET_CFLAGS   =

TARGET_CONLYFLAGS =

ifneq ($(findstring c++-analyzer,$(CXX)),)

TARGET_CXX      = $(CXX)

else

TARGET_CXX      = ccache $(TOOLCHAIN_PREFIX)g++ #Add ccache support

endif

TARGET_CXXFLAGS = $(TARGET_CFLAGS) -fno-exceptions -fno-rtti

Build

Switch to cocos2d-x root path, run:

python build/android-build.py -p 10 cpp-tests 

Open another bash window, run:

 ccache -s

this command will print the ccache statistics,

cache directory                     /Users/heliclei/.ccache

primary config                      /Users/heliclei/.ccache/ccache.conf

secondary config      (readonly)    /usr/local/etc/ccache.conf

cache hit (direct)                 13588

cache hit (preprocessed)           11145

cache miss                          4696

called for link                        1

called for preprocessing              14

preprocessor error                     1

can‘t use precompiled header        1629

no input file                          5

files in cache                     32222

cache size                           5.4 GB

max cache size                      30.0 GB

If both cache hit & cache size are 0, that means ccache doesn‘t work, you need check your configuration.

How to use CCache to speed up cocos2d-x android compilation,布布扣,bubuko.com

时间: 2024-11-07 11:05:09

How to use CCache to speed up cocos2d-x android compilation的相关文章

#Cocos2d+lua#android+Eclipse工程编译设置

用Elicpse编译cocos2d+lua的工程几点注意点记录: 1.设置工程属性Windows->Preferences->NDK目录 2.右键Android Tools->Add native 3.编辑Android.mk文件: LOCAL_C_INCLUDES $(call import-add-path, $(LOCAL_PATH)/../../../) $(call import-module, xxxx) 4.编辑Application.mk: APP_STL := gnus

cocos2d jsb 打包 Android APK

1.首先要会普通的cpp 打包成Android APK 以下所说的是在cocos2d-x 2.2.2 或者 2.3 版本中.本文在Eclipse总用ndk编译cocos2d-x. 老生常谈cocos2d-x JSB不是简单的js代码,涉及到C++代码,如果是Android的话又涉及到Java代码,有点复杂,如果搞过Android下的Jni的话会熟悉些.可以看下这篇文章:<Android Jni 例子 Hello JNI,ndk> Android为了提高开发者开发应用的速度,降低难度,选择了Ja

【Android 系统开发】CyanogenMod 13.0 源码下载 编译 ROM 制作 ( 手机平台 : 小米4 | 编译平台 : Ubuntu 14.04 LTS 虚拟机)

作者 : 韩曙亮 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/51592930 手机的两种模式 : 在下面有详细的图片示例; -- Recovery 模式 : 音量键增加 + 电源键, 长按上述组合键, 看到 "MI" 的 LOGO 后即进入 Recovery 模式; -- Fastboot 模式 : 音量键减小 + 电源键, 长按上述组合键, 看到 "FASTBOOT" 后, 即 进入 FA

cocos2d-x 3.1.1 学习笔记[3]Action 动作

这些动画貌似都非常多的样子,就所有都创建一次. 代码例如以下: /* 动画*/ auto sp = Sprite::create("card_bg_big_26.jpg"); Size size = Director::getInstance()->getWinSize(); sp->setScale(0.2); sp->setPosition(Vec2(size.width / 2 + 200, size.height / 2 + 200)); sp->set

android源码大放送(实战开发必备),免费安卓demo源码,例子大全文件详细列表

免费安卓demo源码,例子大全文件详细列表 本列表源码永久免费下载地址:http://www.jiandaima.com/blog/android-demo 卷 yunpan 的文件夹 PATH 列表 卷序列号为 0000-73EC E:. │ jiandaima.com文件列表生成.bat │ 例子大全说明.txt │ 本例子永久更新地址~.url │ 目录列表2016.03.10更新.txt │ ├─前台界面 │ ├─3D标签云卡片热门 │ │ Android TagCloudView云标签

Cocos2d-x 3.1.1 学习日志11--一Windows下Android环境搭建(一定对你有用的!!)

安装步骤::(多么痛的领悟!!) 1. 配置JDK JDK下载地址: 设置环境变量: JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_21 CLASSPATH=.;%JAVA_HOME%\lib; Path增加%JAVA_HOME%\bin; 设置完后打开cmd,输入java -version 如果出现下面提示,表明环境变量设置成功: C:\Users\arlin>java -version java version "1.7.0_21&quo

cocos2d-x 3.0rc开发指南:Windows下Android环境搭建

安装工具 1. 配置JDK JDK下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 本人的系统是Win7 64位版,但安装的是JDK7.Windows X86版. 如果安装文件夹在:C:\Program Files (x86)\Java\jdk1.7.0_21:当然也能够是其它地方 环境变量设置: JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_21 CLA

codeblocks中cocos2dx项目添加新的.cpp和.h文件后编译运行的方法

新建了cocos2dx项目后(比如我这里建立的项目名为Test01),项目目录下有如下目录和文件: bin CMakeLists.txt MyGame.layout proj.win10 Classes cocos2d proj.android proj.win32 CMakeCache.txt lib proj.android-studio proj.win8.1-universal CMakeFiles Makefile proj.ios_mac Resources cmake_instal

cocos引擎v2.1版本android 编译问题解决办法 (cocos2d-x-3.4rc1)

下载了最新版的cocos v2.1.2beta,使用cocos.exe来创建项目,而且在最下方的附件功能里还勾选了“支持x86架构cpu”这个选项,导致使用build_native.py编译不通过,以及cocos.py也compile不通过:提示android.mk的19行prebuilt-mk报错:***ANDROID NDK aborting, 之后尝试做了几处改动——添加了NDK_MODULE_PATH环境变量.使用了的从cocos下载的ndk版本\看网上别人的解释,prebult-mk报