Go Down

Topic: exclude source when compiling (Read 361 times) previous topic - next topic

Seky

Hi,

I have spent this afternoon googling but I just can't find an answer.
My problem is that I am trying to create a library that will work on Arduino boards, esp, and on Linux (maybe even stm and so on in the future).

I have the following folder and files structure:
library/
- examples/ (with Arduino examples)
- all other Arduino files (library.json, license etc)
- src/
- src/arduinoWrapper/ (with Arduino specific code)
- src/linuxWrapper/ (with code that runs on Linux platform)
- src/{ all src files} (with common code which is the the main logic)

When I compile with my own makefile created for Linux everything compiles and it is working.
When I try to compile through Arduino IDE, it tries to compile c++ libraries like spdlog and arrrgh which are ofc not compilable. The files are not included and I just do not know what to do.

I can not modify Arduino include paths, and I can not find an option to exclude those files.
 I could do #ifndef ARDUINO in all files, but I really do not like this approach.
I would also like to avoid having another repo that will contain other wrappers.


spycatcher2k

OK - Now read your post and point out exactly where you asked any questions!

Also
Quote
I could do #ifndef ARDUINO in all files, but I really do not like this approach.
, Why not, it's a perfectly sound and tested method.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

Seky

OK - Now read your post and point out exactly where you asked any questions!

Also , Why not, it's a perfectly sound and tested method.
Hi,
You are right. I did not ask a question, but I think that it is obvious that I am asking for a help from a way that I have described a problem.  :)

I would like to avoid #ifndef ARDUINO because I am using some external libs like arrrgh and spdlog and that would mean I have to fork them and change them in order to supply them with my repo.

spycatcher2k

Unless the include was wrapped in a ifdef!
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

pert


Seky

Where are arrrgh and spdlog?
Library for logging:
https://github.com/gabime/spdlog

Library for argument parsing:
https://github.com/ElectricToy/arrrgh

Unless the include was wrapped in a ifdef!
Includes in main.ino files are wrapped in an ifdef. The issue is in source globbing I would say. It tries to compile all .cpp files even though their headers are not included anywhere

pert

I meant to ask: where in the file system are those libraries?

Seky

#7
Mar 24, 2019, 11:36 am Last Edit: Mar 24, 2019, 11:37 am by Seky
I meant to ask: where in the file system are those libraries?
Ahh.. Sorry. It was too early for me  :(

They are inside my repo as git submodules

If you take a look at my folder structure in the original post they would be inside src/linuxWrapper/lib

pert

Would it be possible for you to install those libraries somewhere outside of the src folder? That would prevent the source files from being automatically compiled and the solution of doing conditional #includes of those libraries would then work fine.

Seky

Would it be possible for you to install those libraries somewhere outside of the src folder? That would prevent the source files from being automatically compiled and the solution of doing conditional #includes of those libraries would then work fine.
It would. I will play around with different paths. Is only src folder included or are files in library folder included?

pert

With the 1.5 Arduino library format (library.properties file in the library root folder, source files under the src subfolder), only the contents of the src folder are compiled.

Seky

With the 1.5 Arduino library format (library.properties file in the library root folder, source files under the src subfolder), only the contents of the src folder are compiled.
Thank You very much for this info. Tested it today and it is working :D

pert

You're welcome. I'm glad to hear it's working now. Enjoy!
Per

Go Up