Skip to content

Commit

Permalink
IEP-1329 Application Size Analysis does not work. (#1055)
Browse files Browse the repository at this point in the history
* fix: fix app size analysis on esp-idf with multiple dots
  • Loading branch information
sigmaaa authored Oct 1, 2024
1 parent 0917e35 commit bf0d1c5
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*******************************************************************************/
package com.espressif.idf.ui.size;

import java.lang.module.ModuleDescriptor.Version;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -189,11 +190,12 @@ protected List<String> getCommandArgsArchives(String pythonExecutablenPath, IFil

private List<String> addJsonParseCommand()
{
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
IEnvironmentVariable idfVersionEnv = new IDFEnvironmentVariables()
.getEnv(IDFEnvironmentVariables.ESP_IDF_VERSION);
String idfVersion = idfVersionEnv != null ? idfVersionEnv.getValue() : null;
if (idfVersion != null && Double.parseDouble(idfVersion) >= 5.1)

if (idfVersion != null && isVersionAtLeast(idfVersion, "5.1")) //$NON-NLS-1$
{
arguments.add("--format"); //$NON-NLS-1$
arguments.add("json"); //$NON-NLS-1$
Expand All @@ -205,6 +207,13 @@ private List<String> addJsonParseCommand()
return arguments;
}

public boolean isVersionAtLeast(String currentIDFVersion, String minimumIDFVersion)
{
Version currentVersion = Version.parse(currentIDFVersion);
Version minVersion = Version.parse(minimumIDFVersion);
return currentVersion.compareTo(minVersion) >= 0;
}

protected List<String> getCommandArgsSymbolDetails(String pythonExecutablenPath, IFile file)
{
List<String> arguments = new ArrayList<String>();
Expand All @@ -231,6 +240,12 @@ protected List<String> getCommandArgs(String pythonExecutablenPath, IFile file,
protected JSONObject getJSON(String jsonOutput)
{
JSONObject jsonObj = null;
if (jsonOutput.indexOf("{") != 0) //$NON-NLS-1$
{
int begin = jsonOutput.indexOf("{") - 1; //$NON-NLS-1$
int end = jsonOutput.lastIndexOf("}") + 1; //$NON-NLS-1$
jsonOutput = jsonOutput.substring(begin, end);
}
try
{
jsonObj = (JSONObject) new JSONParser().parse(jsonOutput);
Expand Down

0 comments on commit bf0d1c5

Please sign in to comment.