Go Down

Topic: Preprocessor macro for detecting export compiled binary (Read 135 times) previous topic - next topic

VerusLogic

Is there a macro that can be checked to define something one of two ways depending if uploading the sketch locally (Ctrl+u) vs. exporting the compiled binary (Ctrl+Alt+s)?

Kind of like a DEBUG vs RELEASE mode.  When exporting the compiled binary I would like to point to a different URL in my code than when testing.

I compared the verbose output for both types of builds and did not see any differences.

Thanks,

Mike.

pert

I think the only way you could accomplish this is by modifying platform.txt to somehow do it via the recipe.hooks.savehex.presavehex hook:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#pre-and-post-build-hooks-since-ide-165

VerusLogic

Thanks!  This definitely looks like the right place.  But I'm still wondering how to determine which build method was used Ctrl+U or Ctrl+Alt+S.

Is there a way to add a Sketch menu item to build the project so I can add a build-release with say Ctrl+Shift+U?  that would be nice.

DrAzzy

The savehex hooks are only called when doing export compiled binary. But they're called after compilation is complete, so I don't see how you could make that do what you want?

There is no way to add items to other menus short of modifying the IDE itself and maintaining your own custom version.

I think the much easier way to switch between release and debug version would be to do like

#define RELEASE

at top of sketch for a release, and comment it out when not doing a release, and use that in a #ifdef.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

VerusLogic

Dr. Azzy - I agree.  That is what I am doing now.  Only some times I forget to change that prior to exporting compiled binary.  I just thought if there was a way to hook which menu item was used to start the build then I could make sure RELEASE was defined every time the binary was exported.

Thanks.

Go Up