On 3/15/24 7:03 PM, Christophe Chapuis wrote:
Use back reference instead of repeating the search pattern. Later on
this could lead to a more generic way of replacing values in the .h file.

Signed-off-by: Christophe Chapuis <chris.chap...@gmail.com>
---
  meta-oe/recipes-graphics/lvgl/lv-conf.inc | 28 +++++++++++------------
  1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/meta-oe/recipes-graphics/lvgl/lv-conf.inc 
b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
index 6bcead628..f5a93dcae 100644
--- a/meta-oe/recipes-graphics/lvgl/lv-conf.inc
+++ b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
@@ -26,29 +26,29 @@ do_configure:append() {
sed -e "s|#if 0 .*Set it to \"1\" to enable content.*|#if 1 // Enabled by ${PN}|g" \
          \
-        -e "s|\(^#define LV_USE_LINUX_DRM \).*|#define LV_USE_LINUX_DRM 
${LVGL_CONFIG_USE_DRM}|g" \
+        -e "s|\(^#define LV_USE_LINUX_DRM \).*|\1${LVGL_CONFIG_USE_DRM}|g" \
          \
-        -e "s|\(^#define LV_USE_LINUX_FBDEV \).*|#define LV_USE_LINUX_FBDEV 
${LVGL_CONFIG_USE_FBDEV}|g" \
+        -e "s|\(^#define LV_USE_LINUX_FBDEV \).*|\1${LVGL_CONFIG_USE_FBDEV}|g" 
\
          \
-        -e "s|\(^#define LV_USE_SDL \).*|#define LV_USE_SDL 
${LVGL_CONFIG_USE_SDL}|g" \
-        -e "s|\(^#define LV_USE_DRAW_SDL \).*|#define LV_USE_DRAW_SDL 
${LVGL_CONFIG_USE_SDL}|g" \
-        -e "s|\(^    #define LV_SDL_BUF_COUNT \).*|    #define LV_SDL_BUF_COUNT 
2|g" \
-        -e "s|\(^    #define LV_SDL_FULLSCREEN \).*|    #define LV_SDL_FULLSCREEN 
${LVGL_CONFIG_SDL_FULLSCREEN}|g" \
+        -e "s|\(^#define LV_USE_SDL \).*|\1${LVGL_CONFIG_USE_SDL}|g" \
+        -e "s|\(^#define LV_USE_DRAW_SDL \).*|\1${LVGL_CONFIG_USE_SDL}|g" \
+        -e "s|\(^ \+#define LV_SDL_BUF_COUNT \).*|\1 2|g" \
+        -e "s|\(^ \+#define LV_SDL_FULLSCREEN 
\).*|\1${LVGL_CONFIG_SDL_FULLSCREEN}|g" \

Wouldn't it be better to use '^ *#define...' here to catch the case where there are no spaces between start of line and #define ?

-        -e "s|\(^#define LV_COLOR_DEPTH \).*|#define LV_COLOR_DEPTH 
${LVGL_CONFIG_LV_COLOR_DEPTH}|g" \
-        -e "s|\(#define LV_MEM_CUSTOM .*\)0|\1${LVGL_CONFIG_LV_MEM_CUSTOM}|g" \
+        -e "s|\(^#define LV_COLOR_DEPTH 
\).*|\1${LVGL_CONFIG_LV_COLOR_DEPTH}|g" \
+        -e "s|\(#define LV_MEM_CUSTOM .*\).*|\1${LVGL_CONFIG_LV_MEM_CUSTOM}|g" 
\
          \
          -e "s|\(#define LV_TICK_CUSTOM \).*|\1 1|g" \
          -e "s|\(#define LV_TICK_CUSTOM_INCLUDE \).*|\1 <stdint.h>|g" \
          -e "s|\(#define LV_TICK_CUSTOM_SYS_TIME_EXPR \).*|extern uint32_t 
custom_tick_get(void);\n\1 (custom_tick_get())|g" \
          \
-        -e "s|\(^#define LV_USE_EVDEV \).*|#define LV_USE_EVDEV 
${LVGL_CONFIG_USE_EVDEV}|g" \
+        -e "s|\(^#define LV_USE_EVDEV \).*|\1${LVGL_CONFIG_USE_EVDEV}|g" \
          \
-        -e "s|\(^#define LV_USE_ASSERT_NULL \).*|#define LV_USE_ASSERT_NULL 
${DEBUG_BUILD}|g" \
-        -e "s|\(^#define LV_USE_ASSERT_MALLOC \).*|#define LV_USE_ASSERT_MALLOC 
${DEBUG_BUILD}|g" \
-        -e "s|\(^#define LV_USE_ASSERT_STYLE \).*|#define LV_USE_ASSERT_STYLE 
${DEBUG_BUILD}|g" \
-        -e "s|\(^#define LV_USE_ASSERT_MEM_INTEGRITY \).*|#define 
LV_USE_ASSERT_MEM_INTEGRITY ${DEBUG_BUILD}|g" \
-        -e "s|\(^#define LV_USE_ASSERT_OBJ \).*|#define LV_USE_ASSERT_OBJ 
${DEBUG_BUILD}|g" \
+        -e "s|\(^#define LV_USE_ASSERT_NULL \).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^#define LV_USE_ASSERT_MALLOC \).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^#define LV_USE_ASSERT_STYLE \).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^#define LV_USE_ASSERT_MEM_INTEGRITY \).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^#define LV_USE_ASSERT_OBJ \).*|\1${DEBUG_BUILD}|g" \

btw if you want this to be extra accurate, you could do also:

"s|\(^#define \<LV_USE_ASSERT_OBJ\>\).*|\1 ${DEBUG_BUILD}|g"

which would handle '#define LV_USE_ASSERT_OBJ<TAB>' as well .
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#109350): 
https://lists.openembedded.org/g/openembedded-devel/message/109350
Mute This Topic: https://lists.openembedded.org/mt/104953143/21656
Group Owner: openembedded-devel+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to