Skip to content

Commit

Permalink
only do a online request for framework when folder does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Nov 25, 2024
1 parent 9ad58a5 commit 68bbf04
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import json
import re
import requests
from os.path import isfile, join

from platformio.public import PlatformBase, to_unix_path
from platformio.project.config import ProjectConfig


IS_WINDOWS = sys.platform.startswith("win")
Expand All @@ -45,22 +47,24 @@ def configure_default_packages(self, variables, targets):
if "arduino" in frameworks:
self.packages["framework-arduinoespressif32"]["optional"] = False
self.packages["framework-arduinoespressif32-libs"]["optional"] = False
try:
# use latest stable release Arduino core
ARDUINO_CORE_API_URL = "https://api.github.com/repos/espressif/Arduino-esp32/releases/latest"
api_data = requests.get(ARDUINO_CORE_API_URL, timeout=2).json()
zipball = api_data.get("zipball_url")
tag = api_data.get("tag_name")
if tag is not None:
# print("Latest release Arduino core URL:", zipball)
self.packages["framework-arduinoespressif32"]["version"] = zipball
# use corresponding espressif Arduino libs to release
URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/" + tag + "/package/package_esp32_index.template.json"
packjdata = requests.get(URL, timeout=10).json()
dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url']
self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url
except:
pass
ARDUINO_FRAMEWORK_DIR = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "framework-arduinoespressif32")
if not bool(os.path.exists(ARDUINO_FRAMEWORK_DIR)):
try:
# use latest stable release Arduino core
ARDUINO_CORE_API_URL = "https://api.github.com/repos/espressif/Arduino-esp32/releases/latest"
api_data = requests.get(ARDUINO_CORE_API_URL, timeout=2).json()
zipball = api_data.get("zipball_url")
tag = api_data.get("tag_name")
if tag is not None:
# print("Latest release Arduino core URL:", zipball)
self.packages["framework-arduinoespressif32"]["version"] = zipball
# use corresponding espressif Arduino libs to release
URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/" + tag + "/package/package_esp32_index.template.json"
packjdata = requests.get(URL, timeout=10).json()
dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url']
self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url
except:
pass

if "buildfs" in targets:
filesystem = variables.get("board_build.filesystem", "littlefs")
Expand Down Expand Up @@ -132,10 +136,10 @@ def configure_default_packages(self, variables, targets):
# and RISC-V targets.
for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"):
self.packages[gdb_package]["optional"] = False
if IS_WINDOWS:
#if IS_WINDOWS:
# Note: On Windows GDB v12 is not able to
# launch a GDB server in pipe mode while v11 works fine
self.packages[gdb_package]["version"] = "~11.2.0"
# self.packages[gdb_package]["version"] = "~11.2.0"

# Common packages for IDF and mixed Arduino+IDF projects
if "espidf" in frameworks:
Expand Down

0 comments on commit 68bbf04

Please sign in to comment.