Enhanced optimization using multi-value URL resolution. This method leverages the enhanced resolution system to: 1. Resolve shorthand names to multiple URL types (git, zip) 2. Prefer zip URLs for faster caching when available 3. Fall back to git URLs when zi
(self, cache: "PlatformIOCache")
| 2225 | logger.info(f"Replaced {len(replacements)} URLs with cached local paths") |
| 2226 | |
| 2227 | def optimize_enhanced(self, cache: "PlatformIOCache") -> None: |
| 2228 | """ |
| 2229 | Enhanced optimization using multi-value URL resolution. |
| 2230 | |
| 2231 | This method leverages the enhanced resolution system to: |
| 2232 | 1. Resolve shorthand names to multiple URL types (git, zip) |
| 2233 | 2. Prefer zip URLs for faster caching when available |
| 2234 | 3. Fall back to git URLs when zip URLs are not available |
| 2235 | 4. Update local_path in resolution results after caching |
| 2236 | |
| 2237 | Args: |
| 2238 | cache: PlatformIOCache instance to use for downloading and caching packages. |
| 2239 | """ |
| 2240 | # Import here to avoid circular dependencies |
| 2241 | from ci.compiler.platformio_cache import _is_zip_web_url, handle_zip_artifact |
| 2242 | |
| 2243 | cache_manager = cache |
| 2244 | |
| 2245 | # Step 1: Resolve shorthand platform names using enhanced resolution |
| 2246 | logger.debug("Resolving platform shorthand names using enhanced resolution...") |
| 2247 | platform_replacements_made = 0 |
| 2248 | platform_resolutions: dict[str, PlatformUrlResolution] = {} |
| 2249 | |
| 2250 | for section_name, option_name, platform_value in self.get_platform_urls(): |
| 2251 | if platform_value and not self._is_url(platform_value): |
| 2252 | if platform_value not in platform_resolutions: |
| 2253 | resolution = self.resolve_platform_url_enhanced(platform_value) |
| 2254 | if resolution: |
| 2255 | platform_resolutions[platform_value] = resolution |
| 2256 | |
| 2257 | # Replace shorthand names with preferred URLs and track for caching |
| 2258 | for platform_name, resolution in platform_resolutions.items(): |
| 2259 | preferred_url = resolution.preferred_url |
| 2260 | if preferred_url: |
| 2261 | for section_name, option_name, current_url in self.get_platform_urls(): |
| 2262 | if current_url == platform_name: |
| 2263 | self.replace_url( |
| 2264 | section_name, option_name, platform_name, preferred_url |
| 2265 | ) |
| 2266 | platform_replacements_made += 1 |
| 2267 | logger.debug( |
| 2268 | f"Enhanced platform resolution {platform_name} -> {preferred_url} in {section_name}" |
| 2269 | ) |
| 2270 | |
| 2271 | if platform_replacements_made > 0: |
| 2272 | logger.info( |
| 2273 | f"Enhanced resolution of {platform_replacements_made} platform shorthand names" |
| 2274 | ) |
| 2275 | |
| 2276 | # Step 2: Resolve shorthand framework names using enhanced resolution |
| 2277 | logger.debug("Resolving framework shorthand names using enhanced resolution...") |
| 2278 | framework_replacements_made = 0 |
| 2279 | framework_resolutions: dict[str, FrameworkUrlResolution] = {} |
| 2280 | |
| 2281 | for section_name, option_name, framework_value in self.get_framework_urls(): |
| 2282 | if ( |
| 2283 | framework_value |
| 2284 | and not self._is_url(framework_value) |