extraScript in library.json

I’m running into an issue which appears to be somewhat similar to Unclear mechanics of extrascript from library.json

  • the top level of my repository is a library with library.json, jee.h, jee.cpp, etc
  • in the examples/ subdir, I have a platformio.ini based project
  • the ini file has lib_deps = jeeh=symlink://.., so that the top-level will be found and used

So far, so good:

Library Manager: Installing symlink://..
Library Manager: JeeH@2.0.0-alpha has been installed!

Now on to the issue this topic is really about: I’m trying to auto-generate a header in this library, which depends on the board being compiled for. I could do this in the example project (and have successfully done so in other contexts), but it would be much simpler if the library itself would take care of it, for each project where this library is used.

I’ve added “board” "build": { "extraScript": "extra.py" } to library.json, which according to the docs should get called whenever the library is built (as part of some PIO project). I’ve also added extra.py in the top level of course, with print statements at the top (to stdout and stderr).

But for some reason, I can’t get extra.py to run, no matter what I try … I don’t think it’s related the the “examples-inside-library” structure I’ve used, but I’m mentioning that just to be complete. There are no warnings in the pio run -v output. The build completes just fine, but it’s missing the header-generation step (or re-generation in this case).

Board or build? Redirecting...

Oops, yes, it’s “build” in the JSON file. Typo while writing the post.

And now … I do see the print output. Hrmph … brain fog, my apologies.

But perhaps more importantly, now it’s working, see https://git.jeelabs.org/jeeh/tree/examples?h=dev - the code itself is a mess, but this is huge (at least in my little book).

To recap: the idea is that JeeH is a PIO library which can be used in any PIO project, and that it’ll automatically generate a µC-specific header for the board currently being used. Instead of loading an N-megabyte header with define-s that litter up the global namespace, I can now focus on creating a lean set of functions and types. And get sub-second build times, which makes embedded C++ development almost as fast as interactive coding.

Anyway, ignore my hand-waving excitement. Right now, this library is still 100% useless.

Can you see some warning like this?

Thanks for pointing this out - yes, I did get that at some point, but I had resolved that when I posted. But our posts must have crossed - it looks like it’s all working now.

1 Like