Skip to contentSkip to conversation

module.bbclass: Add devshell support

PATCH In review Stefan Wiehler 2 participants 5 messages May 3, 2017 – May 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module.bbclass: Add devshell support

Adds development shell support for out-of-tree kernel modules by reproducing the build environment of the compile task.

---
 meta/classes/module.bbclass | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
meta/classes/module.bbclass +21 -0
index 802476bc7a..9b019513ae 100644
@@ -1,6 +1,7 @@
 inherit module-base kernel-module-split pkgconfig
 
 addtask make_scripts after do_prepare_recipe_sysroot before do_compile
+addtask make_scripts after do_prepare_recipe_sysroot before do_devshell
 do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
 do_make_scripts[depends] += "virtual/kernel:do_shared_workdir"
 
@@ -18,6 +19,26 @@ python __anonymous () {
     d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
 }
 
+python do_devshell_prepend () {
+    os.environ['CFLAGS'] = ''
+    os.environ['CPPFLAGS'] = ''
+    os.environ['CXXFLAGS'] = ''
+    os.environ['LDFLAGS'] = ''
+
+    os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
+    os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
+    os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
+    os.environ['CC'] = d.getVar('KERNEL_CC')
+    os.environ['LD'] = d.getVar('KERNEL_LD')
+    os.environ['AR'] = d.getVar('KERNEL_AR')
+    os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
+    kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
+    if kbuild_extra_symbols:
+        os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
+    else:
+        os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
+}
+
 module_do_compile() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
 	oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR}   \
Signature · 1 line
2.11.0
#1 lore raw
Quoted 13 lines · Stefan Wiehler

Adds development shell support for out-of-tree kernel modules by reproducing the build environment of the compile task.

---
 meta/classes/module.bbclass | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
meta/classes/module.bbclass +0 -0
index 802476bc7a..9b019513ae 100644

meta/classes/module.bbclass line 4

Quoted 4 lines
meta/classes/module.bbclass +1 -0
@@ -1,6 +1,7 @@
 inherit module-base kernel-module-split pkgconfig
 
 addtask make_scripts after do_prepare_recipe_sysroot before do_compile
+addtask make_scripts after do_prepare_recipe_sysroot before do_devshell

For normal recipes, devshell doesn't care about any build dependencies (and so runs very quickly if you just need to refresh a patch etc). If you need a devshell which is able to build something then the normal way would be to manually run the configure or compile task before the devshell task.

I'm not sure of kernel modules are a special enough case to do things differently and add build dependencies to the devshell task?

Quoted 38 lines
meta/classes/module.bbclass +20 -1
 do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
 do_make_scripts[depends] += "virtual/kernel:do_shared_workdir"
 
@@ -18,6 +19,26 @@ python __anonymous () {
     d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
 }
 
+python do_devshell_prepend () {
+    os.environ['CFLAGS'] = ''
+    os.environ['CPPFLAGS'] = ''
+    os.environ['CXXFLAGS'] = ''
+    os.environ['LDFLAGS'] = ''
+
+    os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
+    os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
+    os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
+    os.environ['CC'] = d.getVar('KERNEL_CC')
+    os.environ['LD'] = d.getVar('KERNEL_LD')
+    os.environ['AR'] = d.getVar('KERNEL_AR')
+    os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
+    kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
+    if kbuild_extra_symbols:
+        os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
+    else:
+        os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
+}
+
 module_do_compile() {
        unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
        oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR}   \
--

2.11.0

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 16 lines

meta/classes/module.bbclass line 4

Quoted 9 lines
meta/classes/module.bbclass +1 -0
index 802476bc7a..9b019513ae 100644
@@ -1,6 +1,7 @@
 inherit module-base kernel-module-split pkgconfig
 
 addtask make_scripts after do_prepare_recipe_sysroot before do_compile
+addtask make_scripts after do_prepare_recipe_sysroot before do_devshell

For normal recipes, devshell doesn't care about any build dependencies (and so runs very quickly if you just need to refresh a patch etc). If you need a devshell which is able to build something then the normal way would be to manually run the configure or compile task before the devshell task.

Quoted 2 lines

I'm not sure of kernel modules are a special enough case to do things differently and add build dependencies to the devshell task?

I agree, I couldn't find any other class having devshell task dependencies.

#3 lore raw

PATCH 1/1 module.bbclass: Add devshell support

In reply to Andre McCurdy

Adds development shell support for out-of-tree kernel modules by reproducing the build environment of the compile task.

---

Change: Remove devshell task dependency

 meta/classes/module.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
meta/classes/module.bbclass +20 -0
index 802476b..391776d 100644
@@ -18,6 +18,26 @@ python __anonymous () {
     d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
 }
 
+python do_devshell_prepend () {
+    os.environ['CFLAGS'] = ''
+    os.environ['CPPFLAGS'] = ''
+    os.environ['CXXFLAGS'] = ''
+    os.environ['LDFLAGS'] = ''
+
+    os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
+    os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
+    os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
+    os.environ['CC'] = d.getVar('KERNEL_CC')
+    os.environ['LD'] = d.getVar('KERNEL_LD')
+    os.environ['AR'] = d.getVar('KERNEL_AR')
+    os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
+    kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
+    if kbuild_extra_symbols:
+        os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
+    else:
+        os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
+}
+
 module_do_compile() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
 	oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR}   \
Signature · 1 line
1.9.1
#4 lore raw
Quoted 9 lines

Adds development shell support for out-of-tree kernel modules by reproducing the build environment of the compile task.

---

Change: Remove devshell task dependency

…

Is there anything else preventing this from being merged?