summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/module.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-10 14:35:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-12 15:27:17 +0100
commitfd1517e2b51a170f2427122c6b95396db251d827 (patch)
treedabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/module.bbclass
parent10317912ee319ccf7f83605d438b5cbf9663f296 (diff)
downloadpoky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take advantage of new bitbake functionality to check class scope/usage. (From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/module.bbclass')
-rw-r--r--meta/classes-recipe/module.bbclass80
1 files changed, 80 insertions, 0 deletions
diff --git a/meta/classes-recipe/module.bbclass b/meta/classes-recipe/module.bbclass
new file mode 100644
index 0000000000..d52d5e3098
--- /dev/null
+++ b/meta/classes-recipe/module.bbclass
@@ -0,0 +1,80 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit module-base kernel-module-split pkgconfig
8
9EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}"
10
11MODULES_INSTALL_TARGET ?= "modules_install"
12MODULES_MODULE_SYMVERS_LOCATION ?= ""
13
14python __anonymous () {
15 depends = d.getVar('DEPENDS')
16 extra_symbols = []
17 for dep in depends.split():
18 if dep.startswith("kernel-module-"):
19 extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
20 d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
21}
22
23python do_devshell:prepend () {
24 os.environ['CFLAGS'] = ''
25 os.environ['CPPFLAGS'] = ''
26 os.environ['CXXFLAGS'] = ''
27 os.environ['LDFLAGS'] = ''
28
29 os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
30 os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
31 os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
32 os.environ['CC'] = d.getVar('KERNEL_CC')
33 os.environ['LD'] = d.getVar('KERNEL_LD')
34 os.environ['AR'] = d.getVar('KERNEL_AR')
35 os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
36 kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
37 if kbuild_extra_symbols:
38 os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
39 else:
40 os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
41}
42
43module_do_compile() {
44 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
45 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
46 KERNEL_VERSION=${KERNEL_VERSION} \
47 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
48 AR="${KERNEL_AR}" \
49 O=${STAGING_KERNEL_BUILDDIR} \
50 KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
51 ${MAKE_TARGETS}
52}
53
54module_do_install() {
55 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
56 oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
57 INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
58 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
59 O=${STAGING_KERNEL_BUILDDIR} \
60 ${MODULES_INSTALL_TARGET}
61
62 if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then
63 bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}"
64 bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a"
65 bbwarn "directory below B to get correct inter-module dependencies"
66 else
67 install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers
68 # Module.symvers contains absolute path to the build directory.
69 # While it doesn't actually seem to matter which path is specified,
70 # clear them out to avoid confusion
71 sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers
72 fi
73}
74
75EXPORT_FUNCTIONS do_compile do_install
76
77# add all splitted modules to PN RDEPENDS, PN can be empty now
78KERNEL_MODULES_META_PACKAGE = "${PN}"
79FILES:${PN} = ""
80ALLOW_EMPTY:${PN} = "1"