-
Setting up ccache
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products.Put the following in your .bashrc or equivalent.export USE_CCACHE=1By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.export CCACHE_DIR=<path-to-your-cache-directory>The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code:prebuilts/misc/linux-x86/ccache/ccache -M 50GWhen building Ice Cream Sandwich (4.0.x) or older, ccache is in a different location:prebuilt/linux-x86/ccache/ccache -M 50GThis setting is stored in the CCACHE_DIR and is persistent.------------------------------------------------原理:ccache的使用方式,可以加速我们c与c++的编译速度原理就是中间文件的一个缓存,是同一个.o文件的话就省去再次编译的速度。介于android中c与c++文件数量能占到刚不到一半,所以这个速度还是能省下很多的。----------------------------------------------配置:1在环境变量里添加:export USE_CCACHE=1export CCACHE_DIR=/HDD/.ccache(环境变量有四个位置添加都有效,我习惯添加到全局用户环境变量配置文件:sudo gedit /etc/profile,第一个是标志,android编译会检测这个第二个是缓存路径,默认是~/.ccache)2随便找一个android工程(可能需要2.3以上),设置缓存的大小(注意每执行一次这个,缓存路径会被初始化一次,所以执行一次就好);prebuilt/linux-x86/ccache/ccache -M 50G第一次编译一个工程,会缓存工程.o文件,第二次提升效果明显ccache缓存的调用情况执行下面命令监视$ watch -n1 -d prebuilt/linux-x86/ccache/ccache -s---------------------------------------------------------------------------真实测试:工程android 4.0.4第一次编译:make -j8 36分钟左右;修改了frameworks的一个资源文件;再次编译:make clean;make -j8 18分钟
强力提高 android 4 编译效率(c,c++部分)
最新推荐文章于 2024-05-03 02:53:36 发布