Recipes that use Cython typically also do some bespoke fixup.  Add a
class to centralise the logic:

- Set CYTHON_PREFIX_MAP to stop build paths appearing in generated
  objects
- Strip "Cython Metadata" blocks from generated code that ends up in the
  -src package

Signed-off-by: Ross Burton <[email protected]>
---
 meta/classes-recipe/cython.bbclass | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 meta/classes-recipe/cython.bbclass

diff --git a/meta/classes-recipe/cython.bbclass 
b/meta/classes-recipe/cython.bbclass
new file mode 100644
index 00000000000..005bc838cc9
--- /dev/null
+++ b/meta/classes-recipe/cython.bbclass
@@ -0,0 +1,11 @@
+DEPENDS:append = " python3-cython-native"
+
+# Remap the build paths that appear in generated .c code
+export CYTHON_PREFIX_MAP = "${S}=${TARGET_DBGSRC_DIR} 
${B}=${TARGET_DBGSRC_DIR}"
+
+do_compile[postfuncs] = "strip_cython_metadata"
+strip_cython_metadata() {
+    # Remove the Cython Metadata headers that we don't need after the build, 
and
+    # may contain build paths.
+    find ${B} -name "*.c" -print0 | xargs -0 sed -i -e "/BEGIN: Cython 
Metadata/,/END: Cython Metadata/d"
+}
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#206719): 
https://lists.openembedded.org/g/openembedded-core/message/206719
Mute This Topic: https://lists.openembedded.org/mt/109408637/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to