BitBake recipe

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Added the S switch I had to search for hours for until I found it.)
m (Standard tasks in a recipe)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Bitbake ==
 
== Bitbake ==
BitBake is a build tool for executing tasks and managing metadata.It was inspired by Portage, the package management system used by the Gentoo Linux distribution. BitBake is the basis of the OpenEmbedded project, which is being used to build and maintain OpenMoko.  
+
BitBake is a build tool for executing tasks and managing metadata.It was inspired by Portage, the package management system used by the Gentoo Linux distribution. BitBake is the basis of the OpenEmbedded project, which is being used to build and maintain Openmoko.  
  
 
For the user guide of Bitbake, please visit the site : [http://bitbake.berlios.de/manual/]  
 
For the user guide of Bitbake, please visit the site : [http://bitbake.berlios.de/manual/]  
Line 46: Line 46:
 
1. do_fetch : Fetch the source files from the URI given in the SRC_URI.  
 
1. do_fetch : Fetch the source files from the URI given in the SRC_URI.  
  
2. do_configure : for doing the configuration
+
2. do_unpack : Unpack the source files into WORKDIR.
  
3. do_compile : To compile the program(s) using a compiler specified by CC variable.
+
3. do_patch : Patch the source code, if necessary, before configuration.  
  
4. do_build : To build the package including its build-time dependencies.
+
4. do_configure : for doing the configuration
  
5. do_install : To install the package on the filesystem i.e copy the binaries where required.  
+
5. do_compile : To compile the program(s) using a compiler specified by CC variable.
 +
 
 +
6. do_build : To build the package including its build-time dependencies.
 +
 
 +
7. do_install : To install the package on the filesystem i.e copy the binaries where required.  
  
 
You can define your own tasks (as many as you like) which can also be python functions.  
 
You can define your own tasks (as many as you like) which can also be python functions.  
Line 60: Line 64:
 
             echo "Hello, world!"
 
             echo "Hello, world!"
 
     }
 
     }
 +
 +
You can list all tasks for a given recipe with 'bitbake -c listtasks <package_name>'.
 +
 +
For packages that are built with autotools (automake, autoconf, etc), it is often only necessary to inherit autotools.bbclass, define SRC_URI, and sometimes define do_patch in the .bb file. All BitBake classes inherit from base.bbclass, where the default implementations for most tasks are defined.
  
 
=== A Basic Bitbake Recipe [http://wiki.openmoko.org/wiki/Application_Development_Crash_Course#Filling_the_Files] ===
 
=== A Basic Bitbake Recipe [http://wiki.openmoko.org/wiki/Application_Development_Crash_Course#Filling_the_Files] ===
 +
 +
[[Category:Application Developer]]

Latest revision as of 17:39, 10 February 2009

Contents

[edit] Bitbake

BitBake is a build tool for executing tasks and managing metadata.It was inspired by Portage, the package management system used by the Gentoo Linux distribution. BitBake is the basis of the OpenEmbedded project, which is being used to build and maintain Openmoko.

For the user guide of Bitbake, please visit the site : [1]


[edit] Bitbake Recipe

The literal meaning of a recipe is that it is a direction to making something. Similarly, a bitbake recipe tells bitbake how to build a particular package X. It includes all the package dependencies, sources to fetch the source code from, configuration, compilation, build, install and remove instructions. Apart from this, it also stores the meta data for the package in certain standard variables.


[edit] Some Standard Variables in a Bitbake recipe

1. DESCRIPTION = "This application will print hello world on your screen" : Gives the description of the application that you are developing

2. AUTHOR = "Deepank Gupta" : Gives name of the author of the package. Similar variables can be defined such as HOMEPAGE, LICENSE, SECTION etc.

3. PN = "Helloworld" : This specifies the package name of the package excluding the version number of the package. The version number is specified by PV and revision number by PR variable.

4. DEPENDS = "X Y Z" : With regard to dependencies, it expects the .bb to define a DEPENDS variable, which contains a space seperated list of “package names”. In the above example the package is dependent on X, Y and Z packages. The run-time dependencies of a package are specified by the variable RDEPENDS.

5. PROVIDES += "virtual/package" : This specifies the functionality provided by the bitbake recipe.

6. PREFERRED_VERSION_a = "1.1" : This specifies the preferred version of a package named a. This is used if there are more than 1 versions of a same package such as a-1.1.bb and a-1.2.bb

7. SRC_URI = "file://myhelloworld.c" : This specifies the source address from where to fetch the source files. It can fetch from local disk using file:// , websites using http:// , cvs and svn using cvs:// and svn:// and others like ftp, git etc.

8. S = "${WORKDIR}/trunk" This might be used in order to specify which folder our package extracts to. Normally it looks like ${WORKDIR}/${PN}_${PV} if the package was generated by the autotools - which is the value this variable automatically points to when not set by the receipe. In the case this example shows it points to a folder named trunk - which might be useful for a reciepe that builds the last version from SVN.

[edit] Some variables specific to Openmoko recipes

$WORKDIR = $OMDIR/local/packages/<application directory>
$bindir  = $OMDIR/build/tmp/work/armv4t-linux/<application directory>/image/usr/bin
$docir   = $OMDIR/build/tmp/work/armv4t-linux/<application directory>/image/usr/share/doc
$D       = $OMDIR/build/


[edit] Standard tasks in a recipe

1. do_fetch : Fetch the source files from the URI given in the SRC_URI.

2. do_unpack : Unpack the source files into WORKDIR.

3. do_patch : Patch the source code, if necessary, before configuration.

4. do_configure : for doing the configuration

5. do_compile : To compile the program(s) using a compiler specified by CC variable.

6. do_build : To build the package including its build-time dependencies.

7. do_install : To install the package on the filesystem i.e copy the binaries where required.

You can define your own tasks (as many as you like) which can also be python functions. eg.

   do_mytask () {
           echo "Hello, world!"
   }

You can list all tasks for a given recipe with 'bitbake -c listtasks <package_name>'.

For packages that are built with autotools (automake, autoconf, etc), it is often only necessary to inherit autotools.bbclass, define SRC_URI, and sometimes define do_patch in the .bb file. All BitBake classes inherit from base.bbclass, where the default implementations for most tasks are defined.

[edit] A Basic Bitbake Recipe [2]

Personal tools

Bitbake

BitBake is a build tool for executing tasks and managing metadata.It was inspired by Portage, the package management system used by the Gentoo Linux distribution. BitBake is the basis of the OpenEmbedded project, which is being used to build and maintain OpenMoko.

For the user guide of Bitbake, please visit the site : [1]


Bitbake Recipe

The literal meaning of a recipe is that it is a direction to making something. Similarly, a bitbake recipe tells bitbake how to build a particular package X. It includes all the package dependencies, sources to fetch the source code from, configuration, compilation, build, install and remove instructions. Apart from this, it also stores the meta data for the package in certain standard variables.


Some Standard Variables in a Bitbake recipe

1. DESCRIPTION = "This application will print hello world on your screen" : Gives the description of the application that you are developing

2. AUTHOR = "Deepank Gupta" : Gives name of the author of the package. Similar variables can be defined such as HOMEPAGE, LICENSE, SECTION etc.

3. PN = "Helloworld" : This specifies the package name of the package excluding the version number of the package. The version number is specified by PV and revision number by PR variable.

4. DEPENDS = "X Y Z" : With regard to dependencies, it expects the .bb to define a DEPENDS variable, which contains a space seperated list of “package names”. In the above example the package is dependent on X, Y and Z packages. The run-time dependencies of a package are specified by the variable RDEPENDS.

5. PROVIDES += "virtual/package" : This specifies the functionality provided by the bitbake recipe.

6. PREFERRED_VERSION_a = "1.1" : This specifies the preferred version of a package named a. This is used if there are more than 1 versions of a same package such as a-1.1.bb and a-1.2.bb

7. SRC_URI = "file://myhelloworld.c" : This specifies the source address from where to fetch the source files. It can fetch from local disk using file:// , websites using http:// , cvs and svn using cvs:// and svn:// and others like ftp, git etc.

8. S = "${WORKDIR}/trunk" This might be used in order to specify which folder our package extracts to. Normally it looks like ${WORKDIR}/${PN}_${PV} if the package was generated by the autotools - which is the value this variable automatically points to when not set by the receipe. In the case this example shows it points to a folder named trunk - which might be useful for a reciepe that builds the last version from SVN.

Some variables specific to Openmoko recipes

$WORKDIR = $OMDIR/local/packages/<application directory>
$bindir  = $OMDIR/build/tmp/work/armv4t-linux/<application directory>/image/usr/bin
$docir   = $OMDIR/build/tmp/work/armv4t-linux/<application directory>/image/usr/share/doc
$D       = $OMDIR/build/


Standard tasks in a recipe

1. do_fetch : Fetch the source files from the URI given in the SRC_URI.

2. do_configure : for doing the configuration

3. do_compile : To compile the program(s) using a compiler specified by CC variable.

4. do_build : To build the package including its build-time dependencies.

5. do_install : To install the package on the filesystem i.e copy the binaries where required.

You can define your own tasks (as many as you like) which can also be python functions. eg.

   do_mytask () {
           echo "Hello, world!"
   }

A Basic Bitbake Recipe [2]