-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
kconfiglib improvements #42233
kconfiglib improvements #42233
Conversation
Projects such as Zephyr OS have a module system, where Kconfig files can exist in multiple directories that are effectively merged together by the build system. In other words, one project directory can refer to subdir/Kconfig where subdir/ is actually in another project directory. As an example: zephyr/ - main source directory Kconfig - main Kconfig file module/ec - module directory motion/ - motion subsystem Kconfig - Kconfig file for motion subsystem With the above, we might have, in zephyr/Kconfig: source "motion/Kconfig" and it automatically locates the file in the module/ec directory. Add support for this, by allowing a list of search paths to be supplied to Kconfiglib. Signed-off-by: Simon Glass <[email protected]> Change-Id: I24a48fd21016b08c9b29f3d0349062b491db75f8
When parsing Kconfig which include macros it is currently necessary to provide a value for all macros in advance. This may not be possible in some cases, e.g. when the caller is performing checks on the Kconfig options but is not running a full build of the project. Add an option to support this. This allows parsing of Zephyr Kconfig files without specifying a particular board, etc. This corresponds to upstream PR: ulfalizer/Kconfiglib#112 but it looks like the project might be dead as there is no activity in 18 months. Signed-off-by: Simon Glass <[email protected]> Change-Id: Icf36da1e47fb7293f3d8bc3569affd7cd7598100
Add some changes to allow this library to work with Zephyr: - Ability to have Kconfig files in multiple projects directories - Ability to ignore variable expansion failures, since there are so many Kconfig variables in Zephyr These changes have been sent upstream here: ulfalizer/Kconfiglib#112 and to Zephyr here: zephyrproject-rtos/zephyr#42233 so this also includes the one Zephyr-local commit: 66d1b3ce106 kconfig: kconfiglib.py: Backup files only All three commits are based on Kconfiglib 14.1.0 BUG=b:181323955 BRANCH=none TEST=python3 util/test_kconfig_check.py Signed-off-by: Simon Glass <[email protected]> Change-Id: Iac24a90fe3707cacab40d45210addc663bb17f60 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3390708 Reviewed-by: Jack Rosenthal <[email protected]>
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Hi, please can someone look at this one? |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need a better understanding of the benefit of this PR.
Besides the introduced risk of folder name collisions, which would make it hard
for developers to trace down, then this makes it also makes it unnecessary hard
to know where to find a given file.
Today, if I see:
source "motion/Kconfig"
I know I should start looking directly in $(ZEPHYR_BASE)/motion/Kconfig
.
With this PR, I basically don't know where to start looking.
Today, all modules can be referred using: $(ZEPHYR_<name>_MODULE_DIR)
This means that if I want to source motion/Kconfig
from the ec
module, I can do
source "$(ZEPHYR_EC_MODULE_DIR)/motion/Kconfig"
No risk of naming collisions.
Clear to all developers from where motion/Kconfig
is sourced.
So I really need very good reasons why the existing feature is not sufficient.
For the second commit, you write:
When parsing Kconfig which include macros it is currently necessary to
provide a value for all macros in advance.
Before fixing something, could you please open an issue describing what is wrong ?
The only way I can trigger this error, is by creating configs that are purely
defined using macros, like this:
config $(EXPANDS_TO_EMPTY)
as soon as I do,
config $(EXPANDS_TO_EMPTY)_FIXED_PART
the error is gone, cause the complete setting's name is no longer empty.
Afaik Zephyr doesn't create settings purely based on macros, they usually have a
fixed part, like this:
choice "$(module)_LOG_LEVEL_CHOICE" |
So far i'm not convinced about the value of this PR, so please provide more
information on the exact problem / limitation of the build system.
Which use-cases, with examples, is blocking you.
Let's take them one at a time. For the first one, Zephyr does not require that Kconfig options have source "$(ZEPHYR_EC_MODULE_DIR)/motion/Kconfig" Just source "motion/Kconfig" is sufficient. After all, how can the core Zephyr Kconfig reference a module in that way? It would cause an error if the module were not present. Modules can be added as needed, but a module that is required by Zephyr to build, is not really a module. As to the use case for this one, we want to check the Kconfig to make sure that people don't add #define CONFIG options when they should have a Kconfig too. https://chromium.googlesource.com/chromiumos/platform/ec/+/HEAD/util/kconfig_check.py We obviously need to load the Kconfig to make this work, and things like the log level are not relevant for this check. Without this commit, we get errors trying to load the Kconfig. |
Today, Zephyr sources Kconfig from modules based on their setting in
If you have additional Kconfig files you want to source from a Zephyr module you can use the approach I described earlier, for example as seen here in a project that uses Zephyr:
This is available in And my question is, why is this existing possibility not good enough ?
with this PR, correct. I would like to understand why the new approach is needed, considering its short comings such as collision risk and easiness for developers to directly see location from where a Kconfig is sourced.
hopefully there are no modules that are mandatory for Zephyr. Similar for features, a specific feature might require a specific module. But there should not be a module that are always required.
What kind of errors ? zephyr/scripts/kconfig/kconfiglib.py Lines 2717 to 2720 in 26c5579
and i'm only able to trigger this error in a very special case where I actually would like to see such error. I ask for this, because I don't like to deviate from the upstream Kconfiglib.py unless we really have a good reason for doing so.
and would that allow for empty named config settings ? |
Firstly I should say that I did send this upstream, here: I mentioned in this in the second commit:
It's great that you have a way to generate a Kconfig.modules with magic tooling. But that is in the Zephyr build system. We cannot run a build just to be able to parse the Kconfig. We need to be able to parse it as is, actually from outside the Zephyr build system. If you want to reproduce this you can follow these steps. Sorry for any minor errors: mkdir /tmp/xx put the path to your zephyr tree hereZEPHYR_DIR=~/cosarm/src/third_party/zephyr/main get my new kconfiglibcp $ZEPHYR_DIR/scripts/kconfig/kconfiglib.py util manually hack the test file util/test_kconfig_check.py:#zephyr_path = pathlib.Path( "../../../src/third_party/zephyr/main"replace that with the path to your Zephyr treerun the testspython3 util/test_kconfig_check.py Those tests check the various cases. If you want to try this without the new features and see what happens, hack util/kconfig_check.py to change scan_kconfigs():
In my case this does: python3 util/test_kconfig_check.py
|
@tejlmand does this make sense to you? |
@sjg20 I now had the time to fetch the referenced repo and try it out. I'm still not quite sure exactly what your problem is.
in your module instead of an This means the module in itself is useless without the Zephyr tree. Somewhere in your Kconfig tree, you must load the Zephyr Kconfig tree. But if I understand your problem correctly, then your module is not including So this means I see that your Let me explain how to get your For this, I need a module Kconfig file, but I didn't find any Kconfig files at the ec-repo top-level, but Considering
and then simply export the folder where You can test this in a terminal like this:
This will load Your Kconfig check should already know the module to check, so it should be very simple to generate and include above snippet through above method before running the check. |
For reference, the generated Line 13 in 3f62860
And I noticed, when playing with the So why not set the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not convinced until now that this should be accepted, main reasons:
- It's deviating the general Kconfig of a single tree starting point, something not possible either in regular Kconfig as used by Linux kernel, et. al.
- Risk of path collision, making it unpredictable for end-users whcih tree will be included, not to mention hard to debug when name collides.
- It's not providing any needed feature to Zephyr
- As the feature is not used by Zephyr itself, and used only be single downstream user for a very specific test use-case, the risk that this bit rots becomes high.
Downstream user could even decide a new path in future, resulting in this code just become dead. - A similar functionality can be achieved using the module approach described.
Feel free to continue the discussion and argue your case if you believe this is the only way forward, but for my understanding of your need, I fail to see why existing support cannot accomplish you need.
I am quite surprised at the push-back on this and the overwhelming amount of text above. The key point is that modules effectively merge with the Zephyr tree, so far as the build system is concerned. We don't have to explicitly add full paths to things in our cmake files or device tree. It just works. With that in mind, we need Kconfig to work the same way. I cannot add relative/absolute paths to a completely different project. If I do that in platform/ec it is ignored when parsing zephyr/main Kconfig. If I do it in zephyr/main Kconfig then it breaks when the EC is at a different path or not present. Chromium OS is using upstream Zephyr. We pull down new patches every day. We cannot add 'rsource /...' into the Zephyr tree. How then would someone build Zephyr without the EC? This just seems to be completely at odds with the way Zephyr modules work. As to the empty macros, have you tried parsing the zephyr Kconfig? I think I provided the information you asked for. These commits add useful kconfiglib features along with unit tests to prevent bit rot. I respectfully request you to take another look. |
The main reason was to show it was not a single reason, but a combination of the above. I simply wanted to avoid that, and be clear on my concerns.
Devicetree uses regular For CMake, i'm unsure what you refer to. But for Kconfig, you're invoking Kconfiglib completely decoupled from the Zephyr creation of Kconfig files. Did you at all look at the description I provided to you #42233 (comment) ? Also, when using CMake, the Besides older posts then it would also be valuable to take a look here:
and I don't believe I ever requested you to do that. You create your custom logic for doing extra testing, which is very valid. That was the feedback I tried to give you, and was very detailed on how it may be achieved: #42233 (comment)
but notice, Kconfig language is not defined by Zephyr, nor by Kconfiglib project. Yes, kconfiglib / Zephyr has a number of extensions, but those are extensions, not changing fundamentally how a command like zephyr/scripts/kconfig/kconfiglib.py Lines 892 to 893 in 2636bb4
To me, what you're asking, is to change the
I tried to follow your description, and spent time on looking into it, but please notice, I (and others) have many other things to do, so don't expect me to spend hours in understanding your downstream issue. If you expect me to look even further into this, then please provide a very easy and clear description on how to experience the particular issue you're facing, and how it manifest itself when not having this PR in the Zephyr tree. As for the Kconfig macro itself, you're always welcome to open a dedicated PR for that. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Reopening as I would still like this in |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Add a few things to deal with the Kconfig used by Zephyr