Difference between revisions of "Building Software from an External Source"

From KoanSoftware Wiki
Jump to: navigation, search
(Created page with "== Building Software from an External Source using Yocto Project / Openembedded == By default, the OpenEmbedded build system uses the Build Directory when building source cod...")
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Building Software from an External Source using Yocto Project / Openembedded ==
+
== Building Software from an External Source using Yocto Project - local source tree  ==
 +
 
 +
I have a local source tree I want to build instead of the upstream source a recipe normally fetches, how do I do that?
  
 
By default, the OpenEmbedded build system uses the Build Directory when building source code. The build process involves fetching the source files, unpacking them, and then patching them if necessary before the build takes place.
 
By default, the OpenEmbedded build system uses the Build Directory when building source code. The build process involves fetching the source files, unpacking them, and then patching them if necessary before the build takes place.
Line 5: Line 7:
 
Situations exist where you might want to build software from source files that are external to and thus outside of the OpenEmbedded build system. For example, suppose you have a project that includes a new BSP with a heavily customized kernel. And, you want to minimize exposing the build system to the development team so that they can focus on their project and maintain everyone's workflow as much as possible. In this case, you want a kernel source directory on the development machine where the development occurs. You want the recipe's SRC_URI variable to point to the external directory and use it as is, not copy it.
 
Situations exist where you might want to build software from source files that are external to and thus outside of the OpenEmbedded build system. For example, suppose you have a project that includes a new BSP with a heavily customized kernel. And, you want to minimize exposing the build system to the development team so that they can focus on their project and maintain everyone's workflow as much as possible. In this case, you want a kernel source directory on the development machine where the development occurs. You want the recipe's SRC_URI variable to point to the external directory and use it as is, not copy it.
  
To build from software that comes from an external source, all you need to do is inherit the externalsrc class and then set the EXTERNALSRC variable to point to your external source code. Here are the statements to put in your local.conf file:
 
  
    INHERIT += "externalsrc"
+
in this case use the externalsrc class - you can inherit this in the original bb recipe or a bbappend:
    EXTERNALSRC_pn-myrecipe = "path-to-your-source-tree"
+
 
 +
  inherit externalsrc
 +
  EXTERNALSRC = "/path/to/sources"
 +
 
 +
 
 +
Depending on the type of build (eg, 'inherit module' for out of tree Linux kernel modules) you may or may not need to set EXTERNALSRC_BUILD.
 +
 
 +
  inherit externalsrc
 +
  EXTERNALSRC = "/some/path"
 +
  EXTERNALSRC_BUILD = "/some/path"
 +
 
 +
 
 +
 
 +
If you're going to use it across a number of recipes you can inherit it globally at the configuration level (perhaps via an inc file that you include/require there):
 +
 
 +
  INHERIT += "externalsrc"
 +
  EXTERNALSRC_pn-<recipename> = "/path/to/sources"
 +
 
 +
 
 +
Recipe example using an external source for nInvaders package
 +
 
 +
<pre><nowiki>
 +
 
 +
#
 +
# Recipe example with externalsrc
 +
#
 +
# (C)2019 Marco Cavallini - KOAN - <https://koansoftware.com>
 +
#
 +
 
 +
LICENSE = "CLOSED"
 +
LIC_FILES_CHKSUM = ""
 +
 
 +
inherit externalsrc
 +
 
 +
EXTERNALSRC = "/home/koan/yocto-qemuarm-sumo/ninvaders-0.1.1"
 +
EXTERNALSRC_BUILD = "${EXTERNALSRC}"
 +
 
 +
DEPENDS = "ncurses"
 +
 
 +
EXTRA_OEMAKE = "-e"
 +
 
 +
 
 +
do_install() {
 +
install -d ${D}${bindir}
 +
install -m 0755 nInvaders ${D}${bindir}
 +
}
 +
 
 +
FILES_${PN} = "${bindir}/*"
 +
 
 +
</nowiki></pre>

Latest revision as of 07:15, 3 August 2023

Building Software from an External Source using Yocto Project - local source tree

I have a local source tree I want to build instead of the upstream source a recipe normally fetches, how do I do that?

By default, the OpenEmbedded build system uses the Build Directory when building source code. The build process involves fetching the source files, unpacking them, and then patching them if necessary before the build takes place.

Situations exist where you might want to build software from source files that are external to and thus outside of the OpenEmbedded build system. For example, suppose you have a project that includes a new BSP with a heavily customized kernel. And, you want to minimize exposing the build system to the development team so that they can focus on their project and maintain everyone's workflow as much as possible. In this case, you want a kernel source directory on the development machine where the development occurs. You want the recipe's SRC_URI variable to point to the external directory and use it as is, not copy it.


in this case use the externalsrc class - you can inherit this in the original bb recipe or a bbappend:

 inherit externalsrc
 EXTERNALSRC = "/path/to/sources"


Depending on the type of build (eg, 'inherit module' for out of tree Linux kernel modules) you may or may not need to set EXTERNALSRC_BUILD.

 inherit externalsrc
 EXTERNALSRC = "/some/path"
 EXTERNALSRC_BUILD = "/some/path"


If you're going to use it across a number of recipes you can inherit it globally at the configuration level (perhaps via an inc file that you include/require there):

 INHERIT += "externalsrc"
 EXTERNALSRC_pn-<recipename> = "/path/to/sources"


Recipe example using an external source for nInvaders package


#
# Recipe example with externalsrc
#
# (C)2019 Marco Cavallini - KOAN - <https://koansoftware.com>
#

LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""

inherit externalsrc

EXTERNALSRC = "/home/koan/yocto-qemuarm-sumo/ninvaders-0.1.1"
EXTERNALSRC_BUILD = "${EXTERNALSRC}"

DEPENDS = "ncurses"

EXTRA_OEMAKE = "-e"


do_install() {
	install -d ${D}${bindir}
	install -m 0755 nInvaders ${D}${bindir}
}

FILES_${PN} = "${bindir}/*"