makefiles: add code generator targets#8573
Conversation
|
Question (maybe I miss something): what's the benefit of these make targets? IIRC instead of calling |
RIOTBASE is set automatically, so the the question about this parameter is skipped in the cli wizard. |
|
Using riotgen directly, you would need: |
|
I gave it a try, but it doesn't properly escape output for some reason: basilfx:RIOT_aabadie/ (pr/generator) $ make bootstrap-example
-e -n \033[1;31m"riotgen" command is not available, please
-e -n \033[1;31mconsider installing it from
-e \033[1;31mhttps://pypi.python.org/pypi/riotgen\033[0m
make: *** [riotgen-installed] Error 1(using zsh on macOS 10.13, normal RIOT-OS errors are colored.) |
|
@aabadie awesome!
In addition, the riotgen script might live in dist/tools. So, a make target could invoke the tool with all required env variables. |
I'm not sure it's a good idea. riotgen is not only a script, but several, and it also contains template files. That's why I tried to create a self contained python package: it's easy to install and won't bloat the RIOT code base.
In any case, riotgen will have to be modified to support extra env variables (BOARD?) |
apparently the |
4ae8af6 to
f60eda8
Compare
makefiles/tools/riotgen.inc.mk
Outdated
| @@ -0,0 +1,17 @@ | |||
| .PHONY: riotgen-installed bootstrap-% | |||
There was a problem hiding this comment.
IMO "bootstrap" is misleading
There was a problem hiding this comment.
What would you propose instead ? init-%, generate-% ?
There was a problem hiding this comment.
2 generate propositions, let's go for this one
makefiles/tools/riotgen.inc.mk
Outdated
| $(GENERATORS): %: bootstrap-% | ||
|
|
||
| bootstrap-%: riotgen-installed | ||
| @RIOTBASE=. riotgen $* |
There was a problem hiding this comment.
why "RIOTBASE=."?
because otherwise there will be a question for setting the riotbase directory. Using this environment variable skips this.
And maybe cloning from RIOT repo? Probably not a big improvement to have it in dist/tools, but could allow to "bootstrap-%" without worrying about installing external tools :) |
|
I confirm:
|
|
BTW, code looks good to me |
f60eda8 to
e877b73
Compare
bc7fed4 to
614ea94
Compare
|
@jia200x I updated the makefile to include recents changes in the upstream riot-generator (pkg generator added) and improved the targets : make auto-completion is now supported for the new targets. |
|
any interest for this ? |
614ea94 to
3d7fb56
Compare
|
up |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
|
Quite an old one indeed. |
|
Testing it now @aabadie looks quite nice, it seems like it could use an entry in the docs! |
|
Tested all commands inside |
|
Tested on MAC as well: |
|
@aabadie please correct me if I'm wrong, but as I understand the main benefit to have a make target Other I like this tool but I would like it documented somewhere in out doc, maybe in getting started? @kaspar030 you have some change requests from a while back that @aabadie seems to have answered, are you fine with the changes? Note: I haven't looked at the python code, but this doesn't seem relevant here, the functionality is what we want here. |
Can I quote you on that? ;) |
I guess, we are not reviewing external code here. If the project is merged into the organization then we can review it IMO. |
Yes and the fact that is can bootstrap a skeleton application/pkg/board/test from RIOT itself. |
Good idea, I'll push a commit asap.
I improved it slightly during the last days: now it uses Jinja2 templating engine to render the files (I should have done that from the start...). There's still room for improvement/refactoring and I'm now in the process of adding tests.
If the community is OK to maintain such a tool in a separate repository, that would be great indeed. |
I can propose something. Is it ok if it's in a follow-up PR ? |
These targets will bootstrap code for an example application, a test application or a new board support. The 'riotgen' tool is used behind
|
The latest version of riotgen is now also able to generate the source code of a driver and of a module. I adapted the PR accordingly. |
If you open it right away :) |
(so we can nitpick there, while getting this in) |
|
here is the documentation @fjmolinas => #14103 |
|
ACK! |
|
Thank you for the review @fjmolinas ! |
Contribution description
This PR adds 3 new code bootstrap targets (bootstrap-{example,board,test}) in the build system. The feature relies on riotgen, a small Python tool I wrote to generate empty RIOT code projects.
The idea is to use these targets when one wants to start a new example application, test application or board support: all copyright headers are correctly setup, with main.c files, README, etc. This should simplify initial boring work and improve contribution quality of newcomers.
Just call them using
makeand answer a few questions:Since I'm not a Makefile expert, comments are very welcome.
Hope people will find this useful.
Follow-up potential work:
Issues/PRs references
None