diff mbox series

[meta-oe,2/2] opencv: Support building for native

Message ID 20250927024742.1485096-2-pkj@axis.com
State New
Headers show
Series [meta-oe,1/2] glog: Support building for native | expand

Commit Message

Peter Kjellerstedt Sept. 27, 2025, 2:47 a.m. UTC
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 meta-oe/recipes-support/opencv/opencv_4.12.0.bb | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Khem Raj Sept. 27, 2025, 4:34 a.m. UTC | #1
I am curious what’s the use case ?

On Fri, Sep 26, 2025 at 7:47 PM Peter Kjellerstedt via
lists.openembedded.org <peter.kjellerstedt=axis.com@lists.openembedded.org>
wrote:

> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
>  meta-oe/recipes-support/opencv/opencv_4.12.0.bb | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
> b/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
> index d1ab87b06f..27499caa92 100644
> --- a/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
> +++ b/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
> @@ -200,11 +200,6 @@ do_install:append() {
>          mv ${D}/usr/lib/* ${D}/${libdir}/
>          rm -rf ${D}/usr/lib
>      fi
> -    # remove build host path to improve reproducibility
> -    if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
> -        sed -e 's@${STAGING_DIR_HOST}@@g' \
> -            -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
> -    fi
>      # remove setup_vars_opencv4.sh as its content is confusing and useless
>      if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
>          rm -rf ${D}${bindir}/setup_vars_opencv4.sh
> @@ -222,3 +217,13 @@ do_install:append() {
>          mv ${D}/${bindir}/shape ${D}/${bindir}/opencv_shape
>      fi
>  }
> +
> +do_install:append:class-target() {
> +    # remove build host path to improve reproducibility
> +    if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
> +        sed -e 's@${STAGING_DIR_HOST}@@g' \
> +            -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
> +    fi
> +}
> +
> +BBCLASSEXTEND = "native"
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#119949):
> https://lists.openembedded.org/g/openembedded-devel/message/119949
> Mute This Topic: https://lists.openembedded.org/mt/115460185/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Peter Kjellerstedt Sept. 27, 2025, 6:38 a.m. UTC | #2
We have this (in my opinion) weird unit test system for our own recipes that relies on building the unit tests as a subclass of native, which means the recipe’s dependencies also need to be built for native. Normally we can just add a bbappend with a BBCLASSEXTEND if an upstream recipe does not support building for native out of the box. However, in this case due to the sed expression that removes ${STAGING_DIR_HOST} this does not work because ${STAGING_DIR_HOST} is empty for native and then sed fails. Since this is in a do_install:append, there is no way for me to solve this easily in our own layer. Thus the easiest solution is to solve it in meta-oe.

//Peter

From: Khem Raj <raj.khem@gmail.com>
Sent: den 27 september 2025 06:34
To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Cc: openembedded-devel@lists.openembedded.org
Subject: Re: [oe] [meta-oe][PATCH 2/2] opencv: Support building for native

I am curious what’s the use case ?

On Fri, Sep 26, 2025 at 7:47 PM Peter Kjellerstedt via lists.openembedded.org<http://lists.openembedded.org> <peter.kjellerstedt=axis.com@lists.openembedded.org<mailto:axis.com@lists.openembedded.org>> wrote:
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com<mailto:peter.kjellerstedt@axis.com>>
---
 meta-oe/recipes-support/opencv/opencv_4.12.0.bb<http://opencv_4.12.0.bb> | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/meta-oe/recipes-support/opencv/opencv_4.12.0.bb<http://opencv_4.12.0.bb> b/meta-oe/recipes-support/opencv/opencv_4.12.0.bb<http://opencv_4.12.0.bb>
index d1ab87b06f..27499caa92 100644
--- a/meta-oe/recipes-support/opencv/opencv_4.12.0.bb<http://opencv_4.12.0.bb>
+++ b/meta-oe/recipes-support/opencv/opencv_4.12.0.bb<http://opencv_4.12.0.bb>
@@ -200,11 +200,6 @@ do_install:append() {
         mv ${D}/usr/lib/* ${D}/${libdir}/
         rm -rf ${D}/usr/lib
     fi
-    # remove build host path to improve reproducibility
-    if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
-        sed -e 's@${STAGING_DIR_HOST}@@g' \
-            -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
-    fi
     # remove setup_vars_opencv4.sh as its content is confusing and useless
     if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
         rm -rf ${D}${bindir}/setup_vars_opencv4.sh
@@ -222,3 +217,13 @@ do_install:append() {
         mv ${D}/${bindir}/shape ${D}/${bindir}/opencv_shape
     fi
 }
+
+do_install:append:class-target() {
+    # remove build host path to improve reproducibility
+    if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
+        sed -e 's@${STAGING_DIR_HOST}@@g' \
+            -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
+    fi
+}
+
+BBCLASSEXTEND = "native"

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#119949): https://lists.openembedded.org/g/openembedded-devel/message/119949
Mute This Topic: https://lists.openembedded.org/mt/115460185/1997914
Group Owner: openembedded-devel+owner@lists.openembedded.org<mailto:openembedded-devel%2Bowner@lists.openembedded.org>
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com<mailto:raj.khem@gmail.com>]
-=-=-=-=-=-=-=-=-=-=-=-
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/opencv/opencv_4.12.0.bb b/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
index d1ab87b06f..27499caa92 100644
--- a/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
+++ b/meta-oe/recipes-support/opencv/opencv_4.12.0.bb
@@ -200,11 +200,6 @@  do_install:append() {
         mv ${D}/usr/lib/* ${D}/${libdir}/
         rm -rf ${D}/usr/lib
     fi
-    # remove build host path to improve reproducibility
-    if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
-        sed -e 's@${STAGING_DIR_HOST}@@g' \
-            -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
-    fi
     # remove setup_vars_opencv4.sh as its content is confusing and useless
     if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
         rm -rf ${D}${bindir}/setup_vars_opencv4.sh
@@ -222,3 +217,13 @@  do_install:append() {
         mv ${D}/${bindir}/shape ${D}/${bindir}/opencv_shape
     fi
 }
+
+do_install:append:class-target() {
+    # remove build host path to improve reproducibility
+    if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
+        sed -e 's@${STAGING_DIR_HOST}@@g' \
+            -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
+    fi
+}
+
+BBCLASSEXTEND = "native"