Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-1329 Application Size Analysis does not work. #1055

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading