@@ -22,9 +22,93 @@ def _create_dirs(dirs=["firmware", "map"]):
22
22
if not os .path .isdir ("{}{}" .format (OUTPUT_DIR , d )):
23
23
os .mkdir ("{}{}" .format (OUTPUT_DIR , d ))
24
24
25
+
26
+ # trick for py2/3 compatibility
27
+ if 'basestring' not in globals ():
28
+ basestring = str
29
+
30
+ # WLEDMM : custom print function
31
+ def print_my_item (items , flag = False ):
32
+ if flag : print (" -D" , end = '' )
33
+ else : print (" " , end = '' )
34
+ if isinstance (items , basestring ):
35
+ # print a single string
36
+ print (items , end = '' )
37
+ else :
38
+ # print a list
39
+ first = True
40
+ for item in items :
41
+ if not first : print ("=" , end = '' )
42
+ print (item , end = '' )
43
+ first = False
44
+
45
+ # WLEDMM : dump out buildflags : usermods, disable, enable, use_..
46
+ def wledmm_print_build_info (env ):
47
+ all_flags = env ["CPPDEFINES" ]
48
+ first = True
49
+
50
+ found = False
51
+ for item in all_flags :
52
+ if 'WLED_RELEASE_NAME' in item [0 ] or 'WLED_VERSION' in item [0 ] or 'ARDUINO_USB_CDC_ON_BOOT' in item [0 ]:
53
+ if first : print ("\n Usermods and Features:" )
54
+ print_my_item (item )
55
+ first = False
56
+ found = True
57
+ if found : print ("" )
58
+
59
+ found = False
60
+ for item in all_flags :
61
+ if 'USERMOD_' in item or 'UM_' in item :
62
+ if first : print ("\n Usermods and Features:" )
63
+ print_my_item (item )
64
+ first = False
65
+ found = True
66
+ if found : print ("" )
67
+
68
+ found = False
69
+ for item in all_flags :
70
+ if 'WLED_DISABLE' in item or 'WIFI_FIX' in item :
71
+ if first : print ("\n Usermods and Features:" )
72
+ print_my_item (item )
73
+ first = False
74
+ found = True
75
+ if found : print ("" )
76
+
77
+ found = False
78
+ for item in all_flags :
79
+ if 'WLED_' in item or 'WLED_' in item [0 ] or 'MAX_LED' in item [0 ]:
80
+ if not 'WLED_RELEASE_NAME' in item [0 ] and not 'WLED_VERSION' in item [0 ] and not 'WLED_WATCHDOG_TIMEOUT' in item [0 ] and not 'WLED_DISABLE' in item and not 'WLED_USE_MY_CONFIG' in item and not 'ARDUINO_PARTITION' in item :
81
+ if first : print ("\n Usermods and Features:" )
82
+ print_my_item (item )
83
+ first = False
84
+ found = True
85
+ if found : print ("" )
86
+
87
+ first = True
88
+ found = False
89
+ for item in all_flags :
90
+ if 'WLEDMM_' in item [0 ] or 'WLEDMM_' in item or 'TROYHACKS' in item :
91
+ if first : print ("\n WLEDMM Features:" )
92
+ print_my_item (item )
93
+ first = False
94
+ found = True
95
+ if found : print ("\n " )
96
+
97
+ def wledmm_print_all_defines (env ):
98
+ all_flags = env ["CPPDEFINES" ]
99
+ found = False
100
+ for item in all_flags :
101
+ if not found : print ("\n Build Flags:" )
102
+ print_my_item (item , True )
103
+ found = True
104
+ if found : print ("\n " )
105
+
106
+
25
107
def bin_rename_copy (source , target , env ):
26
108
_create_dirs ()
27
109
variant = env ["PIOENV" ]
110
+ builddir = os .path .join (env ["PROJECT_BUILD_DIR" ], variant )
111
+ source_map = os .path .join (builddir , env ["PROGNAME" ] + ".map" )
28
112
29
113
# create string with location and file names based on variant
30
114
map_file = "{}map{}{}.map" .format (OUTPUT_DIR , os .path .sep , variant )
@@ -48,7 +132,14 @@ def bin_rename_copy(source, target, env):
48
132
49
133
# copy firmware.map to map/<variant>.map
50
134
if os .path .isfile ("firmware.map" ):
51
- shutil .move ("firmware.map" , map_file )
135
+ print ("Found linker mapfile firmware.map" )
136
+ shutil .copy ("firmware.map" , map_file )
137
+ if os .path .isfile (source_map ):
138
+ print (f"Found linker mapfile { source_map } " )
139
+ shutil .copy (source_map , map_file )
140
+
141
+ # wledmm_print_all_defines(env)
142
+ # wledmm_print_build_info(env)
52
143
53
144
def bin_gzip (source , target , env ):
54
145
_create_dirs ()
0 commit comments