2
2
3
3
# This script manages the use of a file with a unique name, like
4
4
# `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
6
6
# option data is encapsulated in a unique "C" comment block and extracted into
7
7
# the build tree during prebuild.
8
8
#
60
60
"""
61
61
Arduino `preferences.txt` changes
62
62
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.
64
65
In ~/.arduino15/preferences.txt, to disable the feature:
65
66
compiler.cache_core=false
66
67
@@ -341,6 +342,7 @@ def discover_1st_time_run(build_path):
341
342
# Arduino IDE 2.0 RC5 does not cleanup on exist like 1.6.19. Probably for
342
343
# debugging like the irregular version number 10607. For RC5 this indicator
343
344
# 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. :(
344
346
tmp_path , build = os .path .split (build_path )
345
347
ide_2_0 = 'arduino-sketch-'
346
348
if ide_2_0 == build [:len (ide_2_0 )]:
@@ -380,10 +382,8 @@ def find_preferences_txt(runtime_ide_path):
380
382
# The downloaded Windows 7 (and up version) will put "preferences.txt"
381
383
# in a different location. When both are present due to various possible
382
384
# 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.
385
385
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
387
387
fqfn2 = os .path .expanduser ("~\AppData\local\Arduino15\preferences.txt" )
388
388
# Path for Windows 7 and up - verified on Windows 10 with Arduino IDE 1.8.19
389
389
if os .path .exists (fqfn ):
@@ -422,9 +422,10 @@ def get_preferences_txt(file_fqfn, key):
422
422
423
423
424
424
def check_preferences_txt (runtime_ide_path ):
425
+ # return the state of "compiler.cache_core" in preferences.txt
425
426
file_fqfn = find_preferences_txt (runtime_ide_path )
426
427
if file_fqfn == "" :
427
- return True # cannot find file assume enabled
428
+ return True # cannot find file - assume enabled
428
429
print_msg ("Using preferences from " + file_fqfn )
429
430
return get_preferences_txt (file_fqfn , "compiler.cache_core" )
430
431
@@ -435,6 +436,7 @@ def touch(fname, times=None):
435
436
436
437
437
438
def synchronous_touch (globals_h_fqfn , commonhfile_fqfn ):
439
+ # touch both files with the same timestamp
438
440
with open (globals_h_fqfn , 'a' ):
439
441
os .utime (globals_h_fqfn )
440
442
ts = os .stat (globals_h_fqfn )
@@ -481,9 +483,9 @@ def main():
481
483
embedded_options = extract_create_build_opt_file (globals_h_fqfn , globals_name , build_opt_fqfn )
482
484
483
485
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
487
489
# "Sketch.ino.globals.h" has changed, rebuild core.
488
490
# A non-zero file size for commonhfile_fqfn, means we have seen a
489
491
# globals.h file before and workaround is active.
@@ -516,7 +518,7 @@ def main():
516
518
517
519
else :
518
520
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 " )
520
522
521
523
if __name__ == '__main__' :
522
524
sys .exit (main ())
0 commit comments