@@ -1089,17 +1089,37 @@ def get_recommended_version(self) -> Optional[str]:
10891089
10901090 def get_preferred_installed_version (self ) -> Optional [str ]:
10911091 """
1092- Get the preferred installed version of the tool. If more versions installed, return the highest.
1092+ Get the preferred installed version of the tool.
1093+ If more versions installed, return recommended version if exists, otherwise return the highest supported version
10931094 """
1094- recommended_versions = [
1095+
1096+ try :
1097+ self .find_installed_versions ()
1098+ except ToolBinaryError :
1099+ pass
1100+
1101+ if self .get_recommended_version () in self .versions_installed :
1102+ return self .get_recommended_version ()
1103+
1104+ supported_installed_versions = [
10951105 k
10961106 for k in self .versions_installed
1097- if self .versions [k ].status == IDFToolVersion .STATUS_RECOMMENDED
1107+ if self .versions [k ].status == IDFToolVersion .STATUS_SUPPORTED
10981108 and self .versions [k ].compatible_with_platform (self ._platform )
10991109 ]
1100- assert len (recommended_versions ) <= 1
1101- if recommended_versions :
1102- return recommended_versions [0 ]
1110+ sorted_supported_installed_versions = sorted (
1111+ supported_installed_versions , key = lambda x : self .versions [x ], reverse = True
1112+ )
1113+ if sorted_supported_installed_versions :
1114+ warn (
1115+ '' .join (
1116+ [
1117+ f'Using supported version { sorted_supported_installed_versions [0 ]} for tool { self .name } ' ,
1118+ f'as recommended version { self .get_recommended_version ()} is not installed.' ,
1119+ ]
1120+ )
1121+ )
1122+ return sorted_supported_installed_versions [0 ]
11031123 return None
11041124
11051125 def find_installed_versions (self ) -> None :
@@ -1152,8 +1172,7 @@ def find_installed_versions(self) -> None:
11521172 else :
11531173 if ver_str != version :
11541174 warn (f'tool { self .name } version { version } is installed, but has reported version { ver_str } ' )
1155- else :
1156- self .versions_installed .append (version )
1175+ self .versions_installed .append (version )
11571176 if tool_error :
11581177 raise ToolBinaryError
11591178
@@ -1900,6 +1919,9 @@ def expand_tools_arg(tools_spec: List[str], overall_tools: OrderedDict, targets:
19001919
19011920 # Filtering by ESP_targets
19021921 tools = [k for k in tools if overall_tools [k ].is_supported_for_any_of_targets (targets )]
1922+
1923+ # Processing specific version of tool - defined with '@'
1924+ tools .extend ([tool_pattern for tool_pattern in tools_spec if '@' in tool_pattern ])
19031925 return tools
19041926
19051927
@@ -2250,10 +2272,6 @@ def process_tool(
22502272 tool_export_paths : List [str ] = []
22512273 tool_export_vars : Dict [str , str ] = {}
22522274
2253- try :
2254- tool .find_installed_versions ()
2255- except ToolBinaryError :
2256- pass
22572275 recommended_version_to_use = tool .get_preferred_installed_version ()
22582276
22592277 if not tool .is_executable and recommended_version_to_use :
0 commit comments