Skip to content

Commit 1b4e109

Browse files
authored
remove hard coding of IDF_TOOLS_PATH and set path to PROJECT_CORE_DIR
1 parent b8ef08e commit 1b4e109

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

platform.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@
7171
IS_WINDOWS = sys.platform.startswith("win")
7272
# Set Platformio env var to use windows_amd64 for all windows architectures
7373
# only windows_amd64 native espressif toolchains are available
74-
# needs platformio/pioarduino core >= 6.1.17
7574
if IS_WINDOWS:
7675
os.environ["PLATFORMIO_SYSTEM_TYPE"] = "windows_amd64"
7776

78-
# Clear IDF_TOOLS_PATH, if set tools may be installed in the wrong place
79-
os.environ["IDF_TOOLS_PATH"] = ""
77+
# Set IDF_TOOLS_PATH to Pio core_dir
78+
PROJECT_CORE_DIR=ProjectConfig.get_instance().get("platformio", "core_dir")
79+
IDF_TOOLS_PATH=os.path.join(PROJECT_CORE_DIR)
80+
os.environ["IDF_TOOLS_PATH"] = IDF_TOOLS_PATH
8081

8182
# Global variables
8283
python_exe = get_pythonexe_path()
@@ -468,19 +469,17 @@ def _install_with_idf_tools(self, tool_name: str, paths: Dict[str, str]) -> bool
468469
return False
469470

470471
# Copy tool files
471-
tools_path_default = os.path.join(
472-
os.path.expanduser("~"), ".platformio"
473472
)
474473
target_package_path = os.path.join(
475-
tools_path_default, "tools", tool_name, "package.json"
474+
IDF_TOOLS_PATH, "tools", tool_name, "package.json"
476475
)
477476

478477
if not safe_copy_file(paths['package_path'], target_package_path):
479478
return False
480479

481480
safe_remove_directory(paths['tool_path'])
482481

483-
tl_path = f"file://{os.path.join(tools_path_default, 'tools', tool_name)}"
482+
tl_path = f"file://{os.path.join(IDF_TOOLS_PATH, 'tools', tool_name)}"
484483
pm.install(tl_path)
485484

486485
logger.info(f"Tool {tool_name} successfully installed")

0 commit comments

Comments
 (0)