22
33# This script manages the use of a file with a unique name, like
44# `Sketch.ino.globals.h`, in the Sketch source directory to provide compiler
5- # command-line options (build options) and sketch global defines . The build
5+ # command-line options (build options) and sketch global macros . The build
66# option data is encapsulated in a unique "C" comment block and extracted into
77# the build tree during prebuild.
88#
6060"""
6161Arduino `preferences.txt` changes
6262
63- "Aggressively cache compiled core" must be turned off for a reliable build process.
63+ "Aggressively cache compiled core" ideally should be turned off; however,
64+ a workaround has been implimented.
6465In ~/.arduino15/preferences.txt, to disable the feature:
6566 compiler.cache_core=false
6667
@@ -341,6 +342,7 @@ def discover_1st_time_run(build_path):
341342 # Arduino IDE 2.0 RC5 does not cleanup on exist like 1.6.19. Probably for
342343 # debugging like the irregular version number 10607. For RC5 this indicator
343344 # will be true after a reboot instead of a 1ST compile of the IDE starting.
345+ # Another issue for this technique, Windows does not clear the Temp directory. :(
344346 tmp_path , build = os .path .split (build_path )
345347 ide_2_0 = 'arduino-sketch-'
346348 if ide_2_0 == build [:len (ide_2_0 )]:
@@ -380,10 +382,8 @@ def find_preferences_txt(runtime_ide_path):
380382 # The downloaded Windows 7 (and up version) will put "preferences.txt"
381383 # in a different location. When both are present due to various possible
382384 # scenarios, use the more modern.
383- # Note, I am ignoring any permutations you might get into with storing
384- # and running applications off Network servers.
385385 fqfn = os .path .expanduser ("~\Documents\ArduinoData\preferences.txt" )
386- # Path for "Windows app" - verified on Windows 10 with Arduino IDE 1.8.19
386+ # Path for "Windows app" - verified on Windows 10 with Arduino IDE 1.8.19 from APP store
387387 fqfn2 = os .path .expanduser ("~\AppData\local\Arduino15\preferences.txt" )
388388 # Path for Windows 7 and up - verified on Windows 10 with Arduino IDE 1.8.19
389389 if os .path .exists (fqfn ):
@@ -422,9 +422,10 @@ def get_preferences_txt(file_fqfn, key):
422422
423423
424424def check_preferences_txt (runtime_ide_path ):
425+ # return the state of "compiler.cache_core" in preferences.txt
425426 file_fqfn = find_preferences_txt (runtime_ide_path )
426427 if file_fqfn == "" :
427- return True # cannot find file assume enabled
428+ return True # cannot find file - assume enabled
428429 print_msg ("Using preferences from " + file_fqfn )
429430 return get_preferences_txt (file_fqfn , "compiler.cache_core" )
430431
@@ -435,6 +436,7 @@ def touch(fname, times=None):
435436
436437
437438def synchronous_touch (globals_h_fqfn , commonhfile_fqfn ):
439+ # touch both files with the same timestamp
438440 with open (globals_h_fqfn , 'a' ):
439441 os .utime (globals_h_fqfn )
440442 ts = os .stat (globals_h_fqfn )
@@ -481,9 +483,9 @@ def main():
481483 embedded_options = extract_create_build_opt_file (globals_h_fqfn , globals_name , build_opt_fqfn )
482484
483485 if use_aggressive_caching_workaround :
484- # When a Sketch owns a "Sketch.ino.globals.h" file in the build tree
485- # that exactly matches the timestamp of "CommonHFile.h" in the
486- # platform source tree, it owns the core cache. If not, or
486+ # When the sketch build has a "Sketch.ino.globals.h" file in the
487+ # build tree that exactly matches the timestamp of "CommonHFile.h"
488+ # in the platform source tree, it owns the core cache. If not, or
487489 # "Sketch.ino.globals.h" has changed, rebuild core.
488490 # A non-zero file size for commonhfile_fqfn, means we have seen a
489491 # globals.h file before and workaround is active.
@@ -516,7 +518,7 @@ def main():
516518
517519 else :
518520 print_err ("Too few arguments. Add arguments:" )
519- print_err (" Source FQFN Sketch.ino.globals.h, Build FQFN Sketch.ino.globals.h, Build FQFN build.opt " )
521+ print_err (" Runtime IDE path, Build path, Build FQFN build.opt, Source FQFN Sketch.ino.globals.h, Core Source FQFN CommonHFile.h " )
520522
521523if __name__ == '__main__' :
522524 sys .exit (main ())
0 commit comments