Skip to content
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,18 +4,13 @@
*******************************************************************************/
package com.espressif.idf.ui.update;

import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
Expand Down Expand Up @@ -120,57 +115,8 @@ private void processExportCmdOutput(final String exportCmdOp, final String gitEx
value = appendGitToPath(value, gitExecutablePath);
}

final IEnvironmentVariable env = idfEnvMgr.getEnv(key);

// Environment variable not found
if (env == null)
{
idfEnvMgr.addEnvVariable(key, value);
}
else if (key.equals(IDFEnvironmentVariables.PATH)) // Special processing in case of PATH
{
// PATH is already defined in the environment variables - so let's identify and append the missing
// paths

// Process the old PATH
String oldPath = env.getValue();
String[] oldPathEntries = oldPath.split(File.pathSeparator);

// Prepare a new set of entries
Set<String> newPathSet = new LinkedHashSet<>(); // Order is important here, check IEP-60

// Process a new PATH
String[] newPathEntries = value.split(File.pathSeparator);
newPathSet.addAll(Arrays.asList(newPathEntries));

// Add old entries
newPathSet.addAll(Arrays.asList(oldPathEntries));

// Prepare PATH string
StringBuilder pathBuilder = new StringBuilder();
for (String newEntry : newPathSet)
{
newEntry = replacePathVariable(newEntry);
if (!StringUtil.isEmpty(newEntry))
{
pathBuilder.append(newEntry);
pathBuilder.append(File.pathSeparator);
}
}

// remove the last pathSeparator
pathBuilder.deleteCharAt(pathBuilder.length() - 1);

// Replace with a new PATH entry
Logger.log(pathBuilder.toString());
idfEnvMgr.addEnvVariable(IDFEnvironmentVariables.PATH, pathBuilder.toString());
}
else
{
// Other build variables - let's replace with new values
idfEnvMgr.addEnvVariable(key, value);
}

// add new or replace old entries
idfEnvMgr.addEnvVariable(key, value);
}

}
Expand Down