Skip to content

Commit d6453fd

Browse files
authored
No registry dependency (#23)
* Scons is installed via pioarduino core
1 parent 49d8edc commit d6453fd

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

.github/workflows/examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: |
4444
python -m pip install --upgrade pip
4545
pip install wheel
46-
pip install -U https://github.com/platformio/platformio/archive/develop.zip
46+
pip install -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.16+test.tar.gz
4747
pio pkg install --global --platform symlink://.
4848
- name: Build examples
4949
run: |

builder/main.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,36 @@
2424
DefaultEnvironment)
2525

2626
from platformio.util import get_serial_ports
27+
from platformio.proc import exec_command, where_is_program
2728

29+
pio_exe = where_is_program("platformio")
2830
env = DefaultEnvironment()
2931
platform = env.PioPlatform()
32+
board = env.BoardConfig()
33+
mcu = board.get("build.mcu", "esp32")
3034

3135
#
3236
# Helpers
3337
#
3438

35-
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
39+
PLATFORM_PATH = env.GetProjectOption("platform")
40+
PLATFORM_CMD = (
41+
pio_exe,
42+
"pkg",
43+
"install",
44+
"--global",
45+
"--platform",
46+
PLATFORM_PATH,
47+
)
3648

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
49+
# install platform again to install missing packages, needed since no registry install
50+
if bool(platform.get_package_dir("tc-%s" % ("rv32" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2") else ("xt-%s" % mcu)))) == False:
51+
result = exec_command(PLATFORM_CMD)
52+
if result["returncode"] != 0:
53+
sys.stderr.write(result["err"] + "\n")
54+
env.Exit(1)
4155

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")
56+
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
4757

4858

4959
def BeforeUpload(target, source, env):

platform.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@
140140
"owner": "",
141141
"version": ""
142142
},
143-
"tool-scons": {
144-
"optional": false,
145-
"owner": "",
146-
"version": "https://github.com/pioarduino/scons/releases/download/4.7.0/scons-local-4.7.0.tar.gz"
147-
},
148143
"tool-cppcheck": {
149144
"optional": true,
150145
"owner": "",

platform.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,15 @@
2020

2121
from platformio.public import PlatformBase, to_unix_path
2222
from platformio.proc import get_pythonexe_path
23-
from platformio.package.manager.tool import ToolPackageManager
23+
from platformio.project.config import ProjectConfig
2424

2525
python_exe = get_pythonexe_path()
26-
pm = ToolPackageManager()
27-
IS_WINDOWS = sys.platform.startswith("win")
26+
2827
IDF_TOOLS_PATH_DEFAULT = os.path.join(os.path.expanduser("~"), ".espressif")
29-
try:
30-
tl_path = pm.get_package("tl-install").path
31-
IDF_TOOLS = os.path.join(tl_path, "tools", "idf_tools.py")
32-
except:
33-
IDF_TOOLS = ""
28+
IDF_TOOLS = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tl-install", "tools", "idf_tools.py")
3429
IDF_TOOLS_FLAG = ["install"]
3530
IDF_TOOLS_CMD = [python_exe, IDF_TOOLS] + IDF_TOOLS_FLAG
3631

37-
3832
class Espressif32Platform(PlatformBase):
3933
def configure_default_packages(self, variables, targets):
4034
if not variables.get("board"):
@@ -43,22 +37,20 @@ def configure_default_packages(self, variables, targets):
4337
board_config = self.board_config(variables.get("board"))
4438
mcu = variables.get("board_build.mcu", board_config.get("build.mcu", "esp32"))
4539
frameworks = variables.get("pioframework", [])
46-
try:
47-
tl_flag = bool(pm.get_package("tl-install").path)
48-
except:
49-
tl_flag = False
40+
tl_flag = bool(os.path.exists(IDF_TOOLS))
5041

5142
# IDF Install is needed only one time
5243
if not os.path.exists(join(IDF_TOOLS_PATH_DEFAULT, "tools")) and tl_flag:
5344
rc = subprocess.call(IDF_TOOLS_CMD)
5445
if rc != 0:
55-
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install' \n")
46+
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install'\n")
5647
else:
5748
shutil.copytree(join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-packages"), join(IDF_TOOLS_PATH_DEFAULT, "tools"), symlinks=False, ignore=None, ignore_dangling_symlinks=False, dirs_exist_ok=True)
5849

5950
if tl_flag:
60-
# Install all tools and toolchains
51+
# install tool is not needed anymore
6152
self.packages["tl-install"]["optional"] = True
53+
# Install all tools and toolchains
6254
for p in self.packages:
6355
if p in ("tool-mklittlefs", "tool-mkfatfs", "tool-mkspiffs", "tool-dfuutil", "tool-openocd", "tool-cmake", "tool-ninja", "tool-cppcheck", "tool-clangtidy", "tool-pvs-studio", "contrib-piohome", "contrib-pioremote", "tc-ulp", "tc-rv32", "tl-xt-gdb", "tl-rv-gdb"):
6456
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", p)
@@ -70,7 +62,7 @@ def configure_default_packages(self, variables, targets):
7062
self.packages[p]["optional"] = False if "espidf" in frameworks else True
7163
# Enabling of following tools is not needed, installing is enough
7264
for p in self.packages:
73-
if p in ("contrib-pioremote", "contrib-piohome", "tool-scons"):
65+
if p in ("contrib-pioremote", "contrib-piohome"):
7466
try:
7567
pkg_dir = pm.get_package(p).path
7668
# When package is not found an execption happens -> install is forced

0 commit comments

Comments
 (0)