Sometimes, you need to add pre-compiled binaries to an
image.
For example, suppose that binaries for proprietary code
exist, which are created by a particular division of a
company.
Your part of the company needs to use those binaries as
part of an image that you are building using the
OpenEmbedded build system.
Since you only have the binaries and not the source code,
you cannot use a typical recipe that expects to fetch the
source specified in
SRC_URI
and then compile it.
One method is to package the binaries and then install them as part of the image. Generally, it is not a good idea to package binaries since, among other things, it can hinder the ability to reproduce builds and could lead to compatibility problems with ABI in the future. However, sometimes you have no choice.
The easiest solution is to create a recipe that uses
the
bin_package
class and to be sure that you are using default locations
for build artifacts.
In most cases, the bin_package
class
handles "skipping" the configure and compile steps as well
as sets things up to grab packages from the appropriate
area.
In particular, this class sets noexec
on both the
do_configure
and
do_compile
tasks, sets
FILES_${PN}
to "/" so that it picks
up all files, and sets up a
do_install
task, which effectively copies all files from
${S}
to ${D}
.
The bin_package
class works well when
the files extracted into ${S}
are
already laid out in the way they should be laid out
on the target.
For more information on these variables, see the
FILES
,
PN
,
S
,
and
D
variables in the Yocto Project Reference Manual's variable
glossary.
Using
DEPENDS
is a good idea even for components distributed
in binary form, and is often necessary for
shared libraries.
For a shared library, listing the library
dependencies in
DEPENDS
makes sure that
the libraries are available in the staging
sysroot when other recipes link against the
library, which might be necessary for
successful linking.
Using DEPENDS
also
allows runtime dependencies between packages
to be added automatically.
See the
"Automatically Added Runtime Dependencies"
section in the Yocto Project Overview and
Concepts Manual for more information.
If you cannot use the bin_package
class, you need to be sure you are doing the following:
Create a recipe where the
do_configure
and
do_compile
tasks do nothing:
It is usually sufficient to just not define these
tasks in the recipe, because the default
implementations do nothing unless a Makefile is
found in
${
S
}
.
If
${S}
might contain a Makefile,
or if you inherit some class that replaces
do_configure
and
do_compile
with custom
versions, then you can use the
[
noexec
]
flag to turn the tasks into no-ops, as follows:
do_configure[noexec] = "1" do_compile[noexec] = "1"
Unlike
deleting the tasks
,
using the flag preserves the dependency chain from
the
do_fetch
, do_unpack
,
and
do_patch
tasks to the
do_install
task.
Make sure your
do_install
task installs the
binaries appropriately.
Ensure that you set up
FILES
(usually
FILES_${
PN
}
)
to point to the files you have installed, which of
course depends on where you have installed them
and whether those files are in different locations
than the defaults.