Skip to content

scripts: implement automatic generation of various files#335

Draft
mathieuchopstm wants to merge 3 commits intozephyrproject-rtos:mainfrom
mathieuchopstm:topic/autogenpkg
Draft

scripts: implement automatic generation of various files#335
mathieuchopstm wants to merge 3 commits intozephyrproject-rtos:mainfrom
mathieuchopstm:topic/autogenpkg

Conversation

@mathieuchopstm
Copy link
Copy Markdown
Collaborator

Add a new script autogenpackage (better name suggestions welcome) which can be used to automatically generate various files that were so far hand-authored:

  • list of series supported by the HAL module
  • HAL assert header stm32_assert.h
    • Build system is slightly tweaked to use a common file as done with common_ll
    • This makes the package more maintainable and reduces space usage
  • per-series CMakeLists.txt

Additionally, the script can generate the Zephyr-side modules/Kconfig.stm32, ensuring that the HAL and Zephyr side of the module are always in sync. Other features include the ability to gate different drivers under the same Kconfig option (e.g., DLYB for drivers called dlyb.c on some series and delayblock.c on others) and easily include or force-exclude drivers from the build system (although this should be done as little as possible).

As part of this PR, the series list and stm32_assert.h are updated for the new infrastructure, but per-series CMakeLists.txt is left unchanged for now.

There are still some points to discuss (e.g., script is oriented towards system_stm32XXxx.c removal) so this PR is opened as draft for discussion.

Add an automatic generator for various files found in the hal_stm32 repo:
 - global stm32_assert.h header
 - global series list enumeration
 - per-series top-level CMakeLists
 - Zephyr-side modules/Kconfig.stm32

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Generate series list using autogenpackage and consume this auto-generated
list in the module's top-level CMakeLists.txt

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Generate multi-series stm32_assert.h using autogenpackage and consume it
by replacing all existing files with one in a shared include directory,
which is then added to the zephyr_include_directories().

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Copy link
Copy Markdown
Collaborator

@djiatsaf-st djiatsaf-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested locally, and it works fine, but I have some questions /suggestions:

@mathieuchopstm
Copy link
Copy Markdown
Collaborator Author

The new files are entirely generated from scratch (i.e., they have no relation to the "old" ones) so I don't think the old copyright has any reason to apply. On the other hand, maybe the copyright notice should be removed from the script-generated headers since they are merely script-generated.

# Copyright (c) 2019 Linaro Limited

  • Is it possible to add a --only-series option for a limited scope? This could be used when introducing a new series to generate packages only for that series instead of all series.

Why? The script is idempotent, if you run it multiple times on the same files (i.e., unmodified series) then it won't have any effect. Unlike genpinctrl, there's also no performance issue here so I don't see the point of implementing filtering. Also, some operations of the script are global (based on all series) so how would filtering even work? Ignore the excluded series entirely? Ignore them individually but include them for global?

@djiatsaf-st
Copy link
Copy Markdown
Collaborator

The new files are entirely generated from scratch (i.e., they have no relation to the "old" ones) so I don't think the old copyright has any reason to apply. On the other hand, maybe the copyright notice should be removed from the script-generated headers since they are merely script-generated.

Okay, I understand. I think so; it will align with the other HAL-generated files.

Why? The script is idempotent, if you run it multiple times on the same files (i.e., unmodified series) then it won't have any effect. Unlike genpinctrl, there's also no performance issue here so I don't see the point of implementing filtering. Also, some operations of the script are global (based on all series) so how would filtering even work? Ignore the excluded series entirely? Ignore them individually but include them for global?

Okay, I see. I was too focused on harmonizing the functions, like with HAL update and genpintcrl.

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.

2 participants