@@ -999,12 +999,38 @@ def find_default_component(target_configs):
999
999
env .Exit (1 )
1000
1000
1001
1001
1002
+ def get_framework_version ():
1003
+ def _extract_from_cmake_version_file ():
1004
+ version_cmake_file = os .path .join (
1005
+ FRAMEWORK_DIR , "tools" , "cmake" , "version.cmake"
1006
+ )
1007
+ if not os .path .isfile (version_cmake_file ):
1008
+ return
1009
+
1010
+ with open (version_cmake_file , encoding = "utf8" ) as fp :
1011
+ pattern = r"set\(IDF_VERSION_(MAJOR|MINOR|PATCH) (\d+)\)"
1012
+ matches = re .findall (pattern , fp .read ())
1013
+ if len (matches ) != 3 :
1014
+ return
1015
+ # If found all three parts of the version
1016
+ return "." .join ([match [1 ] for match in matches ])
1017
+
1018
+ pkg = platform .get_package ("framework-espidf" )
1019
+ version = get_original_version (str (pkg .metadata .version .truncate ()))
1020
+ if not version :
1021
+ # Fallback value extracted directly from the cmake version file
1022
+ version = _extract_from_cmake_version_file ()
1023
+ if not version :
1024
+ version = "0.0.0"
1025
+
1026
+ return version
1027
+
1028
+
1002
1029
def create_version_file ():
1003
1030
version_file = os .path .join (FRAMEWORK_DIR , "version.txt" )
1004
1031
if not os .path .isfile (version_file ):
1005
1032
with open (version_file , "w" ) as fp :
1006
- package_version = platform .get_package_version ("framework-espidf" )
1007
- fp .write (get_original_version (package_version ) or package_version )
1033
+ fp .write (get_framework_version ())
1008
1034
1009
1035
1010
1036
def generate_empty_partition_image (binary_path , image_size ):
@@ -1236,7 +1262,7 @@ def get_idf_venv_dir():
1236
1262
# unnecessary reinstallation of Python dependencies in cases when Arduino
1237
1263
# as an IDF component requires a different version of the IDF package and
1238
1264
# hence a different set of Python deps or their versions
1239
- idf_version = get_original_version ( platform . get_package_version ( "framework-espidf" ) )
1265
+ idf_version = get_framework_version ( )
1240
1266
return os .path .join (
1241
1267
env .subst ("$PROJECT_CORE_DIR" ), "penv" , ".espidf-" + idf_version
1242
1268
)
0 commit comments