-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Library configuration file management (issue #1734) #1808
Conversation
When an application uses a library supporting configuration: - the library configuration file is stored in the sketch folder as a project ressource. - a sketch tab is created in Arduino IDE to edit the library configuration file This commit manages following actions: - create configuration file tab when opening a sketch which uses a Library configuration file - copy the configuration file in the sketch folder and create a configuration file tab when importing a library which uses a library configuration file - add the library configuration file (from sketch) as include file when compiling the library only Added as an example, Morse library supporting configuration file
Hi, could someone revisit this PR? This functionality is necessary for anyone who wants to provide a library configurable through compiler definitions (e.g. to turn off features for the sake of code size), and this PR seems like a good framework for per-sketch configuration in general. |
Can one of the admins verify this patch? |
+1 |
1 similar comment
+1 |
Sorry for the late reply. Would you please rebase your PR on top of current master and provide the example Morse library as a zip file or separate repo, without including it in the PR? Otherwise we had to remove it right after merge |
On second thought, we probably don't want such a feature at the moment. Having a separate configuration file may be confusing and lead library developers rely too much on
|
Isn't the compiler able to remove the unused methods from the final output? In your Morse library I guess that you can remove the define |
@ffissore Will this be added in 1.6.5? planned release date for 1.6.5? Cheers |
Well, the reasoning about clean API is good - but for example now, the lack of #defines made me to fork the standard Keypad library, since I'm memory constrained, and the Keypad does not use memory effectively at all. #define could allow to limit size of the object to the actually used number of switches (16 instead of 160), reducing memory consumption about ~40 (sorry, correction) bytes. Alternatives are quite bad: using new operator (= malloc library = +200bytes for sketch, fragmentation) or user-supplied buffers (error prone). Or templatized Keypad - very ugly and not understandable code. |
I strongly recommend re-opening this discussion, as I am facing this issue with my Sqlite arduino library, which is only a wrapper to the original sqlite code. As a library developer, I wouldn't want to be the one to decide which sqlite feature should be included or omitted. A I am pasting below my
|
I think it should be possible to create new header file (e.g. MyRunningMedian.h) in your project, containing just your changed definitions:
Then, you need to pass this header file to preprocessor, to include it as a first #include for the RunningMedian. You can do this by using -include directive, see https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html. E.g. in PlatformIO you can do it in platformio.ini this way:
from: https://stackoverflow.com/questions/42151118/how-to-override-define-in-arduino-library-header |
unfortunately this isn't a platformio problem and Arduino IDE has no such build_flags mechanism that can be used from the project folder itself |
sorry, i forgot to mention it was just for reference |
When an application uses a library supporting configuration:
project ressource.
configuration file
This commit manages following actions:
Library configuration file
configuration file tab when importing a library which uses a library
configuration file
compiling the library only
Added as an example, Morse library supporting configuration file