Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sketch directory to include directories #313

Open
mihaizh opened this issue Mar 7, 2019 · 0 comments
Open

Add sketch directory to include directories #313

mihaizh opened this issue Mar 7, 2019 · 0 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@mihaizh
Copy link

mihaizh commented Mar 7, 2019

So, as title says, it would be nice to add the original directory of the sketch file (before is copied to the temporary folder) to the include directories.

The motivation behind this is as follows. Usually, if you want to share code between sketches, you should make a library and then use it in both sketches. One of the problems is that, one should import the library manually if it wants to be able to compile the project.
But what if I want to share the code with another C++ project too, one which is not an Arduino project?

I have the following directory structure:

src
-- common
---- common.h
---- arduino.h
-- other_non_arduino_project
---- CMakeLists.txt
---- main.cpp
-- sketch1
---- sketch1.ino
-- sketch2
---- sketch2.ino

Here, sketch1 and sketch2 share the arduino.h file. Then, both sketches share also the common.h file with the other_non_arduino_project. To be able to do it, the original sketch directory should be added to the include directories such that, in the Arduino sketches I can use the following lines of code to include the common files.
#include "../common/arduino.h"
#include "../common/common.h"

Having this means that the builder does not need to copy the .h files anymore to the temporary directory.
I don't know if this is somehow a breaking change or how it would affect the entire building system of Arduino. I have already patched the arduino-builder locally, and it works just fine. Here you can find the commit on my fork: mihaizh@55f9599

What do you say? Is it worth it? Or is there a way, which I don't know yet about, to do it already?

@per1234 per1234 added topic: code Related to content of the project itself type: enhancement Proposed improvement labels Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants