\subsection{Configuration of the Build System}
\begin{frame}
  \frametitle{Configuration}
  \begin{itemize}
  \item The Android build system is not much configurable compared to
    other build systems, but it is possible to modify to some extent
  \item Among the several configuration options you have, you can add
    extra flags for the C compiler, have a given package built with
    debug options, specify the output directory, and first of all, choose what
    product you want to build.
  \item This is done either through the \code{lunch} command or
    through a \code{buildspec.mk} file placed at the top of the source
    directory
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{lunch}
  \begin{itemize}
  \item \code{lunch} is a shell function defined in \code{build/envsetup.sh}
  \item It is the easiest way to configure a build. You can either
    launch it without any argument and it will ask to choose among a list
    of known ``combos'' or launch it with the desired combos as argument.
  \item It sets the environment variables needed for the build and
    allows to start compiling at last
  \item You can declare new combos through the \code{add_lunch_combo}
    command
  \item These combos are the aggregation of the product to build and
    the variant to use (basically, which set of modules to install)
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Variables Exported by Lunch}
  \begin{itemize}
  \item \code{TARGET_PRODUCT}
    \begin{itemize}
    \item Which product to build. To build for the emulator, you will
      have either \code{generic} or \code{full}, which contains more
      apps and more locales
    \end{itemize}
  \item \code{TARGET_BUILD_VARIANT}
    \begin{itemize}
    \item Select which set of modules to build, among
      \begin{itemize}
      \item \emph{user}: Includes modules tagged \code{user}
        (\code{Phone})
      \item \emph{userdebug}: Includes modules tagged \code{user} or
        \code{debug} (\code{strace})
      \item \emph{eng}: Includes modules tagged \code{user}, \code{debug}
        or \code{eng}: (\code{e2fsprogs})
      \end{itemize}
    \end{itemize}
  \item \code{TARGET_SIMULATOR}
    \begin{itemize}
    \item Are we building the simulator? (different from the \emph{emulator})
    \end{itemize}
  \item \code{TARGET_BUILD_TYPE}
    \begin{itemize}
    \item Either \code{release} or \code{debug}. If \code{debug} is
      set, it will enable some debug options across the whole system.
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{buildspec.mk}
  \begin{itemize}
  \item While \code{lunch} is convenient to quickly switch from one
    configuration to another. If you have only one product or
    you want to do more fine-grained configuration, this is not
    really convenient
  \item The file \code{buildspec.mk} is here for that.
  \item If you place it at the top of the sources, it will be used by
    the build system to get its configuration instead of relying on
    the environment variables
  \item It offers more variables to modify, such as compiling a
    given module with debugging symbols, additional C compiler
    flags, change the output directory...
  \item A sample is available in \code{build/buildspec.mk.default},
    with lots of comments on the various variables.
  \end{itemize}
\end{frame}
