[FE training-materials-updates] Add ccache instructions

Maxime Ripard maxime.ripard at free-electrons.com
Fri Oct 18 17:13:14 CEST 2013


Repository : git://git.free-electrons.com/training-materials.git

On branch  : jelly-bean
Link       : http://git.free-electrons.com/training-materials/commit/?id=1e633c7c88fd3ebbafc6089380ca0828bf588b87

>---------------------------------------------------------------

commit 1e633c7c88fd3ebbafc6089380ca0828bf588b87
Author: Maxime Ripard <maxime.ripard at free-electrons.com>
Date:   Fri Oct 18 17:12:20 2013 +0200

    Add ccache instructions
    
    Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>


>---------------------------------------------------------------

1e633c7c88fd3ebbafc6089380ca0828bf588b87
 .../android-first-compilation.tex                  |   32 ++++++++++++++++++++
 labs/android-new-board/android-new-board.tex       |   14 +++++++++
 labs/android-source-code/android-source-code.tex   |   13 ++++++++
 3 files changed, 59 insertions(+)

diff --git a/labs/android-first-compilation/android-first-compilation.tex b/labs/android-first-compilation/android-first-compilation.tex
index 6bd94fb..843a982 100644
--- a/labs/android-first-compilation/android-first-compilation.tex
+++ b/labs/android-first-compilation/android-first-compilation.tex
@@ -10,6 +10,16 @@ During this lab, you will:
 
 Stay in the \code{$HOME/felabs/android/source} directory.
 
+\section{Set up ccache}
+
+To be able to use \code{ccache} properly, we need to apply a commit
+present in the AOSP master that will bump the version of ccache to a
+more recent and much more adapted version of \code{ccache}.
+
+To do so, go in the \code{prebuilts/misc} directory, and use the
+command \code{git cherry-pick 81012983}. This will apply the given
+commit in our current branch.
+
 \section{Build environment}
 
 Now that \code{repo sync} is over, we will compile an Android system
@@ -33,6 +43,16 @@ You will see that \code{build/envsetup.sh} hasn't modified your
 The target product for the emulator is {\it full}, and we want to
 have an engineering build. To do this, run \code{lunch full-eng}
 
+Now, to tell Android to use \code{ccache} whenever possible, we need
+to set a few environment variable.
+
+\begin{verbatim}
+export USE_CCACHE=1
+export CCACHE_DIR=$HOME/felabs/android/ccache
+\end{verbatim}
+
+And that's it!
+
 \section{Compile the root filesystem}
 
 The build system will use the proper setup to build this
@@ -57,6 +77,18 @@ specifying the double number of parallel jobs:
 make -j 8
 \end{verbatim}
 
+While this command runs, make sure you are actually using ccache
+properly: in another terminal, set the \code{CCACHE_DIR} environment
+variable like we did, and use the command
+
+\begin{verbatim}
+watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s
+\end{verbatim}
+
+After a few minutes, you should see the number of cache hits
+increasing, while the number of cache misses remain very low. If
+that's not the case, call your instructor.
+
 Go grab (several cups of) coffee!
 
 \paragraph{Known issue}
diff --git a/labs/android-new-board/android-new-board.tex b/labs/android-new-board/android-new-board.tex
index c5b45d9..982991f 100644
--- a/labs/android-new-board/android-new-board.tex
+++ b/labs/android-new-board/android-new-board.tex
@@ -31,6 +31,13 @@ Now, let's run the big download job:
 repo sync -c -j4
 \end{verbatim}
 
+We then need to reapply our \code{ccache} commit.
+\begin{verbatim}
+cd prebuilts/misc
+git cherry-pick 81012983
+cd ../..
+\end{verbatim}
+
 \section{Build Android for the BeagleBone Black}
 
 As we said earlier, rowboat already includes support for the
@@ -42,6 +49,13 @@ source build/envsetup.sh
 lunch beagleboneblack-eng
 \end{verbatim}
 
+Make sure we are using \code{ccache}:
+
+\begin{verbatim}
+export USE_CCACHE=1
+export CCACHE_DIR=$HOME/felabs/android/ccache
+\end{verbatim}
+
 And finally, we can start the compilation:
 
 \begin{verbatim}
diff --git a/labs/android-source-code/android-source-code.tex b/labs/android-source-code/android-source-code.tex
index 3ea29de..5e06196 100644
--- a/labs/android-source-code/android-source-code.tex
+++ b/labs/android-source-code/android-source-code.tex
@@ -111,3 +111,16 @@ Now, we can install the latest JDK version with the command:
 \begin{verbatim}
 sudo apt-get install oracle-java6-installer
 \end{verbatim}
+
+Follow the steps asked, and you should be all set!
+
+\section{Install the ccache}
+
+Jelly Bean takes a lot of time to compile. Fortunately, we can use a
+tool called \code{ccache} to speed it up. \code{ccache} caches the
+object files compiled for a given project, so that whenever you need
+them once again, you don't have to actually cache them.
+
+Ask your trainer for a pre-filled ccache archive that we will use to
+speed up a lot the compilation. Once you have retrieved the archive,
+extract it in the \code{$HOME/felabs/android/} directory.



More information about the training-materials-updates mailing list