-
Notifications
You must be signed in to change notification settings - Fork 0
Add configuration file support with variable substitution to dmd, dmr, and dmf-get #202
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
Add configuration file support with variable substitution to dmd, dmr, and dmf-get #202
Conversation
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
…onstants Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
|
@copilot zrób jeszcze tak, żeby przy kopiowaniu domyślna docelowa nazwa pliku konfiguracji to było Co więcej powinno się dać wpisać w dmd ten sam driver kilka razy tylko z inna konfiguracja (jeśli by wersja drivera się zmieniła, czyli np pierwszy wpis miał 0.1 a drugi 0.2 - to wtedy weźmy moduł drivera z pierwszego wpisu, a pliki konfiguracyjne z różnych wersji - tak jak w pliku. Czyli można np podać: W takim przypadku używamy drivera w wersji 1.0, konfiguracji stm32f7 z 0.1 oraz high-speed z 0.2 Co więcej powinna być możliwość zmiany nazwy pliku docelowego, np: Wtedy plik po przekopiowaniu do folderu docelowego powinien mieć nazwę clk.ini (folder o nazwie dmclk wtedy nie jest potrzebny) |
…edback Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Implemented all requested features in commit d7c8816:
All 26 tests pass. Documentation and examples updated. |
|
|
||
| # Module with custom destination filename | ||
| # This will create clk.ini directly in config dir (without dmclk/ subdirectory) | ||
| dmclk@1.0 mcu/stm32f7.ini clk.ini |
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.
@copilot ale jeśli bym jako dest podał mydir/CLK.ini to stworzy folder mydir? Powinno
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.
Tak, już działa. Kod w linii 975 używa mkdir -p który tworzy wszystkie potrzebne katalogi nadrzędne. Dla mydir/CLK.ini stworzy folder mydir w katalogu config-dir.
| Dmod_Printf(" -d, --dependencies <path> Path or URL to dependencies (.dmd) file\n"); | ||
| Dmod_Printf(" -m, --manifest <path> Path or URL to manifest file\n"); | ||
| Dmod_Printf(" -o, --output-dir <path> Output directory for downloaded modules\n"); | ||
| Dmod_Printf(" --config-dir <path> Directory where configuration files should be copied\n"); |
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.
Jeszcze w tych ścieżkach może się przydać variable substitution - żeby można było podać np <tool_dir> albo <cpu_family> w ścieżce wejściowej albo w dst. Ponadto by się przydała nowa zmienna "board-name" która też by mogła być podawana z parametru @copilot
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.
Komentarz jest niekompletny. Możesz dokończyć myśl? Jakie dokładnie variable substitution chciałbyś mieć w ścieżkach konfiguracji? Na przykład:
${module}dla nazwy modułu?${version}dla wersji?- Zmienne środowiskowe jak
${HOME}?
Podaj przykład jak chciałbyś użyć tej funkcjonalności.
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.
@copilot Chodzi mi o to, żeby w pliku *.dmd można było użyć zmiennych przekazanych w parametrach komendy, czyli np:
dmclk@1.0 boards/<board_name>.ini
I teraz przy zawołaniu komendy dać:
dmf-get dmclk --board-name stm32f7-discovery I to samo ze ścieżką docelową w dmd - żeby też można było w niej użyć tych zmiennych (board-name, tool-name, cpu family, czy co tam jeszcze jest w parametrach takiego)
Z tego co pamiętam, to już gdzieś jest podobny mechanizm w dmf-get przy okazji któregoś pliku
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.
Przykład nadal jest niekompletny - kończy się na boards/. Możesz podać pełny przykład? Na przykład:
dmclk@1.0 boards/${BOARD_NAME}/config.ini
I wtedy wywołując dmf-get -d deps.dmd --config-dir ./config --define BOARD_NAME=stm32f7 skopiowałby boards/stm32f7/config.ini?
Czy o to chodzi?
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.
@copilot jaki niekompletny? podałem dmclk@1.0 boards/< board_name >.ini
Sprawdź jak przekazywane są zmienne w innych miejscach - jeśli tam jest w formacie ${BOARD_NAME}, to niech tutaj też będzie w ten sam sposób - byle by było spójne
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.
Zaimplementowane w commit aacf3ff. Variable substitution używa formatu ${VAR_NAME} zgodnie z istniejącym kodem w .dmr.
Przykład użycia:
dmclk@1.0 boards/${BOARD}/config.ini
uart@2.0 boards/${BOARD}/uart.ini ${BOARD}_uart.ini
Wywołanie:
dmf-get -d deps.dmd --config-dir ./config -D BOARD=stm32f7Zmienne sprawdzane są w kolejności:
- User-defined variables (przez
-D) - Zmienne środowiskowe
Działa zarówno w ścieżkach źródłowych jak i w custom destination names.
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. |
Modules can now specify configuration files that are copied during installation. This enables per-module configuration management within the package system with support for variable substitution in configuration paths.
Changes
.dmdformat extensionmodule[@version] [config_path] [custom_dest_name]$fromdirectives:dmclk@1.0 mcu/stm32f7.ini $from https://example.com/manifest.dmm${VARIABLE_NAME}syntax for dynamic path resolution.dmrformat extensionconfigorconfigsresource keyconfig=./configs => ${destination}/${module}/configdmf-getenhancement--config-diroption specifies where configuration files are copied-D/--defineoption to define variables for config path substitution-D VAR=valueor--define VAR=value.dmrdefinition, falls back to<module>/config/if undefinedIsPathSafe()mechanism<config-dir>/<module_name>/<filename><config-dir>/<custom_dest_name>Usage
Implementation details
configandconfig_destfields toDmod_DependencyEntry_t(max 256 chars each)CopyConfigurationFile()resolves config location and copies to module subdirectory by defaultSubstituteConfigVariables()handles${VAR}expansionDMOD_MAX_PATH_LENandDMOD_MAX_CMD_LENadded for consistencyBackward compatible - existing
.dmdfiles without config specifications work unchanged.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.