CLI Compilation - Flattening, Ignoring, Etc

Greetings!

I am brand new to all this, and trying to get the hang of how it all works.

From my research thus far, it seems the CLI compile command uses particle.include and particle.ignore to build a directory (project).

I somewhat have this working, but I cannot get the particle.ignore file to be honored.

As it stands now, I have a particle.include of:

# particle.include
main.ino
*.cpp
*.h
carloop/firmware/*.cpp
carloop/firmware/*.h

and a particle.ignore of:

# particle.ignore
.ds_store
carloop/firmware/examples/*.cpp

I have tried variations of ._*.* and similar as found on this forum, but nothing works.

I have the carloop directory as a submodule in my git repository. As such, I do not want to delete the examples, I simply want to ignore them.

I am currently building with particle compile e . and it shows me that the .cpp files in the carloop/firmware/examples directory are being flattened and added to the compilation step, which causes it to fail.

Please let me know what I am doing wrong and what needs to happen for these files to be ignored properly.

Another interesting thing to note: if I remove everything except main.ino from the particle.include file, the CLI tool still recurses and finds all the files automatically. Perhaps this is related to why particle.ignore is being, well, ignored.

Thanks!

1 Like

I’ve gone ahead and created a custom bash script through which I manually add all the files I want to compile. This has solved my problem. Thanks!

I was about to ask this same question. I’ve updated the particle CLI to the latest version. I get the feeling that the CLI is not observing the particle.include and particle.ignore files at all.

I found this code:

but I haven’t been able to track down if that code is getting used from the CLI.

@TylerB a short term workaround is to pass every desired file from your include to the command line, though this doesn’t observe the ignore file, and doesn’t allow wildcards in the .include. But hey, better than nothing:

cat particle.include | xargs particle compile e

It seems that particle cli compilation still does not honour .particle.include and .particle.ignore

Is it meant to?

This is part of me coming to grief with this compilation return:

Compile failed. Exiting.
Server error

My thinking was that it was due to my locally copied Particle supplied libraries which have source in lib/examples// being the problem (but it is not because I have removed these sub-dirs and still the same result). This will be the subject of another ticket....

particle compile rather uses project.properties files now.
To create a project with the correct layout you can use particle project create and to add libraries you can use particel library add or particle library copy

1 Like

@SruffR, didn’t know about “particle project create” (it is not in the particle cli usage).

I see .project.properties is in my folder, so that is good news.

Are the content options for project.properties documented anywhere? Is it the same as .particle.include. and .particle.ignore?

AFAIK the “new” behaviour is that only *.cpp/*.h files in the src and lib folder will be included in the build and directory flattening is not required anymore.
#include statements for libraries either referenced via dependencies (in project.properties via particle library add or in their lib subdirectory) shall not contain the library path but only the <libraryName>.h.
If you copy a library previous versions of CLI had an issue with the examples and <libraryName> folder. I’m not sure if this bug is already cured, but you can just remove these folders from the copies.

That makes sense -> conclusion - no need to edit project.properties and no need for .particle.include and .particle.ignore.

What had thrown me was that when I ran "particle compile photon", I got lines like this:

lib/Adafruit_SSD1306/examples/ssd1306_128x64_i2c/ssd1306_128x64_i2c.ino
lib/Adafruit_SSD1306/examples/ssd1306_128x64_spi/ssd1306_128x64_spi.ino
lib/Adafruit_SSD1306/examples/surfsoon-oled/surfsoon-oled.ino

ie it looked like the examples sub-dir under a library was being compiled, but from what you have indicated (and the evidence now that I look at it), it is not (good).

Same thing with the following. I have a work in progress sub-dir "wip" at the top which gets pushed to the repo, but I don't want it compiled per se, but get lines like this with the compile:

wip/anothersubdir/another.cpp

I will call this case closed (noting that I did not open this case).

Cheers!