@@ -45,15 +45,13 @@ def configure_default_packages(self, variables, targets):
45
45
frameworks = variables .get ("pioframework" , [])
46
46
47
47
def install_tool (TOOL ):
48
- INSTALL_TOOL = "install-" + TOOL .split ('-' , 1 )[- 1 ]
49
- self .packages [INSTALL_TOOL ]["optional" ] = False
50
- INSTALL_TOOL_PATH = os .path .join (ProjectConfig .get_instance ().get ("platformio" , "packages_dir" ), INSTALL_TOOL )
48
+ self .packages [TOOL ]["optional" ] = False
51
49
TOOL_PATH = os .path .join (ProjectConfig .get_instance ().get ("platformio" , "packages_dir" ), TOOL )
52
50
TOOL_PACKAGE_PATH = os .path .join (TOOL_PATH , "package.json" )
53
51
TOOLS_PATH_DEFAULT = os .path .join (os .path .expanduser ("~" ), ".platformio" )
54
52
IDF_TOOLS = os .path .join (ProjectConfig .get_instance ().get ("platformio" , "packages_dir" ), "tl-install" , "tools" , "idf_tools.py" )
55
- TOOLS_JSON_PATH = os .path .join (INSTALL_TOOL_PATH , "tools.json" )
56
- TOOLS_PACK_PATH = os .path .join (INSTALL_TOOL_PATH , "package.json " )
53
+ TOOLS_JSON_PATH = os .path .join (TOOL_PATH , "tools.json" )
54
+ TOOLS_PIO_PATH = os .path .join (TOOL_PATH , ".piopm " )
57
55
IDF_TOOLS_CMD = (
58
56
python_exe ,
59
57
IDF_TOOLS ,
@@ -66,22 +64,26 @@ def install_tool(TOOL):
66
64
67
65
tl_flag = bool (os .path .exists (IDF_TOOLS ))
68
66
json_flag = bool (os .path .exists (TOOLS_JSON_PATH ))
69
- tool_flag = bool (os .path .exists (TOOL_PACKAGE_PATH ))
70
- if tl_flag and json_flag and not tool_flag :
67
+ pio_flag = bool (os .path .exists (TOOLS_PIO_PATH ))
68
+ if tl_flag and json_flag :
71
69
rc = subprocess .run (IDF_TOOLS_CMD ).returncode
72
70
if rc != 0 :
73
71
sys .stderr .write ("Error: Couldn't execute 'idf_tools.py install'\n " )
74
72
else :
75
73
tl_path = "file://" + join (TOOLS_PATH_DEFAULT , "tools" , TOOL )
76
74
if not os .path .exists (join (TOOLS_PATH_DEFAULT , "tools" , TOOL , "package.json" )):
77
- shutil .copyfile (TOOLS_PACK_PATH , join (TOOLS_PATH_DEFAULT , "tools" , TOOL , "package.json" ))
75
+ shutil .copyfile (TOOL_PACKAGE_PATH , join (TOOLS_PATH_DEFAULT , "tools" , TOOL , "package.json" ))
76
+ self .packages .pop (TOOL , None )
77
+ if os .path .exists (TOOL_PATH ,) and os .path .isdir (TOOL_PATH ):
78
+ try :
79
+ shutil .rmtree (TOOL_PATH )
80
+ except Exception as e :
81
+ print (f"Error while removing the tool folder: { e } " )
78
82
pm .install (tl_path )
79
- self .packages [INSTALL_TOOL ]["optional" ] = True
80
83
# tool is already installed, just activate it
81
- if tl_flag and json_flag and tool_flag :
84
+ if tl_flag and pio_flag and not json_flag :
82
85
self .packages [TOOL ]["version" ] = TOOL_PATH
83
86
self .packages [TOOL ]["optional" ] = False
84
- self .packages [INSTALL_TOOL ]["optional" ] = True
85
87
86
88
return
87
89
@@ -140,8 +142,6 @@ def install_tool(TOOL):
140
142
for gdb_package in ("tool-xtensa-esp-elf-gdb" , "tool-riscv32-esp-elf-gdb" ):
141
143
self .packages [gdb_package ]["optional" ] = False
142
144
install_tool ("tool-openocd-esp32" )
143
- else :
144
- self .packages ["install-openocd-esp32" ]["optional" ] = True
145
145
146
146
# Common packages for IDF and mixed Arduino+IDF projects
147
147
if "espidf" in frameworks :
0 commit comments