diff mbox series

[meta-oe,v4,7/7] lvgl: lv-conf.inc: generalize sed instructions

Message ID 20240316100056.409758-7-chris.chapuis@gmail.com
State New
Headers show
Series [meta-oe,v4,1/7] lvgl: fix typo in lv-conf.inc | expand

Commit Message

Christophe Chapuis March 16, 2024, 10 a.m. UTC
Use [ \t] to detect optionnal spaces at the beginning of each
line, and after the define.

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

Comments

Marek Vasut March 16, 2024, 8:44 p.m. UTC | #1
On 3/16/24 11:00 AM, Christophe Chapuis wrote:
> Use [ \t] to detect optionnal spaces at the beginning of each
> line, and after the define.
> 
> Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>

You could've squashed this into 5/7, but either way is fine:

Reviewed-by: Marek Vasut <marex@denx.de>
Peter Kjellerstedt March 18, 2024, 1:10 p.m. UTC | #2
> -----Original Message-----
> From: openembedded-devel@lists.openembedded.org <openembedded-devel@lists.openembedded.org> On Behalf Of Tofe
> Sent: den 16 mars 2024 11:01
> To: openembedded-devel@lists.openembedded.org
> Cc: Marek Vasut <marex@denx.de>; Khem Raj <raj.khem@gmail.com>; Fabio Estevam <festevam@denx.de>; Christophe Chapuis <chris.chapuis@gmail.com>
> Subject: [oe] [meta-oe][PATCH v4 7/7] lvgl: lv-conf.inc: generalize sed instructions
> 
> Use [ \t] to detect optionnal spaces at the beginning of each
> line, and after the define.
> 
> Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
> ---
>  meta-oe/recipes-graphics/lvgl/lv-conf.inc | 46 +++++++++++------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/meta-oe/recipes-graphics/lvgl/lv-conf.inc b/meta-oe/recipes-
> graphics/lvgl/lv-conf.inc
> index 9ee9f283d..2b5d4a14a 100644
> --- a/meta-oe/recipes-graphics/lvgl/lv-conf.inc
> +++ b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
> @@ -35,37 +35,37 @@ 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 \).*|\1${LVGL_CONFIG_USE_DRM}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_LINUX_DRM[ \t]\).*|\1${LVGL_CONFIG_USE_DRM}|g" \
>          \
> -        -e "s|\(^#define LV_USE_LINUX_FBDEV \).*|\1${LVGL_CONFIG_USE_FBDEV}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_LINUX_FBDEV[ \t]\).*|\1${LVGL_CONFIG_USE_FBDEV}|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" \
> +        -e "s|\(^[ \t]*#define LV_USE_SDL[ \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_DRAW_SDL[ \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
> +        -e "s|\(^[ \t]*#define LV_SDL_BUF_COUNT[ \t]\).*|\1 2|g" \
> +        -e "s|\(^[ \t]*#define LV_SDL_FULLSCREEN[ \t]\).*|\1${LVGL_CONFIG_SDL_FULLSCREEN}|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_MEM_SIZE \).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|g" \
> +        -e "s|\(^[ \t]*#define LV_COLOR_DEPTH[ \t]\).*|\1${LVGL_CONFIG_LV_COLOR_DEPTH}|g" \
> +        -e "s|\(^[ \t]*#define LV_MEM_CUSTOM[ \t].*\).*|\1${LVGL_CONFIG_LV_MEM_CUSTOM}|g" \
> +        -e "s|\(^[ \t]*#define LV_MEM_SIZE[ \t]\).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|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|\(^[ \t]*#define LV_TICK_CUSTOM[ \t]\).*|\1 1|g" \
> +        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_INCLUDE[ \t]\).*|\1 <stdint.h>|g" \
> +        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_SYS_TIME_EXPR[ \t]\).*|extern uint32_t custom_tick_get(void);\n\1 (custom_tick_get())|g" \
>          \
> -        -e "s|\(^#define LV_USE_EVDEV \).*|\1${LVGL_CONFIG_USE_EVDEV}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_EVDEV[ \t]\).*|\1${LVGL_CONFIG_USE_EVDEV}|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" \
> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_NULL[ \t]\).*|\1${DEBUG_BUILD}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MALLOC[ \t]\).*|\1${DEBUG_BUILD}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_STYLE[ \t]\).*|\1${DEBUG_BUILD}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MEM_INTEGRITY[ \t]\).*|\1${DEBUG_BUILD}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_OBJ[ \t]\).*|\1${DEBUG_BUILD}|g" \
>          \
> -        -e "s|\(^#define LV_USE_LOG \).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
> -        -e "s|\(^ \+#define LV_LOG_LEVEL \).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
> -        -e "s|\(^ \+#define LV_LOG_PRINTF \).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_LOG[ \t]\).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
> +        -e "s|\(^[ \t]*#define LV_LOG_LEVEL[ \t]\).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
> +        -e "s|\(^[ \t]*#define LV_LOG_PRINTF[ \t]\).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
>          \
> -        -e "s|\(^#define LV_USE_FONT_COMPRESSED \).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
> -        -e "s|\(^ \+#define LV_THEME_DEFAULT_DARK \).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
> +        -e "s|\(^[ \t]*#define LV_USE_FONT_COMPRESSED[ \t]\).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
> +        -e "s|\(^[ \t]*#define LV_THEME_DEFAULT_DARK[ \t]\).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
>          \
>          -i "${S}/lv_conf.h"
>  }
> --
> 2.44.0

I would recommend the following:
* Use "\s" instead of "[ \t]".
* Enable extended regular expressions (ERE) by adding the -r option. 
  Then you can change "\(...\)" to "(...)".
* Change "\(^....\)" to "^(...)" (with ERE enabled).
* Remove the "g" flag as none of the expressions are designed to match 
  multiple times per line.

//Peter
Marek Vasut March 18, 2024, 2:01 p.m. UTC | #3
On 3/18/24 2:10 PM, Peter Kjellerstedt wrote:
>> -----Original Message-----
>> From: openembedded-devel@lists.openembedded.org <openembedded-devel@lists.openembedded.org> On Behalf Of Tofe
>> Sent: den 16 mars 2024 11:01
>> To: openembedded-devel@lists.openembedded.org
>> Cc: Marek Vasut <marex@denx.de>; Khem Raj <raj.khem@gmail.com>; Fabio Estevam <festevam@denx.de>; Christophe Chapuis <chris.chapuis@gmail.com>
>> Subject: [oe] [meta-oe][PATCH v4 7/7] lvgl: lv-conf.inc: generalize sed instructions
>>
>> Use [ \t] to detect optionnal spaces at the beginning of each
>> line, and after the define.
>>
>> Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
>> ---
>>   meta-oe/recipes-graphics/lvgl/lv-conf.inc | 46 +++++++++++------------
>>   1 file changed, 23 insertions(+), 23 deletions(-)
>>
>> diff --git a/meta-oe/recipes-graphics/lvgl/lv-conf.inc b/meta-oe/recipes-
>> graphics/lvgl/lv-conf.inc
>> index 9ee9f283d..2b5d4a14a 100644
>> --- a/meta-oe/recipes-graphics/lvgl/lv-conf.inc
>> +++ b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
>> @@ -35,37 +35,37 @@ 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 \).*|\1${LVGL_CONFIG_USE_DRM}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_LINUX_DRM[ \t]\).*|\1${LVGL_CONFIG_USE_DRM}|g" \
>>           \
>> -        -e "s|\(^#define LV_USE_LINUX_FBDEV \).*|\1${LVGL_CONFIG_USE_FBDEV}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_LINUX_FBDEV[ \t]\).*|\1${LVGL_CONFIG_USE_FBDEV}|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" \
>> +        -e "s|\(^[ \t]*#define LV_USE_SDL[ \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_DRAW_SDL[ \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
>> +        -e "s|\(^[ \t]*#define LV_SDL_BUF_COUNT[ \t]\).*|\1 2|g" \
>> +        -e "s|\(^[ \t]*#define LV_SDL_FULLSCREEN[ \t]\).*|\1${LVGL_CONFIG_SDL_FULLSCREEN}|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_MEM_SIZE \).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|g" \
>> +        -e "s|\(^[ \t]*#define LV_COLOR_DEPTH[ \t]\).*|\1${LVGL_CONFIG_LV_COLOR_DEPTH}|g" \
>> +        -e "s|\(^[ \t]*#define LV_MEM_CUSTOM[ \t].*\).*|\1${LVGL_CONFIG_LV_MEM_CUSTOM}|g" \
>> +        -e "s|\(^[ \t]*#define LV_MEM_SIZE[ \t]\).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|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|\(^[ \t]*#define LV_TICK_CUSTOM[ \t]\).*|\1 1|g" \
>> +        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_INCLUDE[ \t]\).*|\1 <stdint.h>|g" \
>> +        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_SYS_TIME_EXPR[ \t]\).*|extern uint32_t custom_tick_get(void);\n\1 (custom_tick_get())|g" \
>>           \
>> -        -e "s|\(^#define LV_USE_EVDEV \).*|\1${LVGL_CONFIG_USE_EVDEV}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_EVDEV[ \t]\).*|\1${LVGL_CONFIG_USE_EVDEV}|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" \
>> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_NULL[ \t]\).*|\1${DEBUG_BUILD}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MALLOC[ \t]\).*|\1${DEBUG_BUILD}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_STYLE[ \t]\).*|\1${DEBUG_BUILD}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MEM_INTEGRITY[ \t]\).*|\1${DEBUG_BUILD}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_OBJ[ \t]\).*|\1${DEBUG_BUILD}|g" \
>>           \
>> -        -e "s|\(^#define LV_USE_LOG \).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
>> -        -e "s|\(^ \+#define LV_LOG_LEVEL \).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
>> -        -e "s|\(^ \+#define LV_LOG_PRINTF \).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_LOG[ \t]\).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
>> +        -e "s|\(^[ \t]*#define LV_LOG_LEVEL[ \t]\).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
>> +        -e "s|\(^[ \t]*#define LV_LOG_PRINTF[ \t]\).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
>>           \
>> -        -e "s|\(^#define LV_USE_FONT_COMPRESSED \).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
>> -        -e "s|\(^ \+#define LV_THEME_DEFAULT_DARK \).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
>> +        -e "s|\(^[ \t]*#define LV_USE_FONT_COMPRESSED[ \t]\).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
>> +        -e "s|\(^[ \t]*#define LV_THEME_DEFAULT_DARK[ \t]\).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
>>           \
>>           -i "${S}/lv_conf.h"
>>   }
>> --
>> 2.44.0
> 
> I would recommend the following:
> * Use "\s" instead of "[ \t]".

I didn't know \s , where is this documented ? Is this similar to 
[[:space:]] ?

> * Enable extended regular expressions (ERE) by adding the -r option.
>    Then you can change "\(...\)" to "(...)".
> * Change "\(^....\)" to "^(...)" (with ERE enabled).
> * Remove the "g" flag as none of the expressions are designed to match
>    multiple times per line.

Chris, do you want to send a follow up patch (I think this series is 
already applied), or shall I do that while preparing LVGL 9.1 series?
Christophe Chapuis March 18, 2024, 3:42 p.m. UTC | #4
I avoided \s because it's not well known, and I would also prefer using
[[:space:]] as it is POSIX compliant.

I can propose a patch for this, taking Peter's remarks into account.

On Mon, Mar 18, 2024 at 3:46 PM Marek Vasut <marex@denx.de> wrote:

> On 3/18/24 2:10 PM, Peter Kjellerstedt wrote:
> >> -----Original Message-----
> >> From: openembedded-devel@lists.openembedded.org <
> openembedded-devel@lists.openembedded.org> On Behalf Of Tofe
> >> Sent: den 16 mars 2024 11:01
> >> To: openembedded-devel@lists.openembedded.org
> >> Cc: Marek Vasut <marex@denx.de>; Khem Raj <raj.khem@gmail.com>; Fabio
> Estevam <festevam@denx.de>; Christophe Chapuis <chris.chapuis@gmail.com>
> >> Subject: [oe] [meta-oe][PATCH v4 7/7] lvgl: lv-conf.inc: generalize sed
> instructions
> >>
> >> Use [ \t] to detect optionnal spaces at the beginning of each
> >> line, and after the define.
> >>
> >> Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
> >> ---
> >>   meta-oe/recipes-graphics/lvgl/lv-conf.inc | 46 +++++++++++------------
> >>   1 file changed, 23 insertions(+), 23 deletions(-)
> >>
> >> diff --git a/meta-oe/recipes-graphics/lvgl/lv-conf.inc
> b/meta-oe/recipes-
> >> graphics/lvgl/lv-conf.inc
> >> index 9ee9f283d..2b5d4a14a 100644
> >> --- a/meta-oe/recipes-graphics/lvgl/lv-conf.inc
> >> +++ b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
> >> @@ -35,37 +35,37 @@ 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
> \).*|\1${LVGL_CONFIG_USE_DRM}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_LINUX_DRM[
> \t]\).*|\1${LVGL_CONFIG_USE_DRM}|g" \
> >>           \
> >> -        -e "s|\(^#define LV_USE_LINUX_FBDEV
> \).*|\1${LVGL_CONFIG_USE_FBDEV}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_LINUX_FBDEV[
> \t]\).*|\1${LVGL_CONFIG_USE_FBDEV}|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" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_SDL[
> \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_DRAW_SDL[
> \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_SDL_BUF_COUNT[ \t]\).*|\1 2|g" \
> >> +        -e "s|\(^[ \t]*#define LV_SDL_FULLSCREEN[
> \t]\).*|\1${LVGL_CONFIG_SDL_FULLSCREEN}|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_MEM_SIZE
> \).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_COLOR_DEPTH[
> \t]\).*|\1${LVGL_CONFIG_LV_COLOR_DEPTH}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_MEM_CUSTOM[
> \t].*\).*|\1${LVGL_CONFIG_LV_MEM_CUSTOM}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_MEM_SIZE[
> \t]\).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|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|\(^[ \t]*#define LV_TICK_CUSTOM[ \t]\).*|\1 1|g" \
> >> +        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_INCLUDE[ \t]\).*|\1
> <stdint.h>|g" \
> >> +        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_SYS_TIME_EXPR[
> \t]\).*|extern uint32_t custom_tick_get(void);\n\1 (custom_tick_get())|g" \
> >>           \
> >> -        -e "s|\(^#define LV_USE_EVDEV
> \).*|\1${LVGL_CONFIG_USE_EVDEV}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_EVDEV[
> \t]\).*|\1${LVGL_CONFIG_USE_EVDEV}|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" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_NULL[
> \t]\).*|\1${DEBUG_BUILD}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MALLOC[
> \t]\).*|\1${DEBUG_BUILD}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_STYLE[
> \t]\).*|\1${DEBUG_BUILD}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MEM_INTEGRITY[
> \t]\).*|\1${DEBUG_BUILD}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_ASSERT_OBJ[
> \t]\).*|\1${DEBUG_BUILD}|g" \
> >>           \
> >> -        -e "s|\(^#define LV_USE_LOG
> \).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
> >> -        -e "s|\(^ \+#define LV_LOG_LEVEL
> \).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
> >> -        -e "s|\(^ \+#define LV_LOG_PRINTF
> \).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_LOG[
> \t]\).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_LOG_LEVEL[
> \t]\).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_LOG_PRINTF[
> \t]\).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
> >>           \
> >> -        -e "s|\(^#define LV_USE_FONT_COMPRESSED
> \).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
> >> -        -e "s|\(^ \+#define LV_THEME_DEFAULT_DARK
> \).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_USE_FONT_COMPRESSED[
> \t]\).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
> >> +        -e "s|\(^[ \t]*#define LV_THEME_DEFAULT_DARK[
> \t]\).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
> >>           \
> >>           -i "${S}/lv_conf.h"
> >>   }
> >> --
> >> 2.44.0
> >
> > I would recommend the following:
> > * Use "\s" instead of "[ \t]".
>
> I didn't know \s , where is this documented ? Is this similar to
> [[:space:]] ?
>
> > * Enable extended regular expressions (ERE) by adding the -r option.
> >    Then you can change "\(...\)" to "(...)".
> > * Change "\(^....\)" to "^(...)" (with ERE enabled).
> > * Remove the "g" flag as none of the expressions are designed to match
> >    multiple times per line.
>
> Chris, do you want to send a follow up patch (I think this series is
> already applied), or shall I do that while preparing LVGL 9.1 series?
>
Marek Vasut March 18, 2024, 9:59 p.m. UTC | #5
On 3/18/24 4:42 PM, Christophe Chapuis wrote:
> I avoided \s because it's not well known, and I would also prefer using
> [[:space:]] as it is POSIX compliant.
> 
> I can propose a patch for this, taking Peter's remarks into account.

Yes please, already reviewed too.

btw please stop top-posting .
Peter Kjellerstedt March 21, 2024, 8:49 p.m. UTC | #6
> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: den 18 mars 2024 23:00
> To: Christophe Chapuis <chris.chapuis@gmail.com>
> Cc: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; openembedded-
> devel@lists.openembedded.org; Khem Raj <raj.khem@gmail.com>; Fabio Estevam
> <festevam@denx.de>
> Subject: Re: [oe] [meta-oe][PATCH v4 7/7] lvgl: lv-conf.inc: generalize
> sed instructions
> 
> On 3/18/24 4:42 PM, Christophe Chapuis wrote:
> > I avoided \s because it's not well known, and I would also prefer using
> > [[:space:]] as it is POSIX compliant.

See chapter "5.6 regular expression extensions" in the sed info page for \s 
and a number of other similar sequences (for anyone used to Perl's regular 
expressions, \s is the normal way to match whitespace). And true, this is 
not POSIX, but neither is the -i option that is also used by the same 
command.

> >
> > I can propose a patch for this, taking Peter's remarks into account.

Thank you.

> 
> Yes please, already reviewed too.
> 
> btw please stop top-posting .

//Peter
diff mbox series

Patch

diff --git a/meta-oe/recipes-graphics/lvgl/lv-conf.inc b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
index 9ee9f283d..2b5d4a14a 100644
--- a/meta-oe/recipes-graphics/lvgl/lv-conf.inc
+++ b/meta-oe/recipes-graphics/lvgl/lv-conf.inc
@@ -35,37 +35,37 @@  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 \).*|\1${LVGL_CONFIG_USE_DRM}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_LINUX_DRM[ \t]\).*|\1${LVGL_CONFIG_USE_DRM}|g" \
         \
-        -e "s|\(^#define LV_USE_LINUX_FBDEV \).*|\1${LVGL_CONFIG_USE_FBDEV}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_LINUX_FBDEV[ \t]\).*|\1${LVGL_CONFIG_USE_FBDEV}|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" \
+        -e "s|\(^[ \t]*#define LV_USE_SDL[ \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_DRAW_SDL[ \t]\).*|\1${LVGL_CONFIG_USE_SDL}|g" \
+        -e "s|\(^[ \t]*#define LV_SDL_BUF_COUNT[ \t]\).*|\1 2|g" \
+        -e "s|\(^[ \t]*#define LV_SDL_FULLSCREEN[ \t]\).*|\1${LVGL_CONFIG_SDL_FULLSCREEN}|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_MEM_SIZE \).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|g" \
+        -e "s|\(^[ \t]*#define LV_COLOR_DEPTH[ \t]\).*|\1${LVGL_CONFIG_LV_COLOR_DEPTH}|g" \
+        -e "s|\(^[ \t]*#define LV_MEM_CUSTOM[ \t].*\).*|\1${LVGL_CONFIG_LV_MEM_CUSTOM}|g" \
+        -e "s|\(^[ \t]*#define LV_MEM_SIZE[ \t]\).*|\1${LVGL_CONFIG_LV_MEM_SIZE}|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|\(^[ \t]*#define LV_TICK_CUSTOM[ \t]\).*|\1 1|g" \
+        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_INCLUDE[ \t]\).*|\1 <stdint.h>|g" \
+        -e "s|\(^[ \t]*#define LV_TICK_CUSTOM_SYS_TIME_EXPR[ \t]\).*|extern uint32_t custom_tick_get(void);\n\1 (custom_tick_get())|g" \
         \
-        -e "s|\(^#define LV_USE_EVDEV \).*|\1${LVGL_CONFIG_USE_EVDEV}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_EVDEV[ \t]\).*|\1${LVGL_CONFIG_USE_EVDEV}|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" \
+        -e "s|\(^[ \t]*#define LV_USE_ASSERT_NULL[ \t]\).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MALLOC[ \t]\).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_ASSERT_STYLE[ \t]\).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_ASSERT_MEM_INTEGRITY[ \t]\).*|\1${DEBUG_BUILD}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_ASSERT_OBJ[ \t]\).*|\1${DEBUG_BUILD}|g" \
         \
-        -e "s|\(^#define LV_USE_LOG \).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
-        -e "s|\(^ \+#define LV_LOG_LEVEL \).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
-        -e "s|\(^ \+#define LV_LOG_PRINTF \).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_LOG[ \t]\).*|\1${LVGL_CONFIG_LV_USE_LOG}|g" \
+        -e "s|\(^[ \t]*#define LV_LOG_LEVEL[ \t]\).*|\1${LVGL_CONFIG_LV_LOG_LEVEL}|g" \
+        -e "s|\(^[ \t]*#define LV_LOG_PRINTF[ \t]\).*|\1${LVGL_CONFIG_LV_LOG_PRINTF}|g" \
         \
-        -e "s|\(^#define LV_USE_FONT_COMPRESSED \).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
-        -e "s|\(^ \+#define LV_THEME_DEFAULT_DARK \).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
+        -e "s|\(^[ \t]*#define LV_USE_FONT_COMPRESSED[ \t]\).*|\1${LVGL_CONFIG_LV_USE_FONT_COMPRESSED}|g" \
+        -e "s|\(^[ \t]*#define LV_THEME_DEFAULT_DARK[ \t]\).*|\1${LVGL_CONFIG_LV_THEME_DEFAULT_DARK}|g" \
         \
         -i "${S}/lv_conf.h"
 }