Skip to content

Commit

Permalink
Update espidf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Oct 23, 2024
1 parent 19d69d2 commit e1a7bcc
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ def get_flag(line):
else:
return

def HandleArduinoCOMPONENTsettings(env):
if flag_custom_component == True:
import yaml
from yaml import SafeLoader
print("*** \"custom_component\" is used to specify managed idf components ***")
idf_component_yml_src = os.path.join(ARDUINO_FRAMEWORK_DIR, "idf_component.yml")
if not bool(os.path.isfile(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"))):
shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"))
yaml_file=open(idf_component_yml_src,"r")
idf_component=yaml.load(yaml_file, Loader=SafeLoader)
idf_component_json_string=json.dumps(idf_component)
idf_component_json_file=open(os.path.join(ARDUINO_FRAMEWORK_DIR, "idf_component.json"),"w")
json.dump(idf_component,idf_component_json_file)
idf_component_json_file.close()
print("JSON from idf_component.yml:")
print(idf_component_json_string)
return
return

if flag_custom_component:
HandleArduinoCOMPONENTsettings(env)

if flag_custom_sdkonfig:
HandleArduinoIDFsettings(env)
LIB_SOURCE = os.path.join(env.subst("$PROJECT_CORE_DIR"), "platforms", "espressif32", "builder", "build_lib")
Expand Down Expand Up @@ -1323,7 +1345,6 @@ def _get_installed_pip_packages(python_exe_path):
return

deps = {
"PyYAML": ">=6.0.2",
"wheel": ">=0.35.1",
# https://github.com/platformio/platformio-core/issues/4614
"urllib3": "<2",
Expand Down Expand Up @@ -1458,28 +1479,6 @@ def get_python_exe():

create_version_file()

def HandleArduinoCOMPONENTsettings(env):
if flag_custom_component == True:
import yaml
from yaml import SafeLoader
print("*** \"custom_component\" is used to specify managed idf components ***")
idf_component_yml_src = os.path.join(ARDUINO_FRAMEWORK_DIR, "idf_component.yml")
if not bool(os.path.isfile(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"))):
shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"))
yaml_file=open(idf_component_yml_src,"r")
idf_component=yaml.load(yaml_file, Loader=SafeLoader)
idf_component_json_string=json.dumps(idf_component)
idf_component_json_file=open(os.path.join(ARDUINO_FRAMEWORK_DIR, "idf_component.json"),"w")
json.dump(idf_component,idf_component_json_file)
idf_component_json_file.close()
print("The JSON from idf_component.yml:")
print(idf_component_json_string)
return
return

if flag_custom_component:
HandleArduinoCOMPONENTsettings(env)

# Generate a default component with dummy C/C++/ASM source files in the framework
# folder. This component is used to force the IDF build system generate build
# information for generic C/C++/ASM sources regardless of whether such files are used in project
Expand Down Expand Up @@ -1902,6 +1901,9 @@ def idf_lib_copy(source, target, env):
"*** Starting Arduino compile %s with custom libraries ***" % pio_cmd,
)
)
if flag_custom_component == True:
shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml"))
print("*** Original Arduino \"idf_component.yml\" restored ***")
env.AddPostAction("checkprogsize", idf_lib_copy)

#
Expand Down

0 comments on commit e1a7bcc

Please sign in to comment.