Skip to content

Commit db5a27b

Browse files
committed
Tidy up esp-idf build script
1 parent 408decf commit db5a27b

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

builder/frameworks/espidf.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,21 @@ def get_original_version(version):
6666
platform.get_package_version("toolchain-xtensa32"))
6767

6868

69+
def is_set(parameter, configuration):
70+
if int(configuration.get(parameter, 0)):
71+
return True
72+
return False
73+
74+
6975
def is_ulp_enabled(sdk_params):
7076
ulp_memory = int(sdk_params.get("CONFIG_ULP_COPROC_RESERVE_MEM", 0))
71-
ulp_enabled = int(sdk_params.get("CONFIG_ULP_COPROC_ENABLED", 0))
72-
return ulp_memory > 0 and ulp_enabled != 0
77+
ulp_enabled = is_set("CONFIG_ULP_COPROC_ENABLED", sdk_params)
78+
return ulp_memory > 0 and ulp_enabled
7379

7480

7581
def is_arduino_enabled(sdk_params):
76-
arduino_enabled = int(sdk_params.get("CONFIG_ENABLE_ARDUINO_DEPENDS", 0))
77-
return arduino_enabled > 0
82+
arduino_enabled = is_set("CONFIG_ENABLE_ARDUINO_DEPENDS", sdk_params)
83+
return arduino_enabled
7884

7985

8086
def parse_mk(path):
@@ -174,12 +180,6 @@ def get_sdk_configuration(config_path):
174180
return config
175181

176182

177-
def is_set(parameter, configuration):
178-
if int(configuration.get(parameter, 0)):
179-
return True
180-
return False
181-
182-
183183
def find_valid_config_file():
184184
search_path = join(
185185
platform.get_dir(), "examples", "*", "src", "sdkconfig.h")
@@ -208,7 +208,7 @@ def build_lwip_lib(sdk_params):
208208
]
209209

210210
# PPP support can be enabled in sdkconfig.h
211-
if int(sdk_params.get("CONFIG_PPP_SUPPORT", 0)):
211+
if is_set("CONFIG_PPP_SUPPORT", sdk_params):
212212
src_dirs.extend(
213213
["lwip/src/netif/ppp", "lwip/src/netif/ppp/polarssl"])
214214

@@ -302,9 +302,9 @@ def build_wpa_supplicant_lib():
302302
join(FRAMEWORK_DIR, "components", "wpa_supplicant"), config)
303303

304304

305-
def build_heap_lib(params):
305+
def build_heap_lib(sdk_params):
306306
src_filter = "+<*> -<test*>"
307-
if int(sdk_params.get("CONFIG_HEAP_POISONING_DISABLED", 0)) != 0:
307+
if is_set("CONFIG_HEAP_POISONING_DISABLED", sdk_params):
308308
src_filter += " -<multi_heap_poisoning.c>"
309309

310310
return build_component(
@@ -427,15 +427,13 @@ def configure_exceptions(sdk_params):
427427
# directly in sdkconfig.h
428428
cppdefines = env.Flatten(env.get("CPPDEFINES", []))
429429
pio_exceptions = "PIO_FRAMEWORK_ESP_IDF_ENABLE_EXCEPTIONS" in cppdefines
430-
config_exceptions = int(sdk_params.get("CONFIG_CXX_EXCEPTIONS", 0)) != 0
430+
config_exceptions = is_set("CONFIG_CXX_EXCEPTIONS", sdk_params)
431431

432432
if pio_exceptions or config_exceptions:
433433
# remove unnecessary flag defined in main.py that disables exceptions
434434
try:
435-
index = env['CXXFLAGS'].index("-fno-exceptions")
436-
if index > 0:
437-
env['CXXFLAGS'].remove("-fno-exceptions")
438-
except IndexError:
435+
env['CXXFLAGS'].remove("-fno-exceptions")
436+
except ValueError:
439437
pass
440438

441439
env.Append(CXXFLAGS=["-fexceptions"])

0 commit comments

Comments
 (0)