Install Gentoo on Mac-Mini
Cpp Memo part 5 -- Conditionals

(ubuntu)在andorid andk工程中使用ccache加速编译速度 (Repost)

tubo posted @ 2014年11月07日 14:14 in 未分类 , 2062 阅读

环境

系统: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 -s
cache directory                     /home/luogw/.ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
files in cache                         0
cache size                             0 Kbytes
max cache size                       1.0 Gbytes
luogw@luogw-pc:~/study/bitmap-plasma$ time ndk-build
Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi-v7a/gdbserver
Gdbsetup       : libs/armeabi-v7a/gdb.setup
Compile thumb  : plasma <= plasma.c
SharedLibrary  : libplasma.so
Install        : libplasma.so => libs/armeabi/libplasma.so
Compile thumb  : plasma <= plasma.c
SharedLibrary  : libplasma.so
Install        : libplasma.so => libs/armeabi-v7a/libplasma.so

real	0m0.226s
user	0m0.128s
sys	0m0.032s
luogw@luogw-pc:~/study/bitmap-plasma$ ccache -s
cache directory                     /home/luogw/.ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             2
called for link                        2
multiple source files                  2
files in cache                         6
cache size                           108 Kbytes
max cache size                       1.0 Gbytes
luogw@luogw-pc:~/study/bitmap-plasma$ rm -r libs/ obj/
luogw@luogw-pc:~/study/bitmap-plasma$ time ndk-build
Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi-v7a/gdbserver
Gdbsetup       : libs/armeabi-v7a/gdb.setup
Compile thumb  : plasma <= plasma.c
SharedLibrary  : libplasma.so
Install        : libplasma.so => libs/armeabi/libplasma.so
Compile thumb  : plasma <= plasma.c
SharedLibrary  : libplasma.so
Install        : libplasma.so => libs/armeabi-v7a/libplasma.so

real	0m0.114s
user	0m0.052s
sys	0m0.008s
luogw@luogw-pc:~/study/bitmap-plasma$ ccache -s
cache directory                     /home/luogw/.ccache
cache hit (direct)                     2
cache hit (preprocessed)               0
cache miss                             2
called for link                        4
multiple source files                  4
files in cache                         6
cache size                           108 Kbytes
max cache size                       1.0 Gbytes


 

参考文章:

1)http://www.41post.com/4509/programming/android-use-ccache-with-android-ndk-in-cygwin

2)http://www.mirwing.com/2011/11/android-android-ndk-revision-7.html

 

http://blog.csdn.net/scholar_ii/article/details/9615979

 

 

 

 

 

 

 

XE88 apk download 说:
2021年8月29日 05:01

On that website page, you'll see your description, why not read through this.

Satta king 说:
2021年9月24日 10:07

I wrote about a similar issue, I give you the link to my site.

BSEM 11th Question P 说:
2022年8月16日 03:05

Under the provisions of the Manipur Higher Secondary Act, the Council of Higher Education, Manipur was established in 1992 with the primary goal of developing the educational system in the state. Prior to the establishment of this council, the Board of Secondary Education ran 9th+2 programmes in the state. BSEM 11th Question Paper 2023 The university in this state occupies 287 acres and includes one constituent institution in addition to the 72 colleges that are connected with its board. The council of higher secondary education administered the tests, and there were around 29,593 pupils who registered to take them.

Alyssa 说:
2022年12月30日 04:07

"CCache is a tool that can speed up compilation in Android andk projects by caching previous compilations. This can be especially helpful if you are constantly recompiling the diamond rings same code. To use ccache, you need to first install it on your system. You can then add the following line to your ~/.bashrc file: export USE_CCACHE=1 Once you have done this, you can simply run ""ccache"" instead of ""gcc"" or ""g++"" when compiling your code. "

seo service london 说:
2024年1月13日 03:26

I just thought it may be an idea to post incase anyone else was having problems researching but I am a little unsure if I am allowed to put names and addresses on here

seo service london 说:
2024年1月13日 03:26

I just thought it may be an idea to post incase anyone else was having problems researching but I am a little unsure if I am allowed to put names and addresses on here


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter