# CLI Compilation - Flattening, Ignoring, Etc

**URL:** <https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134>\
**Category:** Troubleshooting\
**Created:** [November 8, 2016, 6:42pm UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134 "2016-11-08T18:42:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TylerB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tylerb/32/12030_2.png) [@TylerB](https://community.particle.io/u/TylerB)\
**Post date:** [November 8, 2016, 6:42pm UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/1 "2016-11-08T18:42:13Z")

</div>

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:

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

```

and a `particle.ignore` of:

```auto
# 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!

---

<div class="post-metadata">

**Author:** ![TylerB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tylerb/32/12030_2.png) [@TylerB](https://community.particle.io/u/TylerB)\
**Post date:** [November 13, 2016, 6:16pm UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/2 "2016-11-13T18:16:04Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dgmltn](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dgmltn/32/6631_2.png) [@dgmltn](https://community.particle.io/u/dgmltn)\
**Post date:** [November 13, 2016, 6:24pm UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/3 "2016-11-13T18:24:00Z")

</div>

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:

> <https://github.com/particle-iot/particle-cli/blob/d90e54b1813c6b913248ac21e0aca51a7d8d2ecd/commands/CloudCommands.js>

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:

```auto
cat particle.include | xargs particle compile e

```

---

<div class="post-metadata">

**Author:** ![UMD](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/umd/32/5850_2.png) [@UMD](https://community.particle.io/u/UMD)\
**Post date:** [April 6, 2018, 6:50am UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/4 "2018-04-06T06:50:30Z")

</div>

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....

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [April 6, 2018, 9:05am UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/5 "2018-04-06T09:05:59Z")

</div>

`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`

---

<div class="post-metadata">

**Author:** ![UMD](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/umd/32/5850_2.png) [@UMD](https://community.particle.io/u/UMD)\
**Post date:** [April 6, 2018, 9:25am UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/6 "2018-04-06T09:25:25Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [April 6, 2018, 10:43am UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/7 "2018-04-06T10:43:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![UMD](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/umd/32/5850_2.png) [@UMD](https://community.particle.io/u/UMD)\
**Post date:** [April 6, 2018, 1:08pm UTC](https://community.particle.io/t/cli-compilation-flattening-ignoring-etc/27134/8 "2018-04-06T13:08:35Z")

</div>

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!
