-
Notifications
You must be signed in to change notification settings - Fork 448
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 support for custom defines #571
base: master
Are you sure you want to change the base?
Conversation
You should be able to pass custom defines as part of the compiler flags since they are appended in the Makefile rather than set - I've done it this way before. For .cpp and .c source you can use |
Thanks for your feedback. Somehow using Using CPPFLAGS
Using CXXFLAGS
|
Yes I'm not sure why but setting CPPFLAGS external to the Arduino.mk seems to drop all the include flags, despite it being appended here: https://github.com/sudar/Arduino-Makefile/blob/master/Arduino.mk#L1062 Not got time to look into it now but maybe you can spot something. I thought it might be this line doing the expand prior to the includes but commenting it out still presents the same problem. |
Just found out that using CXXFLAGS does influence the build. The following arguments are missing when using CXXFLAGS from my Makefile:
I think the variables that are passed as arguments are not overwritten or appended from the Arduino.mk. I think this thread is explaining a possible solution. I'm going to give it a try... |
Jup, that seems to make it work. Updated the PR to reflect this :) Thanks for your help in figuring it out and make the solution much cleaner. |
Just checking up if you are going to merge this into master? |
I can't merge as I'm a contributor not collaborator. If you want more chance of getting it merge though, it would be worth updating the arduino-vars.md and changelog as described in CONTRIBUTING.MD. There might be something to be said for sticking to the original sole addition of a variable, in case people are using the passing of CPPFLAGS in the command args to override the default intentionally. |
Thanks for the PR. Please do add some documentation in the |
I patched the current master's HEAD, fe84c59, examples/Blink/Blink.ino with the following patch: I then ran the following in the examples/Blink directory:
So, using CPPFLAGS works for me.
And using CXXFLAGS also work for me.
And finally, as expected, not setting either CPPFLAGS or CXXFLAGS doesn't work. Maybe I'm missing something here. If not, I think CPPFLAGS or CXXFLAGS could be used as I demonstrated above and there is really no need for CUSTOM_DEFINES. I think that the override directive was not used correctly in this patch, as:
The way I understand it, we're always extending (prepending to, using :=, or appending to, using +=) CXXFLAGS/CPPFLAGS. We never override them (using =). Or do we want to override them? If so, overriding should from my point of view be in a separate patch, as it has nothing to do with the pure appending of CUSTOM_DEFINES to CPPFLAGS. If we want it and if I'm not completely missing the point, adding CUSTOM_DEFINES should be as simple as adding the following to Arduino.mk, before the first usage of $(CPPFLAGS):
|
Could you consider adding support for custom defines, so that something like the example below would work? Or am I overlooking an available approach to make this work?