设置 ccache

Usage:
ccache [options]
ccache compiler [compiler options]
compiler [compiler options]          (via symbolic link)

Options:
-c, –cleanup         delete old files and recalculate size counters
(normally not needed as this is done automatically)
-C, –clear           clear the cache completely
-F, –max-files=N     set maximum number of files in cache to N (use 0 for
no limit)
-M, –max-size=SIZE   set maximum size of cache to SIZE (use 0 for no
limit; available suffixes: G, M and K; default
suffix: G)
-s, –show-stats      show statistics summary
-z, –zero-stats      zero statistics counters

-h, –help            print this help text
-V, –version         print version and copyright information

See also <http://ccache.samba.org>.

 

设置方法(ubuntu):
①安装ccache
官网下载或apt安装  sudo apt-get install ccache
②$ which ccache
查看安装路径, /usr/bin/ccache
③$ mkdir ~/.bin
④ $ cd ~/.bin/
   $ ln -s /usr/bin/ccache gcc
   $ ln -s /usr/bin/ccache g++
   $ ln -s /usr/bin/ccache arm-linux-gcc
   $ ln -s /usr/bin/ccache arm-linux-g++
⑤PATH设置,将~/.bin/放在 arm-linux-gcc等的PATH的前面。
原:PATH=/usr/local/arm-linux_pre4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
现:PATH=/home/<user>/.bin:/usr/local/arm-linux_pre4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
        gedit ~/.bashrc 添加 export PATH=”/home/<user>/.bin:$PAHT” ,然后重启即可
⑥$ which arm-linux-gcc
/home/<user>/.bin/arm-linux-gcc 确认
⑦$ ccache -M 2G

1. 设置cache的大小

prebuilts/misc/linux-x86/ccache/ccache -M 25G

2.开启方法

增加USE_CCACHE=1,比如 ./mk -o=USE_CCACHE=1,TARGET_BUILD_VARIANT=user new

可以在makeMtk中将USE_CCACHE=1写进去,比如 $ENV{“USE_CCACHE”}=1

3.通过ccache -s 查看cache的信息,通过ccache -C清除缓存

 

  • 编译Android

Android中,使用ccache,只需要添加环境变量’$ export USE_CCACHE=1′, 不同的是,默认它不用HOST的ccache程式,而使用自带的ccache. 编译android需要较大的缓冲区:

  1. $ ccache -M 3G    // 将缓冲区设置为3G