Subdirectories not compiling in CLI [Fixed]

Ahoy all.

Back in November I started a project based on the Spark Transport Display project and using that as a starting point.

Back then my project compiled properly using the CLI, but now it’s not. In a nutshell: the compiler ignores all files in the /lib subdirectory, and only compiles the files in the main project directory, then fails because it doesn’t see the /lib files that are referenced.

And, the same breakage happens now when I try to compile the original Spark Transport Display code.

Here’s the relevant error text:

Errors
In file included from Transport.cpp:1:0:
Transport.h:4:36: fatal error: Adafruit_CharacterOLED.h: No such file or directory
 #include "Adafruit_CharacterOLED.h"
                                    ^
compilation terminated.
make: *** [Transport.o] Error 1

Compile failed -  compile failed 

You can see all the files and try it yourself via Github: http://github.com/synox/spark-transport-display

Any idea as to what happened or how to fix this?

Thanks!

1 Like

@savage, you may have to create a spark.include file in your directory and see if you can include the lib directory via that. I have not tested this yet but it’s worth a shot. :smile:

Already did. :wink: The original project has a spark.include:

https://github.com/synox/spark-transport-display/blob/master/firmware/spark.include

1 Like

any updates on this? I’ve been having the same issue with my project as well. The spark.include file hasn’t changed and was working before.

I noticed this issue after I updated to spark-cli 0.4.93

maybe @bko has seen this as well?

@savage maybe try reverting spark-cli to an older version? http://community.spark.io/t/best-way-to-setup-spark-project-boilerplate/8587/4?u=ubergeek82

@kennethlimcp files explicitly defined in the spark.include file were pushed correctly in 0.4.5. Seems to be a problem in 0.4.93

2 Likes

For me it worked with spark-cli version 0.4.4, but now with 0.4.93 i have the same issue.

In version 0.4.4 the files in the subdirectory would be included for upload, but in version 0.4.93 they are not.

spark compile .
Including:
    /Users/synox/workspace-cpp/spark-transport-display/firmware/Transport.h
    /Users/synox/workspace-cpp/spark-transport-display/firmware/openweathermap.h
    /Users/synox/workspace-cpp/spark-transport-display/firmware/application.ino
    /Users/synox/workspace-cpp/spark-transport-display/firmware/Transport.cpp
    /Users/synox/workspace-cpp/spark-transport-display/firmware/openweathermap.cpp
attempting to compile firmware
pushing file: /Users/synox/workspace-cpp/spark-transport-display/firmware/Transport.h
pushing file: /Users/synox/workspace-cpp/spark-transport-display/firmware/openweathermap.h
pushing file: /Users/synox/workspace-cpp/spark-transport-display/firmware/application.ino
pushing file: /Users/synox/workspace-cpp/spark-transport-display/firmware/Transport.cpp
pushing file: /Users/synox/workspace-cpp/spark-transport-display/firmware/openweathermap.cpp
Errors
2 Likes

So this is a good question for @Dave and @harrisonhjones

The most recent updates to the Spark-CLI reverted the TI CC3000 patcher level and changed the readme instructions to do npm install. That doesn’t seem related.

2 Likes

Spark-cli is supposed to be able to expand all subfolders and push them for compilation.

can you try it without the spark.include file?

There’s some bug the other time I test that might be related.

Hi @Coffee,

I believe the default behavior (without adding a spark.include file), is to grab any source files (*.h, *.c, *.cpp, *.ino) in the directory provided. If you have a spark.include file in that directory, it’ll parse it and interpret any wildcards.

  • spark compile . / spark compile /some/directory

    • look for spark.include / spark.ignore files in that folder, or just grab any source files from there
  • spark compile foo.cpp foo.h main.ino

    • send those files specifically to compile

I think this has always been the default behavior… Maybe I’m confused? Here’s a generic spark.include file that should include everything in subdirectories:

#spark.include 
# from current dir
*.h
*.ino
*.cpp
*.c

# and from any subdirectories
**/*.h
**/*.ino
**/*.cpp
**/*.c

I don’t believe I changed this behavior in the last release, but it’s possible some submodule got updated and broke something. Please do let me know if this doesn’t seem right, or if anyone has more info.

Thanks,
David

1 Like

without the spark.include file, it just includes all the .h/.cpp/.ino files in the current directory.

when I create a spark.include it actually it does respect any settings in it. It still takes only the default files from the current directory.

Hi @Coffee,

I uh, wow, heh, just found a really dumb bug on my part.

1 sec,

Thanks,
David

4 Likes

Hi @Coffee / All,

Thank you for bumping this, I’m sorry it took me this long to find the bug. If you notice something stop working like this, please ping me with @Dave, or feel free to open an issue on the repo directly (which will email me). I just released 0.4.94 which should fix the issue of ‘spark.include’ files not being considered. You can update the cli with this command:

npm update -g spark-cli

#and check the version with:
spark --version

#should report 0.4.94

Here’s the repo link if you find other issues.

Thanks!
David

4 Likes

Looks like I am still hitting this problem with 0.4.94. It complains about .h files not found in subdirectory, and when I move those files to the main directory (and changed the #include’s together with the spark.include) it works perfectly. Here is what happened when the MFRC522.* were inside the subdirectory MFRC522:

bleu:Spark edwintam$ spark compile musicsense
Including:
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.cpp
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.h
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.cpp
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.h
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/musicsense.ino
attempting to compile firmware 
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.cpp
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.h
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.cpp
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.h
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/musicsense.ino
Errors
musicsense.cpp:3:29: fatal error: MFRC522/MFRC522.h: No such file or directory
 void transfer_data_lcd(byte ucData);
                             ^
compilation terminated.
make: *** [musicsense.o] Error 1

Compile failed -  compile failed
bleu:Spark edwintam$ ls -R musicsense/
HTTPClient.cpp    MFRC522        spark.ignore
HTTPClient.h    musicsense.ino    spark.include

musicsense//MFRC522:
MFRC522.cpp    MFRC522.h
bleu:Spark edwintam$ head musicsense/musicsense.ino 
// This #include statement was automatically added by the Spark IDE.
#include "HTTPClient.h"
#include "MFRC522/MFRC522.h"
#define version 102

/****************************************************************************
 *   Project: Generic project name                                           *
 *                                                                           *
 ****************************************************************************/

bleu:Spark edwintam$ cat musicsense/spark.include 
HTTPClient.cpp
HTTPClient.h
MFRC522/MFRC522.cpp
MFRC522/MFRC522.h
musicsense.ino

bleu:Spark edwintam$ spark --version
0.4.94
bleu:Spark edwintam$ 

//Ed

Trying making a spark.include file with:

#spark.include 
# from current dir
*.h
*.ino
*.cpp
*.c

# and from any subdirectories
**/*.h
**/*.ino
**/*.cpp
**/*.c

No good: same error.

musicsense.cpp:3:29: fatal error: MFRC522/MFRC522.h: No such file or directory


bleu:Spark edwintam$ ls -R musicsense
HTTPClient.cpp    MFRC522        spark.ignore
HTTPClient.h    musicsense.ino    spark.include

musicsense/MFRC522:
MFRC522.cpp    MFRC522.h    spark.include
bleu:Spark edwintam$ cat musicsense/spark.include 
*.cpp
*.ino
*.h
*.c
bleu:Spark edwintam$ cat musicsense/MFRC522/spark.include 
**/*.cpp
**/*.ino
**/*.h
**/*.cbleu:Spark edwintam$

you are probably doing it wrongly.

There should only be one spark.include file with all the stuff i pasted inside the root directory :wink:

Still no good.

bleu:Spark edwintam$ ls -R musicsense
HTTPClient.cpp    MFRC522        spark.ignore
HTTPClient.h    musicsense.ino    spark.include

musicsense/MFRC522:
MFRC522.cpp    MFRC522.h
bleu:Spark edwintam$ cat musicsense/spark.include 
*.cpp
*.ino
*.h
*.c
**/*.cpp
**/*.ino
**/*.h
**/*.c
bleu:Spark edwintam$

what does spark --version say?

Can you try moving the files to be ignored and spark.ignore just to be sure that it is not causing the issues.

I’m guessing that the Spark-cli might not be handling them both properly.

I can try removing the spark ignored item but I doubt its significance.

bleu:Spark edwintam$ spark --version
0.4.94
bleu:Spark edwintam$ cat musicsense/spark.ignore 
.DS_Store
bleu:Spark edwintam$ 

//Ed

As expected, same result.

bleu:musicsense edwintam$ rm spark.ignore 
bleu:musicsense edwintam$ rm .DS_Store 
bleu:musicsense edwintam$ rm MFRC522/.DS_Store 
bleu:musicsense edwintam$ cd ..
bleu:Spark edwintam$ spark compile musicsense --saveTo firmware.bin
Including:
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.cpp
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/musicsense.ino
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.h
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.cpp
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.cpp
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/musicsense.ino
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.h
    /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.h
attempting to compile firmware 
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.cpp
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/musicsense.ino
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.h
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.cpp
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.cpp
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/musicsense.ino
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/HTTPClient.h
pushing file: /Volumes/Haruka/Users/edwintam/Documents/Development/Spark/musicsense/MFRC522/MFRC522.h
Errors
musicsense.cpp:3:29: fatal error: MFRC522/MFRC522.h: No such file or directory
 void transfer_data_lcd(byte ucData);
                             ^
compilation terminated.
make: *** [musicsense.o] Error 1

Compile failed -  compile failed 
bleu:Spark edwintam$

Opps… just tested…

you will simply need to call the files you need directly without the path in the .ino file

eg.

#include "MFRC522.h"

2 Likes