Once when files related to Makefile (*.mk) is changed, it is necessary to do “make clean; make”.
This is time-consuming work. It can reduce time using ccache. It is very easy to use ccache to build Android.
What is ccache?
See this page. http://ccache.samba.org/
When the first compiling, ccache preserves the compilation result in another directory. And, it is checked whether a content and an optional compilation of last time and the file are corresponding at the following compilation, and uses the content preserved instead of actually compiling when agreeing.
It is C/C++/Objective-C/Objective-C++ that ccache supports, and is not supported Java.
Speed up effect will come after the second time build.
And remember that the large amount of disk is consumed to preserve the compilation result.
Using ccache to build Android
It is very easy to use ccache to build Android. Only add “USE_CCACHE=1” to environment variables or make variables.It is not necessary to install it newly because the ccache command is already in the prebuilt directory.
One line is added to build.sh, which is used at previous post.
$ cat build.sh export ARCH_ARM_HAVE_TLS_REGISTER=true export TARGET_ARCH_VARIANT=armv7-a-neon export TARGET_CPU_SMP=true export WITH_JIT=true export JS_ENGINE=v8 export USE_CCACHE=1 time make -j8 showcommands > make.log 2>&1
My build machine is Ubuntu 10.04, CPU: Intel Core i7 950 @3.07GHz, memory 12GB.
The first time build
$ rm -rf out $ ./build.sh real 14m2.447s user 111m48.370s sys 6m38.000s
The second time build
$ rm -rf out$ ./build.sh real 8m45.569s user 70m45.080s sys 4m27.270s
Look at this! Build time is reduced from 14min. to 8min.45sec. Wow.
Makefile of Android
USE_CCACHE has been treated in the following points.
ifneq ($(USE_CCACHE),) ccache := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache # prepend ccache if necessary ifneq ($(ccache),$(firstword $($(combo_target)CC))) $(combo_target)CC := $(ccache) $($(combo_target)CC) endif ifneq ($(ccache),$(firstword $($(combo_target)CXX))) $(combo_target)CXX := $(ccache) $($(combo_target)CXX) endif ccache = endif
CC and CXX have been replaced. It doesn’t influence the build of java.