@@ -930,46 +930,44 @@ def compile(*args): # NOQA
930
930
931
931
ret_code , output = spawn (cmd_ , env = env , cmpl = True )
932
932
if ret_code != 0 :
933
- if (
934
- 'partition is too small ' not in output or
935
- skip_partition_resize
936
- ):
933
+ if skip_partition_resize :
937
934
sys .exit (ret_code )
938
935
939
936
if partition_size != - 1 :
940
937
sys .exit (ret_code )
941
938
942
- sys .stdout .write ('\n \033 [31;1m***** Resizing Partition *****\033 [0m\n ' )
943
- sys .stdout .flush ()
939
+ if not skip_partition_resize and partition_size == - 1 :
940
+ if 'partition is too small ' in output :
941
+ sys .stdout .write ('\n \033 [31;1m***** Resizing Partition *****\033 [0m\n ' )
942
+ sys .stdout .flush ()
944
943
945
- end = output .split ('(overflow ' , 1 )[- 1 ]
946
- overflow_amount = int (end .split (')' , 1 )[0 ], 16 )
944
+ end = output .split ('(overflow ' , 1 )[- 1 ]
945
+ overflow_amount = int (end .split (')' , 1 )[0 ], 16 )
947
946
948
- partition .set_app_size (overflow_amount )
949
- partition .save ()
947
+ partition .set_app_size (overflow_amount )
948
+ partition .save ()
950
949
951
- sys .stdout .write (
952
- '\n \033 [31;1m***** Running build again *****\033 [0m\n \n '
953
- )
954
- sys .stdout .flush ()
950
+ sys .stdout .write (
951
+ '\n \033 [31;1m***** Running build again *****\033 [0m\n \n '
952
+ )
953
+ sys .stdout .flush ()
955
954
956
- cmd_ [4 ] = 'SECOND_BUILD=1'
957
- ret_code , output = spawn (cmd_ , env = env , cmpl = True )
955
+ cmd_ [4 ] = 'SECOND_BUILD=1'
956
+ ret_code , output = spawn (cmd_ , env = env , cmpl = True )
958
957
959
- if ret_code != 0 :
960
- sys .exit (ret_code )
958
+ if ret_code != 0 :
959
+ sys .exit (ret_code )
961
960
962
- if not skip_partition_resize :
963
- if partition_size == - 1 and 'build complete' in output :
964
- app_size = output .rsplit ('micropython.bin binary size ' )[- 1 ]
961
+ elif 'Project build complete.' in output :
962
+ app_size = output .rsplit ('micropython.bin binary size ' , 1 )[1 ]
965
963
app_size = int (
966
- app_size .split (' bytes' )[0 ].strip (),
964
+ app_size .split (' bytes' , 1 )[0 ].strip (),
967
965
16
968
966
)
969
967
970
968
remaining = app_size - partition .get_app_size ()
971
969
972
- if remaining > 0x1000 :
970
+ if abs ( remaining ) > 0x1000 :
973
971
sys .stdout .write (
974
972
'\n \033 [31;1m***** Resizing Partition *****\033 [0m\n '
975
973
)
@@ -983,14 +981,14 @@ def compile(*args): # NOQA
983
981
)
984
982
sys .stdout .flush ()
985
983
986
- compile_cmd [4 ] = 'SECOND_BUILD=1'
984
+ cmd_ [4 ] = 'SECOND_BUILD=1'
987
985
988
- ret_code , output = spawn (cmds , env = env , cmpl = True )
986
+ ret_code , output = spawn (cmd_ , env = env , cmpl = True )
989
987
990
988
if ret_code != 0 :
991
989
sys .exit (ret_code )
992
990
993
- if 'To flash, run: ' in output :
991
+ if 'Project build complete. ' in output :
994
992
output = output .rsplit ('To flash, run:' )[- 1 ].strip ()
995
993
996
994
espressif_path = os .path .expanduser ('~/.espressif' )
0 commit comments