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

llext-edk: rework, read data from build_info.yml and .config #83705

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

pillo79
Copy link
Collaborator

@pillo79 pillo79 commented Jan 8, 2025

This PR improves the LLEXT EDK in several ways:

  • an internal rework to reduce code duplication and improve extensibility
  • read existing data from the current build artifacts, instead of using arguments

It is effectively a subset of #78727 that does not add any new information to the LLEXT EDK.

Note

The first 6 commits, up and including 0600b1c, are the contents of PR #80007 and will be removed once that PR is merged.

pillo79 added 12 commits January 7, 2025 10:38
This introductory commit refactors the `yaml_set` function separating
the bodies of list operations into internal functions while preserving
their original behavior.

The conditions that cause the value to be interpreted as a list are also
verified only once, avoiding multiple checks.

Signed-off-by: Luca Burelli <[email protected]>
This introductory commit removes the ignored 'actual' variable from the
'yaml_set()' calls in the tests to make the code cleaner. Also, a badly
indented block is fixed in the 'message()' macro.

No functional change is introduced by this commit.

Signed-off-by: Luca Burelli <[email protected]>
This test verifies that the APPEND LIST operation in yaml_set() works as
expected.

Signed-off-by: Luca Burelli <[email protected]>
To verify proper functionality, the YAML module test suite is now run
twice: once in the regular CMake project mode and once in the CMake
script mode.

Signed-off-by: Luca Burelli <[email protected]>
This commit adds support for generator expressions in values and lists
to the yaml module.

Generator expressions can only be expanded by CMake after all
configuration code has been executed and the final values of the project
properties are defined. This means that contexts that contain generator
expressions are written twice:

 - the first time, during yaml_save(), a comment with the raw unexpanded
   string is saved instead of the key that uses generator expressions in
   the YAML file;

 - the second time, as a pre-build step of a target, the generator
   expressions are expanded, and the final YAML file is written.

This two-step process also allows to overcome the issue of lists that
are extracted from generator expressions, whose elements would be
expanded into a single string if written directly to the YAML file.
Instead, the lists are stored in their CMake string format with a
special marker, expanded by CMake into a temporary JSON file, and the
conversion to a proper list is performed during the pre-build step.

Note that when generator expressions are used in the context:

 - the GENEX keyword must be provided to yaml_set(), to mark the context
   as containing generator expressions; this is necessary to avoid
   storing the genexes as raw strings in the YAML.

 - the YAML file must be written providing the TARGET parameter to
   yaml_save().  If it is not provided, a warning will be issued and
   only the partial file will be written.

Signed-off-by: Luca Burelli <[email protected]>
Add tests to the YAML suite for generator expressions. The test checks
that generator expressions are handled as expected at different stages:

 - immediately after yaml_save(), the file must contain only non-genex
   entries;
 - at a later time, after the target has been built, the file must
   contain all the expanded genex values.

Signed-off-by: Luca Burelli <[email protected]>
This introductory commit refactors 'build_info()' to use the standard
`cmake_parse_arguments()` and Zephyr helper functions instead of
manually parsing the argument list, to allow additional arguments to
be added.

No functional change is intended in this commit.

Signed-off-by: Luca Burelli <[email protected]>
This patch enables support for generator expressions in the `build_info()`
function by passing the GENEX flag to yaml_set().

This is currently not supported with PATH values, because the actual
contents of the list (whose paths are to be converted) are not known
until after the cmake code has been processed.

Signed-off-by: Luca Burelli <[email protected]>
This commit refactors the code that generates the Makefile and CMake
EDK files into functions that accept the file type as an argument.

No functional changes are introduced in this commit.

Signed-off-by: Luca Burelli <[email protected]>
This commit removes all CMake- or Makefile-specific variables from the
code and instead uses a single list for each type of flag. Where a
difference is needed between the two, a special marker is used.
These markers are replaced later in the target-specific area of the
write functions.

Escaping of problematic characters is also added to the write functions,
to ensure that quotes and backslashes in the flags are properly handled.

Signed-off-by: Luca Burelli <[email protected]>
Currently, the llext-edk.cmake script requires a number of variables to
be passed in from the main CMakeLists.txt file as arguments to be able
to customize the generated files.

To improve this rigid approach, the script is modified to read in the
following files in the build directory:

 * 'zephyr/.config', for the final set of Kconfig options used;
 * 'build_info.yml', for the cmake-related variables.

This is more flexible and also easier to maintain, as it doesn't require
manual changes to the main CMakelists.txt file when new variables need
to be referenced.

Signed-off-by: Luca Burelli <[email protected]>
Extend the documentation for the LLEXT EDK to include information about
the target and toolchain information that is now exported by the EDK and
the new output format.

Signed-off-by: Luca Burelli <[email protected]>
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.

1 participant