Skip to content

Commit 73b54da

Browse files
committed
move call of idf installer
1 parent 08ef197 commit 73b54da

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

builder/main.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434

3535
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
3636

37-
IDF_TOOLS_PATH_DEFAULT = os.path.join(os.path.expanduser("~"), ".espressif")
38-
IDF_TOOLS = join(platform.get_package_dir("tl-install"), "tools", "idf_tools.py")
39-
IDF_TOOLS_FLAG = ["install"]
40-
IDF_TOOLS_CMD = [env["PYTHONEXE"], IDF_TOOLS] + IDF_TOOLS_FLAG
41-
42-
# IDF Install is needed only one time
43-
if not os.path.exists(join(IDF_TOOLS_PATH_DEFAULT, "tools")):
44-
rc = subprocess.call(IDF_TOOLS_CMD)
45-
if rc != 0:
46-
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install' \n")
37+
#IDF_TOOLS_PATH_DEFAULT = os.path.join(os.path.expanduser("~"), ".espressif")
38+
#IDF_TOOLS = join(platform.get_package_dir("tl-install"), "tools", "idf_tools.py")
39+
#IDF_TOOLS_FLAG = ["install"]
40+
#IDF_TOOLS_CMD = [env["PYTHONEXE"], IDF_TOOLS] + IDF_TOOLS_FLAG
41+
42+
## IDF Install is needed only one time
43+
#if not os.path.exists(join(IDF_TOOLS_PATH_DEFAULT, "tools")):
44+
# rc = subprocess.call(IDF_TOOLS_CMD)
45+
# if rc != 0:
46+
# sys.stderr.write("Error: Couldn't execute 'idf_tools.py install' \n")
4747

4848

4949
def BeforeUpload(target, source, env):

platform.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import os
16+
import subprocess
1617
import urllib
1718
import sys
1819
import json
@@ -21,10 +22,14 @@
2122
from os.path import isfile, isdir, join
2223

2324
from platformio.public import PlatformBase, to_unix_path
25+
from platformio.proc import get_pythonexe_path
2426

25-
27+
python_exe = get_pythonexe_path()
2628
IS_WINDOWS = sys.platform.startswith("win")
2729
IDF_TOOLS_PATH_DEFAULT = os.path.join(os.path.expanduser("~"), ".espressif")
30+
IDF_TOOLS = os.path.join(os.path.expanduser("~"), ".platformio", "packages", "tl-install", "tools", "idf_tools.py")
31+
IDF_TOOLS_FLAG = ["install"]
32+
IDF_TOOLS_CMD = [python_exe, IDF_TOOLS] + IDF_TOOLS_FLAG
2833

2934

3035
class Espressif32Platform(PlatformBase):
@@ -36,6 +41,14 @@ def configure_default_packages(self, variables, targets):
3641
mcu = variables.get("board_build.mcu", board_config.get("build.mcu", "esp32"))
3742
frameworks = variables.get("pioframework", [])
3843

44+
self.packages["tl-install"]["optional"] = False
45+
46+
# IDF Install is needed only one time
47+
if not os.path.exists(join(IDF_TOOLS_PATH_DEFAULT, "tools")):
48+
rc = subprocess.call(IDF_TOOLS_CMD)
49+
if rc != 0:
50+
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install' \n")
51+
3952

4053
if "arduino" in frameworks:
4154
self.packages["framework-arduinoespressif32"]["optional"] = False
@@ -87,7 +100,9 @@ def configure_default_packages(self, variables, targets):
87100
for gdb_package in ("tl-xt-gdb", "tl-rv-gdb"):
88101
self.packages[gdb_package]["optional"] = False
89102
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", gdb_package)
90-
self.packages[gdb_package]["version"] = tl_path
103+
# print("gdb path:", tl_path)
104+
if os.path.exists(tl_path):
105+
self.packages[gdb_package]["version"] = tl_path
91106

92107
# Common packages for IDF and mixed Arduino+IDF projects
93108
if "espidf" in frameworks:
@@ -114,7 +129,9 @@ def configure_default_packages(self, variables, targets):
114129
# RISC-V based toolchain for ESP32C3, ESP32C6 ESP32S2, ESP32S3 ULP
115130
self.packages["tc-rv32"]["optional"] = False
116131
rv32_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-rv32")
117-
self.packages["tc-rv32"]["version"] = rv32_path
132+
if os.path.exists(rv32_path):
133+
self.packages["tc-rv32"]["owner"] = "espressif"
134+
self.packages["tc-rv32"]["version"] = rv32_path
118135

119136
return super().configure_default_packages(variables, targets)
120137

0 commit comments

Comments
 (0)