Skip to content

Commit

Permalink
more failsafe IDF version get
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Jul 7, 2024
1 parent 19a2a1e commit 3b7f78a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,12 +999,24 @@ def find_default_component(target_configs):
env.Exit(1)


def get_version_cmake_file():
version_cmake = os.path.join(FRAMEWORK_DIR, "tools", "cmake", "version.cmake")
with open(version_cmake, "r") as file:
string = file.read().replace("\n", "").replace("(", " ").replace(")", " ")
list = string.split()
v_major = list[(list.index("IDF_VERSION_MAJOR"))+1]
v_minor = list[(list.index("IDF_VERSION_MINOR"))+1]
v_patch = list[(list.index("IDF_VERSION_PATCH"))+1]
version = v_major + "." + v_minor + "." + v_patch
return version


def create_version_file():
version_file = os.path.join(FRAMEWORK_DIR, "version.txt")
if not os.path.isfile(version_file):
with open(version_file, "w") as fp:
package_version = platform.get_package_version("framework-espidf")
fp.write(get_original_version(package_version) or package_version)
version = get_version_cmake_file()
fp.write(version)


def generate_empty_partition_image(binary_path, image_size):
Expand Down Expand Up @@ -1236,10 +1248,8 @@ def get_idf_venv_dir():
# unnecessary reinstallation of Python dependencies in cases when Arduino
# as an IDF component requires a different version of the IDF package and
# hence a different set of Python deps or their versions
idf_version = get_original_version(platform.get_package_version("framework-espidf"))
return os.path.join(
env.subst("$PROJECT_CORE_DIR"), "penv", ".espidf-" + idf_version
)
idf_version = get_version_cmake_file()
return os.path.join(env.subst("$PROJECT_CORE_DIR"), "penv", ".espidf-" + idf_version)


def ensure_python_venv_available():
Expand Down

0 comments on commit 3b7f78a

Please sign in to comment.