Add support for global build defines and options#8504
Merged
d-a-v merged 30 commits intoesp8266:masterfrom May 12, 2022
Merged
Conversation
A script manages the use of a file with a unique name, like `SketchName.ino.globals.h`, in the Sketch source directory to provide compiler command-line options (build options) and sketch global defines. The build option data is encapsulated in a unique "C" comment block and extracted into the build tree during prebuild.
…s file path issue. Improved helpful message for adding embedded build options.
added workaround for aggressive caching
Added portable path for preferences.txt Expanded file timestamp granularity Improved error message printing for Arduino IDE 2.0 RC4
When global header file does not exist, this print makes it easier for user to create the header file by providing its name and documentation pointer.
Compiler command line changes from build.opt are shown to user
Grouped helpful info to print at the end. Added missing return value.
More improvements to printing Updated docs.
Support hints for compiler.cache_core. For use when Arduino IDE uses command-line options that override compiler.cache_core. Removed overuse of () Improve FAQ entry
Rely on argpaser for checking that all arguments are present. Removed redundant argument check in main(). Added '--debug' option and print_dbg method. Rethink failures on overrides. Remove well know path fallbacks, error exit when override file is missing. In well-known path search for preferences.txt, do not assume true. Make failure to find an error exit event. When Windows has two preferences.txt files and they have different values for caching and globals.h is used, error exit. It is not possible to know from the script which is being used.
d965206 to
b75904e
Compare
d-a-v
approved these changes
Mar 27, 2022
Collaborator
d-a-v
left a comment
There was a problem hiding this comment.
Thanks a lot for this proposal.
It is an excellent replacement to a feature-request which is still not available upstream.
6 tasks
Update comment Include the @ within the expantion string use quotes around file name. Update doc example to remind and use quotes.
Added "mkbuildoptglobals.extra_flags=--cache_core" to platform.loca.txt Update "-ide-version=10802" this version number indicates aggressive caching support Added example to test global .h support
Added --debug to CI - this needs to be removed later Tweaks to touch...
temp CI changes debug crud Added --ci switch
run_CI_locall.sh works fine locally. Hosted Multi-VM CI fails to work with 'aggressive caching' workaround method. Add #if defined(CORE_MOCK) to failing example.
mkbuildoptglobals.py is optimized around the Arduino IDE 1.x behaviour. One way the CI differs from the Arduino IDE is in the handling of core and caching core. With the Arduino IDE, each sketch has a private copy of core and contributes to a core cache. With the CI, there is one shared copy of core for all sketches. When global options are used, the shared copy of core and cache are removed before and after the build.
|
Is similar feature available in ESP32 boards? If not, is it planned to be ported? |
Collaborator
|
Please ask them directly (arduino/esp32). Best is to ask Arduino themselves. There are lots en entry-points about this subject. ... Well, I will add this one because they still have not closed it yet despite the fact that they should have after months of inactivity. PS: @mhightower83 Thanks for this addition |
hasenradball
pushed a commit
to hasenradball/Arduino
that referenced
this pull request
Nov 18, 2024
* Add support to specify global build defines and options A script manages the use of a file with a unique name, like `SketchName.ino.globals.h`, in the Sketch source directory to provide compiler command-line options (build options) and sketch global defines. The build option data is encapsulated in a unique "C" comment block and extracted into the build tree during prebuild. * Applied os.path.normpath() liberally to input arguments. Fixes windows file path issue. Improved helpful message for adding embedded build options. * doubleup '\' * Added context help for build option support * expunged sketchbook global added workaround for aggressive caching * inital pass at searching for and reading preferences.txt * Correct Windows path for preferences.txt Added portable path for preferences.txt Expanded file timestamp granularity Improved error message printing for Arduino IDE 2.0 RC4 * Improved portable path and various Windows paths to preferences.txt * Add cleanup logic and identify 1st run after IDE restart * text corrections * Create mkbuildoptglobals.py When global header file does not exist, this print makes it easier for user to create the header file by providing its name and documentation pointer. * build.opt heads up to user Compiler command line changes from build.opt are shown to user * Updated text * oops * Expanded comment and made print help consistent * Improve handling stderr/stdout with "no verbose output" Grouped helpful info to print at the end. Added missing return value. * Correct timestamp on CommonHFile.h More improvements to printing Updated docs. * Added command-line parser Support hints for compiler.cache_core. For use when Arduino IDE uses command-line options that override compiler.cache_core. Removed overuse of () Improve FAQ entry * Fix script failure under windows Rely on argpaser for checking that all arguments are present. Removed redundant argument check in main(). Added '--debug' option and print_dbg method. Rethink failures on overrides. Remove well know path fallbacks, error exit when override file is missing. In well-known path search for preferences.txt, do not assume true. Make failure to find an error exit event. When Windows has two preferences.txt files and they have different values for caching and globals.h is used, error exit. It is not possible to know from the script which is being used. * Use quotes on build.opt Update comment Include the @ within the expantion string use quotes around file name. Update doc example to remind and use quotes. * Update CI for build option and global support Added "mkbuildoptglobals.extra_flags=--cache_core" to platform.loca.txt Update "-ide-version=10802" this version number indicates aggressive caching support Added example to test global .h support * Add debug prints Added --debug to CI - this needs to be removed later Tweaks to touch... * Give each build VM a unique build.tmp space * Corrected style on example temp CI changes debug crud Added --ci switch * Removed CI debug crud run_CI_locall.sh works fine locally. Hosted Multi-VM CI fails to work with 'aggressive caching' workaround method. Add #if defined(CORE_MOCK) to failing example. * Try HOST_MOCK * CI adjustments mkbuildoptglobals.py is optimized around the Arduino IDE 1.x behaviour. One way the CI differs from the Arduino IDE is in the handling of core and caching core. With the Arduino IDE, each sketch has a private copy of core and contributes to a core cache. With the CI, there is one shared copy of core for all sketches. When global options are used, the shared copy of core and cache are removed before and after the build. * Doc update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A script that manages the use of a file with a unique name, like
Sketch.ino.globals.h, in the sketch source directory, to provide compiler command-line options (build options) and sketch global#definemacros. The build option data is encapsulated in a unique "C" comment block and extracted into the build tree during prebuild.