Skip to content
New issue

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

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

Already on GitHub? # to your account

Generate global macros according to contents of specially named header file in sketch #5084

Closed
xcvista opened this issue Jun 29, 2016 · 4 comments
Labels
arduino-builder The tool used to handle the Arduino sketch compilation process arduino-cli Related to the arduino-cli tool Component: Compilation Related to compilation of Arduino sketches feature request A request to make an enhancement (not a bug fix) Type: Duplicate Another item already exists for this topic

Comments

@xcvista
Copy link

xcvista commented Jun 29, 2016

I am here suggesting a possible way of allowing configuring the libraries in a reliable way.

Currently when a library requires configuration, it takes those information either as arguments in the initializer, or build it into the code as #defines. The first type is already customizable, but what about the latter, as used in, say, some variant of Ethernet library that can drive W5100, W5200 and W5500?

I am suggesting the use of an optional config.h file. Only #defines are allowed in this file, and those lines are turned into -D flags that is present when compiling the entire sketch. This will allow some libraries to be configured at compile time.

@per1234
Copy link
Collaborator

per1234 commented Jun 29, 2016

See arduino/arduino-builder#15 and #3757. I agree that something like this would be very useful but it has been requested multiple times in various forms(see also arduino/arduino-builder#29, #3717) and it seems this is not considered a desirable feature by the Arduino team(see arduino/arduino-builder#15 (comment)). I do understand the idea of forcing library authors to create a more user friendly API but sometimes you just need the preprocessor and I don't consider forcing the user to edit the library every time they want to change the configuration to be very user friendly.

I found it interested that .org did merge arduino/arduino-builder#29.

@xcvista
Copy link
Author

xcvista commented Jun 29, 2016

@per1234 This is a bit disappointing to me somehow. Any good IDE should allow the users some way to manage this really.

I have a hobby project to rewrite the IDE from ground up (but optimize away a few problems like keywords.txt and a sketch preprocessing using a proper project file project.ocxjson) and in the project file I have an array called /cpp/defines that get converted into -D's.

@ameliaamelia
Copy link

ameliaamelia commented Jul 9, 2016

All of us know that in a library module we can insert i.e. the following include:
#include "X:\Project\Config.h"
that works but at this point the library module is no more a library module.
But if there was a Common Macro like $(TargetDir) or TARGETDIR to write:
#include "X:\$(TargetDir)\Config.h" or #include "X:\TARGETDIR \Config.h"
everything would be fine, no side effects; at worst if the Config.h is not present in the project directory, we would have an error message.

I recently downloaded a library very well done with a huge amount of features.
I customized a config.h for each project manually (silly) insert in the library directory.
I got a reduction of 2k-4k depending on the unused functions.
By working with the micro every byte saved is a good thing.

amelia

@facchinm
Copy link
Member

Closing this as the discussion about the metadata (or configuration) file is going to take place in arduino-cli repo and in the mailing list

@per1234 per1234 added Component: Compilation Related to compilation of Arduino sketches Type: Duplicate Another item already exists for this topic arduino-cli Related to the arduino-cli tool arduino-builder The tool used to handle the Arduino sketch compilation process labels Jul 17, 2023
@per1234 per1234 changed the title config.h Generate global macros according to contents of specially named header file in sketch Jul 17, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
arduino-builder The tool used to handle the Arduino sketch compilation process arduino-cli Related to the arduino-cli tool Component: Compilation Related to compilation of Arduino sketches feature request A request to make an enhancement (not a bug fix) Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

No branches or pull requests

4 participants