[meta-zephyr][PATCH v3] zephyr.bbclass: Remove need for MACHINEOVERRIDES for ZEPHYR_MODULES


Eilís Ní Fhlannagáin
 

From: Eilís Ní Fhlannagáin <elizabeth.flanagan@...>

This commit removes the need for calling out ZEPHYR_MODULES via
MACHINEOVERRIDES. It uses west list to figure out what ZEPHYR_MODULES
are available and attaches them to -DZEPHYR_MODULES. Additional out of
tree modules may be added via ZEPHYR_EXTRA_MODULES.

Signed-off-by: Eilís Ní Fhlannagáin <elizabeth.flanagan@...>
---
.../conf/machine/include/nrf52.inc | 2 -
.../machine/include/stm32mp1-cortex-m4.inc | 3 --
meta-zephyr-core/classes/zephyr.bbclass | 42 +++++++++++++++++++
meta-zephyr-core/conf/layer.conf | 2 +
.../zephyr-kernel/zephyr-kernel-common.inc | 13 +++---
5 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/meta-zephyr-bsp/conf/machine/include/nrf52.inc b/meta-zephyr-bsp/conf/machine/include/nrf52.inc
index d22f8bc..4162d3e 100644
--- a/meta-zephyr-bsp/conf/machine/include/nrf52.inc
+++ b/meta-zephyr-bsp/conf/machine/include/nrf52.inc
@@ -5,8 +5,6 @@

require conf/machine/include/tune-cortexm4.inc

-MACHINEOVERRIDES =. "nordic:"
-
TUNE_FEATURES = "armv7m cortexm4"

# Target type for this machine used by Pyocd
diff --git a/meta-zephyr-bsp/conf/machine/include/stm32mp1-cortex-m4.inc b/meta-zephyr-bsp/conf/machine/include/stm32mp1-cortex-m4.inc
index b82b02d..0d46620 100644
--- a/meta-zephyr-bsp/conf/machine/include/stm32mp1-cortex-m4.inc
+++ b/meta-zephyr-bsp/conf/machine/include/stm32mp1-cortex-m4.inc
@@ -5,7 +5,4 @@

require conf/machine/include/tune-cortexm4.inc

-# Include OpenAMP for communication with Cortex-A7 core of the SoC
-MACHINEOVERRIDES =. "stm32:openamp:"
-
TUNE_FEATURES = "armv7m cortexm4"
diff --git a/meta-zephyr-core/classes/zephyr.bbclass b/meta-zephyr-core/classes/zephyr.bbclass
index e1d3185..f3d16b7 100644
--- a/meta-zephyr-core/classes/zephyr.bbclass
+++ b/meta-zephyr-core/classes/zephyr.bbclass
@@ -1,4 +1,7 @@
inherit terminal
+inherit python3native
+
+PYTHONPATH="${STAGING_DIR_HOST}${libdir}/${PYTHON_DIR}/site-packages"

OE_TERMINAL_EXPORTS += "HOST_EXTRACFLAGS HOSTLDFLAGS TERMINFO CROSS_CURSES_LIB CROSS_CURSES_INC"
HOST_EXTRACFLAGS = "${BUILD_CFLAGS} ${BUILD_LDFLAGS}"
@@ -21,6 +24,45 @@ python () {
d.setVar('BOARD',board)
}

+do_get_zmods() {
+
+ export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/${libdir}/${PYTHON_DIR}/site-packages:${RECIPE_SYSROOT_NATIVE}/${libdir}/${PYTHON_DIR}"
+ cd ${S}
+
+ # I really dislike how tied in this is to west, but without reimplementing their script, this seems to be the
+ # easiest way to do this
+ rm -rf .west; mkdir .west
+ cat << EOF >> ${S}/.west/config
+[manifest]
+path = .
+file = west.yml
+EOF
+
+ # Because of how we structure things, we need to either structure this more like a west workspace or just tweak
+ # the manifest in order to get access to the west extentions like build and whatnot. Tweaking the manifest is the
+ # easier path here and minimizes the amount of breakage that might occur.
+
+ sed -i 's/path: zephyr/path: ./' west.yml
+
+ # Get all available modules and add them to ZEPHYR_MODULES
+ for i in $(west list|awk 'NR>1 {print $2}'); do
+ ZEPHYR_MODULES="${S}/$i\;${ZEPHYR_MODULES}"
+ done
+ export ZEPHYR_MODULES
+}
+
+do_get_zmods[nostamp] = "1"
+do_get_zmods[dirs] = "${B}"
+
+EXTRA_OECMAKE:append = " -DZEPHYR_MODULES=${ZEPHYR_MODULES}"
+
+addtask get_zmods after do_patch before do_configure
+do_get_zmods[depends] += "west-native:do_populate_sysroot"
+do_get_zmods[depends] += "python3-pyyaml-native:do_populate_sysroot"
+do_get_zmods[depends] += "python3-pykwalify-native:do_populate_sysroot"
+do_get_zmods[depends] += "python3-colorama-native:do_populate_sysroot"
+do_get_zmods[depends] += "python3-pyelftools-native:do_populate_sysroot"
+
python do_menuconfig() {
os.chdir(d.getVar('ZEPHYR_SRC_DIR', True))
configdir = d.getVar('ZEPHYR_SRC_DIR', True) + '/outdir/' + d.getVar('BOARD', True)
diff --git a/meta-zephyr-core/conf/layer.conf b/meta-zephyr-core/conf/layer.conf
index 4b1bf91..d3ac10e 100644
--- a/meta-zephyr-core/conf/layer.conf
+++ b/meta-zephyr-core/conf/layer.conf
@@ -18,3 +18,5 @@ LAYERDEPENDS_zephyrcore = "core meta-python"
LAYERSERIES_COMPAT_zephyrcore = "dunfell gatesgarth hardknott honister"

X86_TUNE_DIR = "${@bb.utils.contains('LAYERSERIES_CORENAMES', 'honister', 'include/x86', 'include', d)}"
+
+PYTHON3_NATIVE_SITEPACKAGES_DIR = "${libdir_native}/${PYTHON3_DIR}/site-packages"
diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
index 5ae7504..e69ba3c 100644
--- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
+++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
@@ -2,7 +2,6 @@

ZEPHYR_INHERIT_CLASSES += "zephyr cmake"
inherit ${ZEPHYR_INHERIT_CLASSES}
-inherit python3native

# There shouldn't be a manifest for zephyr kernels since there is no root
# filesystem.
@@ -24,19 +23,17 @@ EXTRA_OECMAKE = "\
-DZEPHYR_SYSROOT=${ZEPHYR_SYSROOT} \
-DZEPHYR_TOOLCHAIN_VARIANT=yocto \
-DEXTRA_CPPFLAGS=${CPPFLAGS} \
+ -DZEPHYR_MODULES=${ZEPHYR_MODULES} \
"

-ZEPHYR_MODULES = ""
-ZEPHYR_MODULES:append:arm = "\;${S}/modules/cmsis"
-ZEPHYR_MODULES:append:nordic = "\;${S}/modules/hal/nordic"
-ZEPHYR_MODULES:append:stm32 = "\;${S}/modules/hal/stm32"
-ZEPHYR_MODULES:append:openamp = "\;${S}/modules/lib/open-amp\;${S}/modules/hal/libmetal"
+ZEPHYR_EXTRA_MODULES = ""

-EXTRA_OECMAKE:append = " -DZEPHYR_MODULES=${ZEPHYR_MODULES}"
+EXTRA_OECMAKE:append = " -DZEPHYR_EXTRA_MODULES=${ZEPHYR_EXTRA_MODULES}"

export ZEPHYR_BASE="${S}"

-DEPENDS += "gperf-native python3-pyelftools-native python3-pyyaml-native python3-pykwalify-native"
+DEPENDS += "gperf-native"
+
CROSS_COMPILE = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}"

DEPENDS:append:qemuall = " qemu-native qemu-helper-native"
--
2.25.1

Join yocto@lists.yoctoproject.org to automatically receive all group messages.