So, returning to this after a few days, I thought I had it sorted but realise I haven’t. I’ve got the structure and can compile individual files however I don’t get how to compile all the example src files in one go, neither do I understand how to set the build_dir explicitly. I’ve looked through the documentation for about an hour and it makes little sense to me though I feel what I’m doing should be trivial
The command I’m using is:
pio ci --board=uno lib/RandomNumber/examples/example-01 --lib lib/RandomNumber
I tried */ instead of examples/example-01 but that didn’t help
Neither am I totally sure of what the --lib flag is doing. I thought it was the source but it doesn’t seem to be compiling everything.
Those have to be individual commands. pio ci creates as said a dynamic project on the fly, and one final firmware should only contain one example, otherwise all the main functions (like setup() and loop()) will be conflicting. See e.g. this (uses pio run though instead of pio ci)
One can create a special PlatformIO project for this purpose by creating multiple enviornments with different src_filter settings, each of which only enables the compilation of one test. But it’s most common to just compile one example at a time (automated for all exampels of course in CI).
I must admit I’m on the verge of going back to the Arduino IDE - at least it works, is predictable and easy to use - even if it is a pain. I just don’t see how platformio is helping in anyway at all.
I can’t compile multiple examples at once
I can’t see errors in the editor until I compile
I can’t make head nor tail of the ‘documentation’
I feel like I’ve never coded in my life before using this product yet I have for decades.
Why do I have to create a ‘special PlatformIO project with multiple environments…’
You do this sort of thing in Java and node and Python in 5 minutes. Why is this so weird?
Found one of my issues - Having set the default parser to TagParser, all my real-time syntax checking no longer worked.
Changed this back to default and it works.
Finally some progress
Now I just need to figure out how to compile the library files all in one go
thanks although it isn’t the library structure that is difficult. It is simple to create a library. PlatformIO is the problem. Seems hard to do anything. It is also the C++ plugin for VS Code that I’m fighting with although I got it to syntax check and format correctly yesterday.
It seems I can’t compile all the examples at once which is my next issue. I might have to settle for copying and pasting each example into the src folder main.cpp file or issuing a separate pio ci command for each example manually.
There must be a way to automate this as I’d like to get unit tests if possible and a deploy target to productionize the build - however it is slow progress.
Which one? The Microsoft one is the only one that should be installed, others being installed at the same time cause problems and also do so for PlatformIO.
Its ok I figured out the config and it works fine.
One other thing is unit testing with my setup. I would like to write and run tests to test the library functions. I don’t mind manually running the tests. Have you done this before?