The CLI now knows how to compile library examples.
Upgrade to the latest beta: npm install -g https://github.com/spark/particle-cli/releases/download/v1.19.0-libraries.20/particle-cli-1.19.0-libraries.20.tgz
To compile an example in your library, open a terminal to the library directory and do: particle compile photon examples/name_of_example
It creates a project on the fly with the example and the library source.
@jvanier, this way to build samples seems to have issues with the default stub headers created by particle library migrate inside the src folder.
I always get
Compile failed. Exiting.
In file included from /src/libName.cpp:xx:yy:
/src/libName.h:xx:yy: fatal error: ../libName.h: No such file or directory
#include "../libName.h"
When I remove that subfolder from src it builds fine, but I guess I might produce issues when uploading, since there ought to be a reason why migrate creates this folder and dummy headers.
@jvanier, true that error message does not pop up anymore, but no I just get a non-descriptive “Compile failed” for all of my lib examples that did build yesterday.
Is there a 1.19.2 for that? npm update -g particle-cli doesn’t do anything for me - still only 1.19.1
Now I’ve got a funny new behaviour (had something similar a while ago). particle compile photon examples/dmy --target 0.6.1-rc.2 seems to build some other code.
Although I have got some definetly not compilable code I get this from that command
C:\Users\Particle\Libraries2.0\_todo_\uploaded\PS2Communication>particle compile photon examples/dmy --saveTo firmware.bin --target 0.6.1-rc.2
Compiling code for photon
Targeting version: 0.6.1-rc.2
Including:
examples\dmy\dmy.ino
library.properties
src\PS2Communication.cpp
src\PS2Communication.h
src\PS2Communication\PS2Communication.h
attempting to compile firmware
downloading binary from: /v1/binaries/588b1b7fdcc9827d6858e4fd
saving to: firmware.bin
Memory use:
text data bss dec hex filename
4460 8 1420 5888 1700 /workspace/target/workspace.elf
Compile succeeded.
Saved firmware to: C:\Users\Particle\Libraries2.0\_todo_\uploaded\PS2Communication\firmware.bin
And not surprisingly, when building and flashing code that wouldn’t throw errors, I’d assume the build was fine and I’d scratch my head why that code is not doing what I’d expect it to do.
Pretending to build your code and downloading a rather obscure binary (which I don’t know what it actually does) isn’t a reassuring experience
However building for targets pre 0.6.1-rc.2 works as expected
I’ll give it a try.
But the funny thing with above sketch is that it already used #pragma SPARK_NO_PREPROCESSOR so was there another preproc playing up or did the Wiring preproc still interfere despite being told not to?
The example has a .ino extension. The preprocessor is responsible for renaming the file to .cpp even if it doesn’t change the content. The issue was that the preprocessor wasn’t renaming the file