Conversation
|
I've changed xtimer's auto init to use snippets in order to show how this is supposed to be used. |
|
Couldn't you just use |
|
@gebart Yes, much simpler. |
|
Nice one! :) |
|
Fun thing to try: |
|
I like the idea. 👍 Maybe add an underscore after the index for better readability? |
|
I have some thoughts regarding file names:
Since the |
I thought about that, it might be possible to use make filters filters if they're called something like *.snip.c. Then we'd have to create filter rules for all filetypes, currently this would probably also work with headers. I'll look into it... |
good idea! |
|
Ok, the snippets are now called @Kijewski I tried with a '_' between snip and number, but somehow I liked it better like this. What do you think? |
|
I'll close this in favor of a linker-script based solution. |
First try at #4290.
Whenever a module dir contains "NNname.c.snip" (with NN a decimal), the makefile concatenates that file with all other "NNname.c.snip" of other modules into $(BINDIR)/snippets/name.c and compiles all combined files into a "snippets" module.
For all but the application module, the snippets get enclosed by
#ifdef MODULE_X ... #endifThat way, static array definitions, functions, ... can be spread over multiple files in all module directories.
Imagine shell commands, auto_init, saul parameters, device driver parameters, coap endpoints, .. can be defined by just adding a snippet where it belongs.
You've hooked up another radio (same as onboard) to your board? Just drop a file "01at86rf2xx_params.c.snip" into your application folder, containing only the array entry for the added device.
Your module auto_inits? Just drop a 01auto_init.c.snip into it's folder, no more rebase conflicts in sys/auto_init/auto_init.c.
What do you guys think?