-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Surface compiler flags for a given platform #1090
Comments
This seems challenging to implement. One problem is that arduino-cli doesn't really know about compiler flags. It knows about all kinds of variables which it collects from various places (platform.txt, boards.txt, compiler commandline, maybe even some builtin defaults or backward compatibility fixups). Then, to run the compiler, it takes a "recipe" from platform.txt and instantiates it with all collected variables. This produces the complete commandline, not just the defines, or just compiler flags, etc. There are likely some of these variables that might be relevant (i.e. a variable that contains all compiler flags or all defines), but (names of) these variables are not standardized, only the recipe that generates the full commandline. So, that means that at best arduino-cli could give you all the relevant variables for a given board, or the complete compiler commandline for a given board and source file. If you know how the Regarding the specific example you give, |
OH! That line from the recipe is a perfect illustration of what I'm after!
Just being able to get ahold of the contents of I assume surfacing this info is as easy as copying the process for examples compilation -- then instead of plugging the data into the recipe and running the compiler, just print out any & all variables that a typical recipe would access. Is that more reasonable? |
Yup, that's probably easy to implement. Not sure what the (CLI or GRPC) interface for this would look like exactly, though (and I'm not familiar enough with the code to really suggest anything or be really sure that this is indeed easy :-p). There is some work on creating a compilation database as a side effect of compilation (see #1081), which might be an ideal interface for what you need. From that PR, it seems @cmaglie even added an option to generate just a compilation database without actually running the compilation commands (except for the preprocessor for library detection)? OTOH you might need a little more high-level view of the various flags, extracting them from a compilation database might require a bit of reverse engineering maybe? |
Linking Arduino-CI/arduino_ci#242 for visibility. I'm hopeful that this sort of feature would support a more robust approach to defining board constants during mock compilation |
Hi @ianfixes, unfortunately this cannot be done since it's compiler dependent. |
I'm not sure I understand this resolution. At some point you know what the compiler flags are, because you have to pass them to the actual compiler. You "cannot" print them to STDOUT instead (hard-coding "gcc" as the compiler if necessary)? |
Many definitions are builtin in the compiler itself, for example, the
Another problems is that a compiler for a specific platform may have a set of flags that is different from a compiler of another, the first example that comes to mind is the The only "official" definitions flags made by Arduino are:
I don't know if those are useful for your purposes, they seem too generic. |
If I'm understanding this correctly, in your example Overall though, it sounds like I might be stuck with the YAML definitions... and that might be the most straightforward method of resolving this. |
Yes, correct. |
Feature Request
arduino_ci
has logic for building Arduino libraries with mocked hardware.Part of this is setting the proper compiler
#define
values for a given board, which I currently hard code in a yaml file.__AVR_ATmega328P__
becomes the compiler flag-D__AVR_ATmega328P__
, and so on.I'd like a way to ask
arduino-cli
for these instead, if possible.The text was updated successfully, but these errors were encountered: