Skip to content

Commit bf0d1c5

Browse files
authored
IEP-1329 Application Size Analysis does not work. (#1055)
* fix: fix app size analysis on esp-idf with multiple dots
1 parent 0917e35 commit bf0d1c5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*******************************************************************************/
55
package com.espressif.idf.ui.size;
66

7+
import java.lang.module.ModuleDescriptor.Version;
78
import java.util.ArrayList;
89
import java.util.Collections;
910
import java.util.List;
@@ -189,11 +190,12 @@ protected List<String> getCommandArgsArchives(String pythonExecutablenPath, IFil
189190

190191
private List<String> addJsonParseCommand()
191192
{
192-
List<String> arguments = new ArrayList<String>();
193+
List<String> arguments = new ArrayList<>();
193194
IEnvironmentVariable idfVersionEnv = new IDFEnvironmentVariables()
194195
.getEnv(IDFEnvironmentVariables.ESP_IDF_VERSION);
195196
String idfVersion = idfVersionEnv != null ? idfVersionEnv.getValue() : null;
196-
if (idfVersion != null && Double.parseDouble(idfVersion) >= 5.1)
197+
198+
if (idfVersion != null && isVersionAtLeast(idfVersion, "5.1")) //$NON-NLS-1$
197199
{
198200
arguments.add("--format"); //$NON-NLS-1$
199201
arguments.add("json"); //$NON-NLS-1$
@@ -205,6 +207,13 @@ private List<String> addJsonParseCommand()
205207
return arguments;
206208
}
207209

210+
public boolean isVersionAtLeast(String currentIDFVersion, String minimumIDFVersion)
211+
{
212+
Version currentVersion = Version.parse(currentIDFVersion);
213+
Version minVersion = Version.parse(minimumIDFVersion);
214+
return currentVersion.compareTo(minVersion) >= 0;
215+
}
216+
208217
protected List<String> getCommandArgsSymbolDetails(String pythonExecutablenPath, IFile file)
209218
{
210219
List<String> arguments = new ArrayList<String>();
@@ -231,6 +240,12 @@ protected List<String> getCommandArgs(String pythonExecutablenPath, IFile file,
231240
protected JSONObject getJSON(String jsonOutput)
232241
{
233242
JSONObject jsonObj = null;
243+
if (jsonOutput.indexOf("{") != 0) //$NON-NLS-1$
244+
{
245+
int begin = jsonOutput.indexOf("{") - 1; //$NON-NLS-1$
246+
int end = jsonOutput.lastIndexOf("}") + 1; //$NON-NLS-1$
247+
jsonOutput = jsonOutput.substring(begin, end);
248+
}
234249
try
235250
{
236251
jsonObj = (JSONObject) new JSONParser().parse(jsonOutput);

0 commit comments

Comments
 (0)