博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(ubuntu)在andorid andk工程中使用ccache加速编译速度
阅读量:4028 次
发布时间:2019-05-24

本文共 3327 字,大约阅读时间需要 11 分钟。

环境

系统:Linux luogw-pc 3.5.0-36-generic #57~precise1-Ubuntu SMP Thu Jun 20 18:21:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

ndk:   ndk-r8d

cache: ccache version 3.1.6

第一步:安装ccache

sudo apt-get install ccache

第二步:配置ccache

添加环境变量 export NDK_CCACHE=ccache

第三步:修改 android-ndk-r8e/build/core/default-build-commands.mk

注:红色部份为修改的内容,原内容被注释掉

#

# 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       = $(TOOLCHAIN_PREFIX)gcc
TARGET_CC       = ccache $(TOOLCHAIN_PREFIX)gcc
endif
TARGET_CFLAGS   =
ifneq ($(findstring c++-analyzer,$(CXX)),)
TARGET_CXX      = $(CXX)
else
#TARGET_CXX      = $(TOOLCHAIN_PREFIX)g++
TARGET_CXX      = ccache $(TOOLCHAIN_PREFIX)g++
endif
TARGET_CXXFLAGS = $(TARGET_CFLAGS) -fno-exceptions -fno-rtti

实践对比:

使用ccache前后情况对比如下

luogw@luogw-pc:~/study/bitmap-plasma$ ccache -scache directory                     /home/luogw/.ccachecache hit (direct)                     0cache hit (preprocessed)               0cache miss                             0files in cache                         0cache size                             0 Kbytesmax cache size                       1.0 Gbytesluogw@luogw-pc:~/study/bitmap-plasma$ time ndk-buildGdbserver      : [arm-linux-androideabi-4.7] libs/armeabi/gdbserverGdbsetup       : libs/armeabi/gdb.setupGdbserver      : [arm-linux-androideabi-4.7] libs/armeabi-v7a/gdbserverGdbsetup       : libs/armeabi-v7a/gdb.setupCompile thumb  : plasma <= plasma.cSharedLibrary  : libplasma.soInstall        : libplasma.so => libs/armeabi/libplasma.soCompile thumb  : plasma <= plasma.cSharedLibrary  : libplasma.soInstall        : libplasma.so => libs/armeabi-v7a/libplasma.soreal	0m0.226suser	0m0.128ssys	0m0.032sluogw@luogw-pc:~/study/bitmap-plasma$ ccache -scache directory                     /home/luogw/.ccachecache hit (direct)                     0cache hit (preprocessed)               0cache miss                             2called for link                        2multiple source files                  2files in cache                         6cache size                           108 Kbytesmax cache size                       1.0 Gbytesluogw@luogw-pc:~/study/bitmap-plasma$ rm -r libs/ obj/luogw@luogw-pc:~/study/bitmap-plasma$ time ndk-buildGdbserver      : [arm-linux-androideabi-4.7] libs/armeabi/gdbserverGdbsetup       : libs/armeabi/gdb.setupGdbserver      : [arm-linux-androideabi-4.7] libs/armeabi-v7a/gdbserverGdbsetup       : libs/armeabi-v7a/gdb.setupCompile thumb  : plasma <= plasma.cSharedLibrary  : libplasma.soInstall        : libplasma.so => libs/armeabi/libplasma.soCompile thumb  : plasma <= plasma.cSharedLibrary  : libplasma.soInstall        : libplasma.so => libs/armeabi-v7a/libplasma.soreal	0m0.114suser	0m0.052ssys	0m0.008sluogw@luogw-pc:~/study/bitmap-plasma$ ccache -scache directory                     /home/luogw/.ccachecache hit (direct)                     2cache hit (preprocessed)               0cache miss                             2called for link                        4multiple source files                  4files in cache                         6cache size                           108 Kbytesmax cache size                       1.0 Gbytes

参考文章:

1)

2)

转载地址:http://blmbi.baihongyu.com/

你可能感兴趣的文章
8.X版本的node打包时,gulp命令报错 require.extensions.hasownproperty
查看>>
Jenkins 启动命令
查看>>
Maven项目版本继承 – 我必须指定父版本?
查看>>
Maven跳过单元测试的两种方式
查看>>
通过C++反射实现C++与任意脚本(lua、js等)的交互(二)
查看>>
利用清华镜像站解决pip超时问题
查看>>
[leetcode BY python]1两数之和
查看>>
微信小程序开发全线记录
查看>>
Centos import torchvision 出现 No module named ‘_lzma‘
查看>>
Maximum Subsequence Sum
查看>>
PTA:一元多项式的加乘运算
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
Django 的Error: [Errno 10013]错误
查看>>
机器学习实战之决策树(一)
查看>>
[LeetCode By Python] 2 Add Two Number
查看>>
python 中的 if __name__=='__main__' 作用
查看>>