[yocto] Managing multiple builds

Ulf Samuelsson yocto at emagii.com
Thu Feb 14 08:27:34 PST 2019


Den 2019-02-14 kl. 10:00, skrev Alexander Kanavin:
> On Thu, 14 Feb 2019 at 01:35, Timothy Froehlich <tfroehlich at archsys.io> wrote:
>> Hi, I've been struggling a bit with this question. I want to use Yocto to build two+ products with separate dev/prod images for each (dev including debug-tweaks, etc.). I've ruled out separate image recipes because my dev builds need ENABLE_UART on my RaspberryPi and that needs to be set at the conf level (I've got it set conditionally in my base dist conf). Multiconfig looked promising, but I'm not happy about how long the parsing takes to start a build. "--postread" looked nice, but I've barely seen it mentioned so I'm worried that it's not well supported.
>>
> 
> Which recipes use the ENABLE_UART setting? You might want to write two
> variants of those, and include them into images accordingly.
> 
> Alex
> 

Some guys I know solved the problem a little bit differently, and they 
did not mind to share.
I created a meta-layer with that and some other ideas.

* https://github.com/emagii/meta-map-sheriffco

An example recipe is:
==================================
SUMMARY = ""
DESCRIPTION = ""

inherit license-mit

SRC_URI = " \
	file://class/class-recipe.c \
	file://class/Makefile \
"

EXTRA_OEMAKE_class-development = 'CFLAGS="${CFLAGS} -DDEVELOPMENT"'
EXTRA_OEMAKE_class-production  = 'CFLAGS="${CFLAGS} -DPRODUCTION"'
EXTRA_OEMAKE_class-release     = 'CFLAGS="${CFLAGS} -DRELEASE"'

do_install-class-development () {
	install	-d	${D}${bindir}
	install	-m 0755	class	${D}${bindir}/development
}

do_install-class-production () {
	install	-d	${D}${bindir}
	install	-m 0755	class	${D}${bindir}/production
}

do_install-class-release () {
	install	-d	${D}${bindir}
	install	-m 0755	class	${D}${bindir}/release
}

BBCLASSEXTEND = "development production release"
==================================
You now have the same recipe which builds four package variants.

<package>,
<package>-development,
<package>-production,
<package>-release,

The base package is not included in any image.
In the development image, you install the <package>-development and so on.
==================================
Three bbclasses are used, one for each special package.

Here is the development.bbclass
==================================
# Class for use in BBCLASSEXTEND to make it easier to have a single 
recipe that
# build and generate packages separately for development and normal images.
#
# Usage:
# BBCLASSEXTEND = "development"

CLASSOVERRIDE .= ":class-development"

python development_virtclass_handler () {
     # Do nothing if this is inherited, as it's for BBCLASSEXTEND
     if "development" not in (d.getVar('BBCLASSEXTEND') or ""):
         bb.error("Don't inherit development, use BBCLASSEXTEND")
         return

     # Restore BPN
     bpn = d.getVar('BPN')
     newbpn = bpn.replace('-development', '')
     d.setVar('BPN', newbpn)

     # Use default FILESPATH searching for patches and files
     filespath = d.getVar('FILESPATH')
     newfilespath = filespath.replace('-development', '')
     d.setVar('FILESPATH', newfilespath)
}

addhandler development_virtclass_handler
development_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"

==================================

-- 
Best Regards
Ulf Samuelsson


More information about the yocto mailing list