28
28
import os
29
29
from os .path import join
30
30
import re
31
+ import requests
31
32
import platform as sys_platform
32
33
33
34
import click
@@ -194,12 +195,40 @@ def get_MD5_hash(phrase):
194
195
import hashlib
195
196
return hashlib .md5 ((phrase ).encode ('utf-8' )).hexdigest ()[:16 ]
196
197
198
+ def custom_sdkconfig_file (string ):
199
+ if not config .has_option ("env:" + env ["PIOENV" ], "custom_sdkconfig" ):
200
+ return ""
201
+ sdkconfig_entrys = env .GetProjectOption ("custom_sdkconfig" ).splitlines ()
202
+ for file in sdkconfig_entrys :
203
+ if "http" in file and "://" in file :
204
+ response = requests .get (file .split (" " )[0 ])
205
+ if response .ok :
206
+ target = str (response .content .decode ('utf-8' ))
207
+ else :
208
+ print ("Failed to download:" , file )
209
+ return ""
210
+ return target
211
+ if "file://" in file :
212
+ file_path = join (PROJECT_DIR ,file .lstrip ("file://" ).split (os .path .sep )[- 1 ])
213
+ if os .path .exists (file_path ):
214
+ with open (file_path , 'r' ) as file :
215
+ target = file .read ()
216
+ else :
217
+ print ("File not found:" , file_path )
218
+ return ""
219
+ return target
220
+ return ""
221
+
222
+
197
223
custom_sdk_config_flags = ""
198
224
board_idf_config_flags = ""
225
+ sdkconfig_file_flags = ""
226
+ custom_sdkconfig_file_str = ""
199
227
200
228
if config .has_option ("env:" + env ["PIOENV" ], "custom_sdkconfig" ):
201
229
flag_custom_sdkonfig = True
202
230
custom_sdk_config_flags = (env .GetProjectOption ("custom_sdkconfig" ).rstrip ("\n " )) + "\n "
231
+ custom_sdkconfig_file_str = custom_sdkconfig_file (sdkconfig_file_flags )
203
232
204
233
if "espidf.custom_sdkconfig" in board :
205
234
board_idf_config_flags = ('\n ' .join ([element for element in board .get ("espidf.custom_sdkconfig" , "" )])).rstrip ("\n " ) + "\n "
@@ -208,6 +237,9 @@ def get_MD5_hash(phrase):
208
237
if flag_custom_sdkonfig == True : # TDOO duplicated
209
238
print ("*** Add \" custom_sdkconfig\" settings to IDF sdkconfig.defaults ***" )
210
239
idf_config_flags = custom_sdk_config_flags
240
+ if custom_sdkconfig_file_str != "" :
241
+ sdkconfig_file_flags = custom_sdkconfig_file_str + "\n "
242
+ idf_config_flags = idf_config_flags + sdkconfig_file_flags
211
243
idf_config_flags = idf_config_flags + board_idf_config_flags
212
244
if flash_frequency != "80m" :
213
245
idf_config_flags = idf_config_flags + "# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set\n "
@@ -224,7 +256,7 @@ def get_MD5_hash(phrase):
224
256
225
257
idf_config_flags = idf_config_flags .splitlines ()
226
258
sdkconfig_src = join (ARDUINO_FRMWRK_LIB_DIR ,mcu ,"sdkconfig" )
227
-
259
+
228
260
def get_flag (line ):
229
261
if line .startswith ("#" ) and "is not set" in line :
230
262
return line .split (" " )[1 ]
0 commit comments