Hide defaults & extra upgrades#10
Conversation
Signed-off-by: Emilio Bottoni <emilio.bottoni@edge.ufal.br>
Signed-off-by: Emilio Bottoni <emilio.bottoni@edge.ufal.br>
There was a problem hiding this comment.
Code Review
This pull request expands the scaffolding system by adding an "append" mode for file patching, introducing specialized field types for path normalization, and allowing built-in components to be hidden. It also includes several example components and a new devicetree compatibility validator. Review feedback highlights a critical bug in the line-by-line deduplication logic for file appending and suggests more robust path handling to prevent potential crashes when calculating relative paths.
There was a problem hiding this comment.
Pull request overview
This PR extends scaffold’s component discovery and generation pipeline: it adds a hide_defaults option for suppressing built-in components, repackages the built-in component definitions under example_components, and broadens descriptor/template support with path normalization and append-style rendering.
Changes:
- Adds config/CLI handling for
hide_defaultsplus an empty-component warning/clean exit path. - Moves built-in component definitions/templates into packaged
example_components/*subpackages and updates registry/package wiring. - Expands descriptor/engine/template behavior with path normalization, new generated files, and refreshed built-in templates.
Reviewed changes
Copilot reviewed 26 out of 52 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_descriptors.py |
Adds descriptor normalization tests. |
scaffold/validators.py |
Adds devicetree compatible validator. |
scaffold/engine.py |
Normalizes field values and adds append/patch rendering flow. |
scaffold/descriptors.py |
Introduces FieldDir, FieldPath, and append-capable TemplateFile. |
scaffold/config_schema.json |
Adds hide_defaults config key. |
scaffold/components/__init__.py |
Loads packaged example components and adds default-purging logic. |
scaffold/cli.py |
Wires hide_defaults into CLI flow and empty-registry warning. |
pyproject.toml |
Packages example_components and their template data. |
external_templates/templates/shell_cmd/name_cmd.c.j2 |
Removes old external shell command example template. |
external_templates/templates/shell_cmd/CMakeLists.txt.j2 |
Removes old external shell command CMake template. |
external_templates/templates/module/name.h.j2 |
Removes old external module header template. |
external_templates/templates/module/name.c.j2 |
Removes old external module source template. |
external_templates/templates/module/CMakeLists.txt.j2 |
Removes old external module CMake template. |
external_templates/shell_cmd.py |
Removes old external shell command example component. |
external_templates/module.py |
Removes old external module example component. |
example_components/test/test.py |
Reworks built-in test component descriptor. |
example_components/test/templates/testcase.yaml.j2 |
Adds testcase manifest template. |
example_components/test/templates/README.md.j2 |
Updates generated test README path usage. |
example_components/test/templates/prj.conf.j2 |
Adds default test config template. |
example_components/test/templates/main.c.j2 |
Renames generated test source file and adds header block. |
example_components/test/templates/CMakeLists.txt.j2 |
Updates generated test target/source naming. |
example_components/test/__init__.py |
Marks packaged test component module. |
example_components/service/templates/README.md.j2 |
Adds generated service README template. |
example_components/service/templates/Kconfig.j2 |
Adds service Kconfig/logging template. |
example_components/service/templates/internal.h.j2 |
Adds internal service header template. |
example_components/service/templates/impl.c.j2 |
Adds service implementation template. |
example_components/service/templates/CMakeLists.txt.j2 |
Adds service CMake template. |
example_components/service/templates/access.h.j2 |
Adds public service API header template. |
example_components/service/service.py |
Reworks built-in service component descriptor. |
example_components/service/__init__.py |
Marks packaged service component module. |
example_components/sample/templates/sample.yaml.j2 |
Adds sample manifest template. |
example_components/sample/templates/README.md.j2 |
Updates generated sample README path usage. |
example_components/sample/templates/prj.conf.j2 |
Adds sample config template. |
example_components/sample/templates/main.c.j2 |
Adds sample source template. |
example_components/sample/templates/CMakeLists.txt.j2 |
Adds sample CMake template. |
example_components/sample/sample.py |
Reworks built-in sample component descriptor. |
example_components/sample/__init__.py |
Marks packaged sample component module. |
example_components/lib/templates/README.md.j2 |
Updates generated library README path usage. |
example_components/lib/templates/name.h.j2 |
Adds library API header template. |
example_components/lib/templates/name.c.j2 |
Adds library source template. |
example_components/lib/templates/Kconfig.j2 |
Changes library Kconfig symbol naming. |
example_components/lib/templates/CMakeLists.txt.j2 |
Adds library CMake template. |
example_components/lib/lib.py |
Reworks built-in library component descriptor. |
example_components/lib/__init__.py |
Marks packaged library component module. |
example_components/driver/templates/README.md.j2 |
Adds generated driver README template. |
example_components/driver/templates/name.h.j2 |
Adds driver API header template. |
example_components/driver/templates/name.c.j2 |
Adds driver source template. |
example_components/driver/templates/Kconfig.j2 |
Adds driver Kconfig/logging template. |
example_components/driver/templates/CMakeLists.txt.j2 |
Adds driver CMake template. |
example_components/driver/driver.py |
Reworks built-in driver component descriptor. |
example_components/driver/__init__.py |
Marks packaged driver component module. |
example_components/__init__.py |
Marks top-level packaged built-in components namespace. |
Comments suppressed due to low confidence (1)
example_components/lib/templates/Kconfig.j2:1
- After changing the Kconfig symbol prefix to
LIB_..., the other library templates still use the old unprefixed name. In particular the generated C file still referencesCONFIG_<NAME>_LOG_LEVEL, so newly generated libraries will fail to build because that symbol is no longer defined by the Kconfig template.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
878e29c to
98f724a
Compare
Signed-off-by: Emilio Bottoni <emilio.bottoni@edge.ufal.br>
98f724a to
603dbe0
Compare
This pull request introduces several improvements to the project’s structure, documentation, and configuration, focusing on making external component support clearer and more flexible. The main changes include reorganizing built-in components into an
example_componentsdirectory, updating documentation for external component usage, and adding pre-commit hooks for consistent formatting and linting.Component system restructuring and externalization:
driver,lib,sample) fromscaffold/components/toexample_components/, updated their imports, and settemplates_dirto use a path relative to each component’s location for better modularity. [1] [2] [3] [4] [5] [6] [7] [8] [9]libcomponent to use variables forpathand to prefix Kconfig symbols withLIB_for clarity and consistency. [1] [2]Documentation and developer workflow improvements:
README.mdwith detailed instructions and examples for using external components, overriding built-ins, and using new options like--hide-defaults. The process for adding new built-in and external components is now more explicit. [1] [2] [3] [4] [5] [6] [7]CONTRIBUTING.mdwith clear setup, linting, and testing instructions, including the use ofpre-commitfor local checks.Pre-commit and linting setup:
.pre-commit-config.yamlto enforce linting and formatting for Python and YAML files usingruffandyamllint, ensuring code quality and consistency before commits.