Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Kconfig) add missing LV_BUILD_EXAMPLES configuration #2555

Merged
merged 12 commits into from
Nov 5, 2021

Conversation

FASTSHIFT
Copy link
Collaborator

@FASTSHIFT FASTSHIFT commented Sep 14, 2021

Description of the feature or fix

fix(Kconfig) add missing LV_BUILD_EXAMPLES configuration.

Checkpoints

FASTSHIFT and others added 3 commits September 10, 2021 11:15
Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
@FASTSHIFT
Copy link
Collaborator Author

FASTSHIFT commented Sep 14, 2021

There seems to be a problem with the cooperation between lv_conf_internal.h and Kconfig.
For example, when the LV_BUILD_EXAMPLES function is turned off in menuconfig,#define CONFIG_LV_BUILD_EXAMPLES 0 will not be written in config.h, resulting in that LV_BUILD_EXAMPLES cannot be disabled.
image

@C47D
Copy link
Contributor

C47D commented Sep 14, 2021

When boolean symbols are defined to n the symbol is not "defined", so I think the value in line 1527 should be changed from 1 to 0.

@FASTSHIFT
Copy link
Collaborator Author

When boolean symbols are defined to n the symbol is not "defined", so I think the value in line 1527 should be changed from 1 to 0.

There are many options that have this problem, such as LV_USE_FLEX which is enabled by default in undefined.

@C47D
Copy link
Contributor

C47D commented Sep 14, 2021

I haven't been able to take a look into the additions to the Kconfig, maybe they are enabled by default.

@kisvegabor
Copy link
Member

Does it mean we should disable everything by default? Including all the widgets and features?

@C47D
Copy link
Contributor

C47D commented Sep 15, 2021

I remember we followed the default configuration (the one in lv_conf_temp.h), but it was a while ago.

@kisvegabor
Copy link
Member

Ah, so it the Kconfig and lv_conf_template.h are in sync the problem is solved.

Using LV_CONF_MINIMAL might alter the default values of Kconfig though.

@kisvegabor
Copy link
Member

E.g. with LV_CONF_MINIMAL 1 LV_USE_ASSERT_NULL will be always enabled.

 config LV_USE_ASSERT_NULL
      bool "Check if the parameter is NULL. (Very fast, recommended)"
      default y if !LV_CONF_MINIMAL
#ifndef LV_USE_ASSERT_NULL
#  ifdef CONFIG_LV_USE_ASSERT_NULL
#    define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL
#  else
#    define  LV_USE_ASSERT_NULL          1   /*Check if the parameter is NULL. (Very fast, recommended)*/
#  endif
#endif

I wonder if we should alter the logic in lv_conf_internal.h. We can simply detect if there is a Kconfig environment or not:

#ifdef CONFIG_LV_COLOR_DEPTH
#  define LV_KCNFIG_PRESENT
#endif 

And with the configs:

#ifndef LV_USE_ASSERT_NULL                /*Do not overwrite externally set defines*/
#  ifdef LV_KCNFIG_PRESENT                /*Use the value from Kcfonfig if present*/
#    ifdef CONFIG_LV_USE_ASSERT_NULL
#      define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL
#    else
#      define LV_USE_ASSERT_NULL 0        /*If a config is not defined then should be evaluated as 0*/
#    endif
#  else                                   /*Without Kconfig set the default value*/
#    define  LV_USE_ASSERT_NULL          1   
#  endif
#endif

What do you think?

@C47D
Copy link
Contributor

C47D commented Sep 24, 2021

I think the logic in the configuration files will become huge. Maybe we should use the lv_conf_kconfig.h file, see how we're defining the CONFIG_LV_BIDI_BASE_DIR_DEF symbol.

Maybe we can add something like this in lv_conf_kconfig.h. The LV_BUILD_EXAMPLES value is 1 by default in lv_conf_template.h (see here).

#ifndef LV_BUILD_EXAMPLES
#ifdef CONFIG_LV_BUILD_EXAMPLES           // Default value, used when LV_BUILD_EXAMPLES is enabled in the Kconfig
#define LV_BUILD_EXAMPLES_DEFAULT 1
#else
#define LV_BUILD_EXAMPLES_DEFAULT 0    // Value used if we disable LV_BUILD_EXAMPLES in Kconfig
#endif
#endif

Then in lv_conf_internal.h:

#ifndef LV_BUILD_EXAMPLES
#define LV_BUILD_EXAMPLES LV_BUILD_EXAMPLES_DEFAULT
#endif

Does it makes sense?

@C47D C47D mentioned this pull request Sep 24, 2021
3 tasks
@kisvegabor
Copy link
Member

I think the logic in the configuration files will become huge.

IMO it doesn't matter much. It's a long, boring, repetitive file which is generated by a script. Not intended to read/edited by humans. (Although it's quite readable)

Maybe we can add something like this in lv_conf_kconfig.h.

lv_conf_internal.h is autogenerated and we can't/shouldn't pick 1-2 configs that are treated differently. I'd rather go with a longer but generic lv_conf_internal.h instead of adding minor tweaks here and there.

If you agree I can update the script to see how it works.

@C47D
Copy link
Contributor

C47D commented Sep 24, 2021

lv_conf_internal.h is autogenerated and we can't/shouldn't pick 1-2 configs that are treated differently. I'd rather go with a longer but generic lv_conf_internal.h instead of adding minor tweaks here and there.

I totally forgot that lv_conf_internal.h is generated by script.

If you agree I can update the script to see how it works.

Are you thinking of updating the script just for those options (LV_BUILD_EXAMPLES, LV_USE_FLEX) or for all?

@kisvegabor
Copy link
Member

Are you thinking of updating the script just for those options (LV_BUILD_EXAMPLES, LV_USE_FLEX) or for all?

For all. This seems like a more robust value checking for all options

#ifndef LV_USE_ASSERT_NULL                /*Do not overwrite externally set defines*/
#  ifdef LV_KCONFIG_PRESENT                /*Use the value from Kcfonfig if present*/
#    ifdef CONFIG_LV_USE_ASSERT_NULL
#      define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL
#    else
#      define LV_USE_ASSERT_NULL 0        /*If a config is not defined should be evaluated as 0*/
#    endif
#  else                                   /*Without Kconfig set the default value*/
#    define  LV_USE_ASSERT_NULL          1   
#  endif
#endif

@C47D
Copy link
Contributor

C47D commented Sep 24, 2021

There's a case that I think we're not considering, configure LVGL with lv_conf.h in platforms that support Kconfig. So instead of LV_KCONFIG_PRESENT should we name it LV_USE_KCONFIG?

@kisvegabor
Copy link
Member

There's a case that I think we're not considering, configure LVGL with lv_conf.h in platforms that support Kconfig.

If the value is set in lv_conf.h the first #ifndef will skip the whole block and leave the set value.

@kisvegabor
Copy link
Member

If you say ok, I can add the proposed changes.

@FASTSHIFT
Copy link
Collaborator Author

@kisvegabor
Can this pr be merged? If LV_BUILD_EXAMPLES can be disabled, the compilation time can be reduced.

@kisvegabor
Copy link
Member

I'm waiting for feedback on this: #2555 (comment)

@kisvegabor
Copy link
Member

I've pushed the changes proposed here.

@kisvegabor
Copy link
Member

I needed to revert it due to some unexpected issues. I will investigate tomorrow.

@kisvegabor kisvegabor reopened this Oct 19, 2021
@kisvegabor
Copy link
Member

@xiaoxiang781216 has suggested to change bools to int with 0/1 possible values.

I'm ok with this but comments from Kconfig users would be great.

@kisvegabor
Copy link
Member

We are about releasing v8.1 and it'd great to fix this issue for it.

If there is no objection for "change bools to int with 0/1 possible values" can someone who uses Kconfig contribute with this update?

@xiaoxiang781216
Copy link
Collaborator

xiaoxiang781216 commented Oct 29, 2021

We are about releasing v8.1 and it'd great to fix this issue for it.

I can fix this issue.

If there is no objection for "change bools to int with 0/1 possible values" can someone who uses Kconfig contribute with this update?

It has a bad side effect, here is the screen shot when LV_BUILD_EXAMPLES is bool:
image
here is the screen shot when LV_BUILD_EXAMPLES is integer:
image
The square(blank/cross) become a circle(0/1) at the begin, more bad effect is that we have to change the value in popup window instead with space key directly:
image

Another fix is change all default bool config to false.

Which propose do you like?

@kisvegabor
Copy link
Member

Thanks for looking into this. Using this pattern could be an option too. My first attempt to implement it failed because it can be applied only to config options with numeric type. But of course we can treat non-numbers and numbers differently.

@kisvegabor
Copy link
Member

As an experiment I updated lv_conf_internal_gen.py to add a more complex check if the default value is 1.

@kisvegabor
Copy link
Member

I merge it to see if there are any unexpected problems before the release.

@kisvegabor kisvegabor merged commit ce3e767 into lvgl:master Nov 5, 2021
kisvegabor added a commit that referenced this pull request Nov 5, 2021
* fix(arc) format code

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* fix(Kconfig) add missing LV_BUILD_EXAMPLES configuration

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* fix(fsdrv): remove the seek call in fs_open (#2736)

since the file should be located at zero after open

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

* docs(os) add example and clarify some poinits

* fix(draw border):border draw error if border width > radius (#2739)

* fix(label) consider base dir lv_label_get_letter_pos in special cases

related to #2712 (comment)

* improve lv_conf_internal_gen.py for better Kconfig support

Co-authored-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Co-authored-by: embeddedt <42941056+embeddedt@users.noreply.github.com>
Co-authored-by: guoweilkd <guowei15@xiaomi.com>
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants