[FE training-materials-updates] slides/buildroot-appdev: rework local site method / override src dir explanation

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Wed Jun 8 15:02:17 CEST 2016


Repository : git://git.free-electrons.com/training-materials.git
On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=adcea94df37334ca0a77f90b6f96e316132733cd

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

commit adcea94df37334ca0a77f90b6f96e316132733cd
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Wed Jun 8 15:02:17 2016 +0200

    slides/buildroot-appdev: rework local site method / override src dir explanation
    
    Put the emphasis on the local site method, which is more useful for
    application development, and only cover override src dir as an
    extension of that.
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


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

adcea94df37334ca0a77f90b6f96e316132733cd
 slides/buildroot-appdev/buildroot-appdev.tex       | 135 +++++++++++++--------
 .../{override-srcdir.dia => local-site-method.dia} |  40 +++---
 2 files changed, 103 insertions(+), 72 deletions(-)

diff --git a/slides/buildroot-appdev/buildroot-appdev.tex b/slides/buildroot-appdev/buildroot-appdev.tex
index 2d99b39..f0315a9 100644
--- a/slides/buildroot-appdev/buildroot-appdev.tex
+++ b/slides/buildroot-appdev/buildroot-appdev.tex
@@ -100,69 +100,106 @@ $ ./configure --host=arm-linux
   \end{itemize}
 \end{frame}
 
-\begin{frame}{The {\tt <pkg>\_OVERRIDE\_SRCDIR} mechanism}
+\begin{frame}{Building during development}
   \begin{itemize}
-  \item Very often, you don't build packages manually: Buildroot
-    builds them for you.
-  \item But Buildroot also downloads them for you, and keeps the
-    source code in the package build directory.
-  \item Not very practical during development:
+  \item Buildroot is mainly a {\em final integration} tool: it is
+    aimed at downloading and building {\bf fixed} versions of software
+    components, in a reproducible way.
+  \item When doing active development of a software component, you
+    need to be able to quickly change the code, build it, and deploy
+    it on the target.
+  \item The package build directory is temporary, and removed on
+    \code{make clean}, so making changes here is not practical
+  \item Buildroot does not automatically ``update'' your source code
+    when the package is fetched from a version control system.
+  \item Three solutions:
     \begin{itemize}
-    \item The build directory is temporary, gets removed when doing a
-      \code{make clean} or \code{make <pkg>-dirclean}
-    \item The build directory isn't checked out from your version
-      control system.
+    \item Build your software component outside of Buildroot during
+      development. Doable for software components that are easy to
+      build.
+    \item Use the \code{local} \code{SITE_METHOD} for your package
+    \item Use the \code{<pkg>_OVERRIDE_SRCDIR} mechanism
     \end{itemize}
-  \item Buildroot should, for certain packages, pick up the source
-    from a local directory.
-  \item This is exactly what \code{<pkg>_OVERRIDE_SRCDIR} allows to
-    do.
   \end{itemize}
 \end{frame}
 
-\begin{frame}{Without {\tt <pkg>\_OVERRIDE\_SRCDIR}}
+\begin{frame}[fragile]{{\tt local} site method}
   \begin{itemize}
-  \item The normal package build process, when
-    \code{<pkg>_OVERRIDE_SRCDIR} is not used, is:
-    \begin{enumerate}
-    \item Package gets downloaded as a tarball, or from a VCS
-      repository (in which case a tarball is generated)
-    \item The tarball is extracted in
-      \code{$(O)/build/<pkg>-<version>}
-    \item Then the configure, build and installs steps are executed
-    \end{enumerate}
-  \item \code{$(O)/build/<pkg>-<version>/} does not contain any VCS
-    metadata, and is a temporary directory.
-  \item Running \code{make <pkg>-reconfigure}, \code{make
-      <pkg>-rebuild}, \code{make <pkg>-reinstall} only restarts the
-    build process from one of the corresponding steps.
+  \item Allows to tell Buildroot that the source code for a package is
+    already available locally
+  \item Allows to keep your source code under version control,
+    separately, and have Buildroot always build your latest changes.
+  \item Typical project organization:
+    \begin{itemize}
+    \item \code{buildroot/}, the Buildroot source code
+    \item \code{external/}, your \code{BR2_EXTERNAL} tree
+    \item \code{custom-app/}, your custom application code
+    \item \code{custom-lib/}, your custom library
+    \end{itemize}
+  \item In your package \code{.mk} file, use:
+    \begin{block}{}
+\begin{verbatim}
+<pkg>_SITE = $(TOPDIR)/../custom-app
+<pkg>_SITE_METHOD = local
+\end{verbatim}
+    \end{block}
   \end{itemize}
 \end{frame}
 
-\begin{frame}{Effect of {\tt <pkg>\_OVERRIDE\_SRCDIR}}
+\begin{frame}{Effect of {\tt local} site method}
   \begin{itemize}
-  \item For each package, you can define a
-    \code{<pkg>_OVERRIDE_SRCDIR} variable that points to a local
-    directory containing the source code for this package.
-  \item Instead of downloading and extracting the original source,
-    Buildroot will {\em rsync} the source from the specified directory
-    to the build directory.
-  \item Invoking \code{make <pkg>-reconfigure}, \code{make
-      <pkg>-rebuild}, \code{make <pkg>-reinstall} will retrigger a
-    {\em rsync}.
+  \item For the first build, the source code of your package is {\em
+      rsync'ed} from \code{<pkg>_SITE} to the build directory, and
+    built there.
+  \item After making changes to the source code, you can run:
+    \begin{itemize}
+    \item \code{make <pkg>-reconfigure}
+    \item \code{make <pkg>-rebuild}
+    \item \code{make <pkg>-reinstall}
+    \end{itemize}
+  \item Buildroot will first {\em rsync} again the package source code
+    (copying only the modified files) and restart the build from the
+    requested step.
   \end{itemize}
 \end{frame}
 
-\begin{frame}[fragile]{Passing {\tt <pkg>\_OVERRIDE\_SRCDIR}}
+\begin{frame}{{\tt local} site method workflow}
+  \begin{center}
+    \includegraphics[height=0.8\textheight]{slides/buildroot-appdev/local-site-method.pdf}
+  \end{center}
+\end{frame}
+
+\begin{frame}{{\tt <pkg>\_OVERRIDE\_SRCDIR}}
   \begin{itemize}
-  \item \code{<pkg>_OVERRIDE_SRCDIR} can be specified:
+  \item The \code{local} site method solution is appropriate when the
+    package uses this method for all developers
+    \begin{itemize}
+    \item Requires that all developers fetch locally the source code
+      for all custom applications and libraries
+    \end{itemize}
+  \item An alternate solution is that packages for custom applications
+    and libraries fetch their source code from version control systems
+    \begin{itemize}
+    \item Using the \code{git}, \code{svn}, \code{cvs}, etc. fetching
+      methods
+    \end{itemize}
+  \item Then, locally, a user can {\bf override} how the package is
+    fetched using \code{<pkg>_OVERRIDE_SRCDIR}
     \begin{itemize}
-    \item In the package \code{.mk} file itself. Not ideal solution,
-      and identical to \code{<pkg>_SITE_METHOD = local}
-    \item In a {\em package override file}, configured in
-      \code{BR2_PACKAGE_OVERRIDE_FILE}, by default
-      \code{$(CONFIG_DIR)/local.mk.}
+    \item It tells Buildroot to not {\em download} the package source
+      code, but to copy it from a local directory.
     \end{itemize}
+  \item The package then behaves as if it was using the \code{local}
+    site method.
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]{Passing {\tt <pkg>\_OVERRIDE\_SRCDIR}}
+  \begin{itemize}
+  \item \code{<pkg>_OVERRIDE_SRCDIR} values are specified in a {\em
+      package override file}, configured in
+    \code{BR2_PACKAGE_OVERRIDE_FILE}, by default
+    \code{$(CONFIG_DIR)/local.mk.}
   \end{itemize}
 
   \begin{block}{Example \code{local.mk}}
@@ -173,12 +210,6 @@ LINUX_OVERRIDE_SRCDIR = $(HOME)/projects/linux
   \end{block}
 \end{frame}
 
-\begin{frame}{{\tt <pkg>\_OVERRIDE\_SRCDIR} workflow}
-  \begin{center}
-    \includegraphics[height=0.8\textheight]{slides/buildroot-appdev/override-srcdir.pdf}
-  \end{center}
-\end{frame}
-
 \begin{frame}{Debugging: debugging symbols and stripping}
   \begin{itemize}
   \item To use debuggers, you need the programs and libraries to be
diff --git a/slides/buildroot-appdev/override-srcdir.dia b/slides/buildroot-appdev/local-site-method.dia
similarity index 95%
rename from slides/buildroot-appdev/override-srcdir.dia
rename to slides/buildroot-appdev/local-site-method.dia
index 6679a3a..209c654 100644
--- a/slides/buildroot-appdev/override-srcdir.dia
+++ b/slides/buildroot-appdev/local-site-method.dia
@@ -126,13 +126,13 @@
         <dia:point val="35,0.5"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="30.5725,-0.27375;39.4275,1.27375"/>
+        <dia:rectangle val="30.8275,-0.3945;39.1955,1.3945"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
             <dia:string>#Make a change in
-$(HOME)/projects/libpng#</dia:string>
+$(TOPDIR)/../custom-app/#</dia:string>
           </dia:attribute>
           <dia:attribute name="font">
             <dia:font family="Latin Modern Sans" style="80" name="Courier"/>
@@ -141,7 +141,7 @@ $(HOME)/projects/libpng#</dia:string>
             <dia:real val="0.80000000000000004"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="35,0.32125"/>
+            <dia:point val="35,0.356"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>
@@ -163,12 +163,12 @@ $(HOME)/projects/libpng#</dia:string>
         <dia:point val="35,4"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="28.9913,3.49375;41.0087,4.50625"/>
+        <dia:rectangle val="29.1275,3.527;40.8945,4.473"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
-            <dia:string>#make libpng-rebuild all#</dia:string>
+            <dia:string>#make custom-app-rebuild all#</dia:string>
           </dia:attribute>
           <dia:attribute name="font">
             <dia:font family="Inconsolata" style="48" name="Courier"/>
@@ -177,7 +177,7 @@ $(HOME)/projects/libpng#</dia:string>
             <dia:real val="1.0858499824345103"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="35,4.30125"/>
+            <dia:point val="35,4.274"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>
@@ -225,15 +225,15 @@ $(HOME)/projects/libpng#</dia:string>
         <dia:point val="28,8.5"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="22.7375,6.92625;33.2625,10.0738"/>
+        <dia:rectangle val="22.5688,6.79475;33.4548,10.2053"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
             <dia:string>#Rsync code from
-$(HOME)/projects/libpng/
+$(TOPDIR)/../custom-app/
 to
-$(O)/output/build/libpng-custom/#</dia:string>
+$(O)/output/build/custom-app-custom/#</dia:string>
           </dia:attribute>
           <dia:attribute name="font">
             <dia:font family="Latin Modern Sans" style="0" name="Courier"/>
@@ -242,7 +242,7 @@ $(O)/output/build/libpng-custom/#</dia:string>
             <dia:real val="0.80000000000000004"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="28,7.52125"/>
+            <dia:point val="28,7.55825"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>
@@ -293,13 +293,13 @@ $(O)/output/build/libpng-custom/#</dia:string>
         <dia:point val="42,8.5"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="37.4913,6.92625;46.5087,10.0738"/>
+        <dia:rectangle val="38.2675,6.79475;45.756,10.2053"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
             <dia:string>#Re-run "make"
-in libpng sources
+in custom-app sources
 
 Rebuilds only what changed#</dia:string>
           </dia:attribute>
@@ -310,7 +310,7 @@ Rebuilds only what changed#</dia:string>
             <dia:real val="0.80000000000000004"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="42,7.52125"/>
+            <dia:point val="42,7.55825"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>
@@ -361,13 +361,13 @@ Rebuilds only what changed#</dia:string>
         <dia:point val="42,16.5"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="37.5138,14.9263;46.4862,18.0738"/>
+        <dia:rectangle val="37.8725,14.7948;46.151,18.2053"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
             <dia:string>#Re-run "make install"
-in libpng sources
+in custom-app sources
 
 Reinstalls to $(TARGET_DIR)#</dia:string>
           </dia:attribute>
@@ -378,7 +378,7 @@ Reinstalls to $(TARGET_DIR)#</dia:string>
             <dia:real val="0.80000000000000004"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="42,15.5213"/>
+            <dia:point val="42,15.5583"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>
@@ -429,7 +429,7 @@ Reinstalls to $(TARGET_DIR)#</dia:string>
         <dia:point val="28,16.5"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="25.0425,15.7262;30.9575,17.2737"/>
+        <dia:rectangle val="25.5338,15.63;30.4663,17.37"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
@@ -444,7 +444,7 @@ filesystem image#</dia:string>
             <dia:real val="0.80000000000000004"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="28,16.3212"/>
+            <dia:point val="28,16.37"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>
@@ -523,7 +523,7 @@ filesystem image#</dia:string>
         <dia:point val="35,23"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="34.14,22.6262;35.86,23.3737"/>
+        <dia:rectangle val="34.22,22.53;35.78,23.47"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
@@ -537,7 +537,7 @@ filesystem image#</dia:string>
             <dia:real val="0.80000000000000004"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="35,23.2212"/>
+            <dia:point val="35,23.27"/>
           </dia:attribute>
           <dia:attribute name="color">
             <dia:color val="#000000"/>




More information about the training-materials-updates mailing list