diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java index 12ee97850..f0ce64c76 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java @@ -7,11 +7,14 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; +import com.espressif.idf.core.util.IDFUtil; + /** * @author Kondal Kolipaka * @@ -31,6 +34,10 @@ public class IDFCorePreferenceConstants public static final String IDF_GITHUB_ASSETS_DEFAULT = "dl.espressif.com/github_assets"; //$NON-NLS-1$ public static final String PIP_EXTRA_INDEX_URL = "PIP_EXTRA_INDEX_URL"; //$NON-NLS-1$ public static final String PIP_EXTRA_INDEX_URL_DEFAULT = "https://dl.espressif.com/pypi"; //$NON-NLS-1$ + public static final String IDF_TOOLS_PATH = "IDF_TOOLS_PATH"; //$NON-NLS-1$ + public static final String IDF_TOOLS_PATH_DEFAULT = Platform.getOS().equals(Platform.OS_WIN32) + ? IDFUtil.resolveEnvVariable("%USERPROFILE%\\.espressif") //$NON-NLS-1$ + : IDFUtil.resolveEnvVariable("$HOME/.espressif"); //$NON-NLS-1$ /** * Returns the node in the preference in the given context. * diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFEnvironmentVariables.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFEnvironmentVariables.java index de5d3d06e..d83ba27a6 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFEnvironmentVariables.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFEnvironmentVariables.java @@ -18,13 +18,14 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; import com.espressif.idf.core.logging.Logger; +import com.espressif.idf.core.util.IDFUtil; import com.espressif.idf.core.util.StringUtil; /** * @author Kondal Kolipaka * */ -@SuppressWarnings("restriction") //$NON-NLS-1$ +@SuppressWarnings("restriction") public class IDFEnvironmentVariables { /** @@ -127,17 +128,21 @@ public Map getSystemEnvMap() IEnvironmentVariableManager buildEnvironmentManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IEnvironmentVariable[] variables = buildEnvironmentManager.getVariables((ICConfigurationDescription) null, true); - Map envMap = new HashMap<>(); + Map envMap = IDFUtil.getSystemEnv(); if (variables != null) { for (IEnvironmentVariable iEnvironmentVariable : variables) { String key = iEnvironmentVariable.getName(); + if (key.equals(IDFCorePreferenceConstants.IDF_TOOLS_PATH)) + { + continue; + } String value = iEnvironmentVariable.getValue(); envMap.put(key, value); } } - + return envMap; } diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java index cf2c09c45..c3bc2b7d0 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java @@ -420,7 +420,10 @@ private void runCmakeBuildCommand(IConsole console, IProgressMonitor monitor, IP } } } - + + envVars.add(new EnvironmentVariable(IDFCorePreferenceConstants.IDF_TOOLS_PATH, + IDFUtil.getIDFToolsPathFromPreferences())); + String buildCommand = getProperty(BUILD_COMMAND); if (buildCommand.isBlank()) { @@ -523,7 +526,7 @@ private void runCmakeCommand(IConsole console, IProgressMonitor monitor, IProjec { command.add("-DIDF_TOOLCHAIN=clang"); //$NON-NLS-1$ } - + String userArgs = getProperty(CMAKE_ARGUMENTS); if (userArgs != null && !userArgs.isBlank()) { @@ -541,8 +544,9 @@ private void runCmakeCommand(IConsole console, IProgressMonitor monitor, IProjec // Set PYTHONUNBUFFERED to 1/TRUE to dump the messages back immediately without // buffering IEnvironmentVariable bufferEnvVar = new EnvironmentVariable("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ + IEnvironmentVariable idfToolsPathEnvVar = new EnvironmentVariable(IDFCorePreferenceConstants.IDF_TOOLS_PATH, IDFUtil.getIDFToolsPathFromPreferences()); - Process p = startBuildProcess(command, new IEnvironmentVariable[] { bufferEnvVar }, workingDir, errConsole, + Process p = startBuildProcess(command, new IEnvironmentVariable[] { bufferEnvVar, idfToolsPathEnvVar }, workingDir, errConsole, monitor); if (p == null) { diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java index b8942cb14..4e6668a06 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java @@ -315,7 +315,7 @@ protected String getIdfToolsExportPath() Logger.log(commands.toString()); IStatus idfToolsExportStatus = new ProcessBuilderFactory().runInBackground(commands, - org.eclipse.core.runtime.Path.ROOT, System.getenv()); + org.eclipse.core.runtime.Path.ROOT, IDFUtil.getSystemEnv()); if (idfToolsExportStatus != null && idfToolsExportStatus.isOK()) { String message = idfToolsExportStatus.getMessage(); diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/util/ToolsUtility.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/util/ToolsUtility.java index 6c4479a43..843d430f0 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/util/ToolsUtility.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/util/ToolsUtility.java @@ -37,6 +37,7 @@ import com.espressif.idf.core.tools.ToolsSystemWrapper; import com.espressif.idf.core.tools.vo.ToolsVO; import com.espressif.idf.core.util.FileUtil; +import com.espressif.idf.core.util.IDFUtil; import com.espressif.idf.core.util.StringUtil; /** @@ -318,7 +319,7 @@ public static IPath findAbsoluteToolPath(String toolName, String path) { if (StringUtil.isEmpty(path)) { - Map env = System.getenv(); + Map env = IDFUtil.getSystemEnv(); if (env.containsKey(IDFEnvironmentVariables.PATH)) path = env.get(IDFEnvironmentVariables.PATH); else diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/EspToolCommands.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/EspToolCommands.java index 8f5dc3e9b..1de306634 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/EspToolCommands.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/EspToolCommands.java @@ -25,21 +25,27 @@ public class EspToolCommands public Process chipInformation(String port) throws Exception { destroyAnyChipInfoProcess(); - chipInfoProcess = new ProcessBuilder(getChipInfoCommand(port)).start(); + ProcessBuilder processBuilder = new ProcessBuilder(getChipInfoCommand(port)); + processBuilder.environment().putAll(IDFUtil.getSystemEnv()); + chipInfoProcess = processBuilder.start(); return chipInfoProcess; } public Process eraseFlash(String port) throws Exception { destroyAnyChipInfoProcess(); - flashEraseProcess = new ProcessBuilder(getFlashEraseCommand(port)).start(); + ProcessBuilder processBuilder = new ProcessBuilder(getFlashEraseCommand(port)); + processBuilder.environment().putAll(IDFUtil.getSystemEnv()); + flashEraseProcess = processBuilder.start(); return flashEraseProcess; } public Process writeFlash(String port, String path, String offset) throws IOException { destroyAnyChipInfoProcess(); - writeFlashProcess = new ProcessBuilder(getWriteFlashCommand(port, path, offset)).start(); + ProcessBuilder processBuilder = new ProcessBuilder(getWriteFlashCommand(port, path, offset)); + processBuilder.environment().putAll(IDFUtil.getSystemEnv()); + writeFlashProcess = processBuilder.start(); return writeFlashProcess; } diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java index 5590719fb..d950d6d51 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java @@ -37,6 +37,7 @@ import com.espressif.idf.core.IDFConstants; import com.espressif.idf.core.IDFCorePlugin; +import com.espressif.idf.core.IDFCorePreferenceConstants; import com.espressif.idf.core.IDFEnvironmentVariables; import com.espressif.idf.core.ProcessBuilderFactory; import com.espressif.idf.core.SystemExecutableFinder; @@ -728,7 +729,7 @@ public static String getGitExecutablePathFromSystem() arguments.add("whereis"); //$NON-NLS-1$ arguments.add("git"); //$NON-NLS-1$ - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(getSystemEnv()); IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, environment); @@ -760,4 +761,56 @@ public static boolean isReparseTag(File file) } return false; } + + public static String resolveEnvVariable(String path) + { + Pattern winEnvPattern = Pattern.compile("%(\\w+)%"); //$NON-NLS-1$ + Pattern unixEnvPattern = Pattern.compile("\\$(\\w+)"); //$NON-NLS-1$ + Matcher matcher; + if (Platform.getOS().equals(Platform.OS_WIN32)) + { + matcher = winEnvPattern.matcher(path); + } + else + { + matcher = unixEnvPattern.matcher(path); + } + + StringBuffer resolvedPath = new StringBuffer(); + while (matcher.find()) + { + String envVarName = matcher.group(1); + String envVarValue = System.getenv(envVarName); + + if (envVarValue != null) + { + matcher.appendReplacement(resolvedPath, envVarValue.replace("\\", "\\\\")); //$NON-NLS-1$ //$NON-NLS-2$ + } + else + { + // If the environment variable is not found, keep the original + matcher.appendReplacement(resolvedPath, matcher.group(0)); + } + } + matcher.appendTail(resolvedPath); + + return resolvedPath.toString(); + + } + + public static Map getSystemEnv() + { + Map env = new HashMap(System.getenv()); + String idfToolsPath = Platform.getPreferencesService().getString(IDFCorePlugin.PLUGIN_ID, + IDFCorePreferenceConstants.IDF_TOOLS_PATH, IDFCorePreferenceConstants.IDF_TOOLS_PATH_DEFAULT, null); + env.put(IDFCorePreferenceConstants.IDF_TOOLS_PATH, idfToolsPath); + return env; + } + + public static String getIDFToolsPathFromPreferences() + { + String idfToolsPath = Platform.getPreferencesService().getString(IDFCorePlugin.PLUGIN_ID, + IDFCorePreferenceConstants.IDF_TOOLS_PATH, IDFCorePreferenceConstants.IDF_TOOLS_PATH_DEFAULT, null); + return idfToolsPath; + } } diff --git a/bundles/com.espressif.idf.serial.monitor/src/com/espressif/idf/serial/monitor/core/IDFMonitor.java b/bundles/com.espressif.idf.serial.monitor/src/com/espressif/idf/serial/monitor/core/IDFMonitor.java index 7427f69ea..e63d7ee60 100644 --- a/bundles/com.espressif.idf.serial.monitor/src/com/espressif/idf/serial/monitor/core/IDFMonitor.java +++ b/bundles/com.espressif.idf.serial.monitor/src/com/espressif/idf/serial/monitor/core/IDFMonitor.java @@ -159,7 +159,7 @@ public Process start() throws Exception idfEnvMap.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ // Update with the CDT build environment variables - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); environment.putAll(idfEnvMap); Logger.log(environment.toString()); diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/SbomCommandDialog.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/SbomCommandDialog.java index 0a27a578f..d7445e758 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/SbomCommandDialog.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/SbomCommandDialog.java @@ -283,7 +283,7 @@ private String buildProjectDescriptionPath() private void runEspIdfSbomCommand() { - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); List arguments = new ArrayList<>(); final String pythonEnvPath = IDFUtil.getIDFPythonEnvPath(); arguments.add(pythonEnvPath); @@ -435,7 +435,7 @@ private boolean checkIfFileIsNotWritable(java.nio.file.Path pathToFile) private void installEspIdfSbom() { - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); List arguments = new ArrayList<>(); final String pythonEnvPath = IDFUtil.getIDFPythonEnvPath(); arguments.add(pythonEnvPath); @@ -450,7 +450,7 @@ private void installEspIdfSbom() private boolean getEspIdfSbomInstalledStatus() { - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); List arguments = new ArrayList<>(); final String pythonEnvPath = IDFUtil.getIDFPythonEnvPath(); arguments.add(pythonEnvPath); diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/help/ProductInformationHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/help/ProductInformationHandler.java index afed00087..e7e988e15 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/help/ProductInformationHandler.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/help/ProductInformationHandler.java @@ -131,7 +131,7 @@ private String getPythonExeVersion(String pythonExePath) List commands = new ArrayList<>(); commands.add(pythonExePath); commands.add("--version"); //$NON-NLS-1$ - return pythonExePath != null ? runCommand(commands, System.getenv()) : null; + return pythonExePath != null ? runCommand(commands, IDFUtil.getSystemEnv()) : null; } private String runCommand(List arguments, Map env) diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java index e85e802f5..283dcc4da 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java @@ -3,11 +3,14 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; @@ -38,6 +41,7 @@ public class EspresssifPreferencesPage extends PreferencePage implements IWorkbe private Text gitAssetsText; private Text pythonWheelText; + private Text idfToolsPathText; public EspresssifPreferencesPage() { @@ -83,7 +87,7 @@ private void addToolsInstallationSettings(Composite mainComposite) { Group toolsInstallationGroup = new Group(mainComposite, SWT.SHADOW_ETCHED_IN); toolsInstallationGroup.setText(Messages.EspressifPreferencesPage_ToolsInstallationGrpTxt); - toolsInstallationGroup.setLayout(new GridLayout(2, false)); + toolsInstallationGroup.setLayout(new GridLayout(3, false)); Label githubAssetsLabel = new Label(toolsInstallationGroup, SWT.NONE); githubAssetsLabel.setText(Messages.EspressifPreferencesPage_ToolsInstallationGitAssetUrlLabel); @@ -92,24 +96,51 @@ private void addToolsInstallationSettings(Composite mainComposite) Label pythonWheelsLabel = new Label(toolsInstallationGroup, SWT.NONE); pythonWheelsLabel.setText(Messages.EspressifPreferencesPage_ToolsInstallationPythonPyWheelUrlLabel); pythonWheelText = new Text(toolsInstallationGroup, SWT.SINGLE | SWT.NONE); - - GridData gitTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + + GridData gitTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); gitTextGridData.widthHint = 200; - GridData pythonTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + GridData pythonTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); pythonTextGridData.widthHint = 200; gitAssetsText.setLayoutData(gitTextGridData); pythonWheelText.setLayoutData(pythonTextGridData); + Label idfToolsPathLabel = new Label(toolsInstallationGroup, SWT.NONE); + idfToolsPathLabel.setText(Messages.EspressifPreferencesPage_EspIdfToolsInstallationDirectoryLabel); + idfToolsPathText = new Text(toolsInstallationGroup, SWT.SINGLE | SWT.NONE); + GridData idfToolsPathTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + idfToolsPathTextGridData.widthHint = 200; + idfToolsPathText.setLayoutData(idfToolsPathTextGridData); + // Add browse button + Button browseButtonIdfToolsPath = new Button(toolsInstallationGroup, SWT.PUSH); + browseButtonIdfToolsPath.setText(Messages.EspressifPreferencesPage_DirectorySelectionIDFToolsPathBrowseButton); + browseButtonIdfToolsPath.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + DirectoryDialog dialog = new DirectoryDialog(mainComposite.getShell()); + dialog.setText(Messages.EspressifPreferencesPage_DirectorySelectionIDFToolsPathTitle); + dialog.setMessage(Messages.EspressifPreferencesPage_DirectorySelectionIDFToolsPathMessage); + String dir = dialog.open(); + if (dir != null) { + idfToolsPathText.setText(dir); + } + } + }); + String gitUrl = getPreferenceStore().getString(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS); String pyWheelUrl = getPreferenceStore().getString(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL); + String idfToolsPath = getPreferenceStore().getString(IDFCorePreferenceConstants.IDF_TOOLS_PATH); gitUrl = StringUtil.isEmpty(gitUrl) ? getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS) : gitUrl; pyWheelUrl = StringUtil.isEmpty(pyWheelUrl) ? getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL) : pyWheelUrl; + idfToolsPath = StringUtil.isEmpty(idfToolsPath) + ? getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.IDF_TOOLS_PATH) + : idfToolsPath; gitAssetsText.setText(gitUrl); pythonWheelText.setText(pyWheelUrl); + idfToolsPathText.setText(idfToolsPath); } private void addBuildSettings(Composite mainComposite) @@ -214,6 +245,8 @@ public boolean performOk() getPreferenceStore().setValue(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS, gitAssetsText.getText()); getPreferenceStore().setValue(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL, pythonWheelText.getText()); + + getPreferenceStore().setValue(IDFCorePreferenceConstants.IDF_TOOLS_PATH, idfToolsPathText.getText()); } catch (Exception e) { @@ -237,6 +270,7 @@ protected void performDefaults() .setSelection(getPreferenceStore().getBoolean(IDFCorePreferenceConstants.HIDE_ERRORS_IDF_COMPONENTS)); gitAssetsText.setText(getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS)); pythonWheelText.setText(getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL)); + idfToolsPathText.setText(getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.IDF_TOOLS_PATH)); } private void initializeDefaults() @@ -253,5 +287,6 @@ private void initializeDefaults() getPreferenceStore().setDefault(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS, IDFCorePreferenceConstants.IDF_GITHUB_ASSETS_DEFAULT); getPreferenceStore().setDefault(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL, IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL_DEFAULT); + getPreferenceStore().setDefault(IDFCorePreferenceConstants.IDF_TOOLS_PATH, IDFCorePreferenceConstants.IDF_TOOLS_PATH_DEFAULT); } } diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java index 5d81438b1..3392d4fc2 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java @@ -21,6 +21,10 @@ public class Messages extends NLS public static String EspressifPreferencesPage_ToolsInstallationGrpTxt; public static String EspressifPreferencesPage_ToolsInstallationGitAssetUrlLabel; public static String EspressifPreferencesPage_ToolsInstallationPythonPyWheelUrlLabel; + public static String EspressifPreferencesPage_EspIdfToolsInstallationDirectoryLabel; + public static String EspressifPreferencesPage_DirectorySelectionIDFToolsPathMessage; + public static String EspressifPreferencesPage_DirectorySelectionIDFToolsPathTitle; + public static String EspressifPreferencesPage_DirectorySelectionIDFToolsPathBrowseButton; static { diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties index a90e3fc62..184535bec 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties @@ -13,3 +13,7 @@ SerialMonitorPage_GroupHeading=Serial Monitor Setting EspressifPreferencesPage_ToolsInstallationGrpTxt=Tools Installation EspressifPreferencesPage_ToolsInstallationGitAssetUrlLabel=Mirror for GIT (IDF_GITHUB_ASSETS) EspressifPreferencesPage_ToolsInstallationPythonPyWheelUrlLabel=Mirror for python wheels (PIP_EXTRA_INDEX_URL) +EspressifPreferencesPage_EspIdfToolsInstallationDirectoryLabel=ESP-IDF tools installation directory (IDF_TOOLS_PATH) +EspressifPreferencesPage_DirectorySelectionIDFToolsPathTitle=Select IDF Tools Path +EspressifPreferencesPage_DirectorySelectionIDFToolsPathMessage=Select the directory for IDF Tools installation: +EspressifPreferencesPage_DirectorySelectionIDFToolsPathBrowseButton=Browse \ No newline at end of file diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java index 0856758c8..59f798d42 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java @@ -166,7 +166,7 @@ protected IStatus runProcess(IFile file, List arguments) throws Exceptio ProcessBuilderFactory processRunner = new ProcessBuilderFactory(); try { - return processRunner.runInBackground(arguments, Path.ROOT, System.getenv()); + return processRunner.runInBackground(arguments, Path.ROOT, IDFUtil.getSystemEnv()); } catch (Exception e1) { diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java index 52acd16b8..98c285809 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java @@ -138,7 +138,7 @@ protected void processExportCmdOutput(final String exportCmdOp) protected String replacePathVariable(String value) { // Get system PATH - Map systemEnv = new HashMap<>(System.getenv()); + Map systemEnv = new HashMap<>(IDFUtil.getSystemEnv()); String pathEntry = systemEnv.get("PATH"); //$NON-NLS-1$ if (pathEntry == null) { @@ -207,7 +207,7 @@ protected IStatus handleWebSocketClientInstall() } Logger.log(cmdMsg); - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); Logger.log(environment.toString()); IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, environment); @@ -348,7 +348,7 @@ protected IStatus runCommandIdfPyInIdfEnv(List arguments, MessageConsole console.println(cmdMsg); Logger.log(cmdMsg); - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); Logger.log(environment.toString()); environment.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ loadIdfPathWithSystemPath(environment); @@ -468,7 +468,7 @@ protected IStatus runCommand(List arguments, MessageConsoleStream consol console.println(cmdMsg); Logger.log(cmdMsg); - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); Logger.log(environment.toString()); environment.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ environment.put("IDF_GITHUB_ASSETS", //$NON-NLS-1$ diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tracing/AppLvlTracingDialog.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tracing/AppLvlTracingDialog.java index 1cd6fc8ad..b9ee9d677 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tracing/AppLvlTracingDialog.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tracing/AppLvlTracingDialog.java @@ -298,7 +298,7 @@ private void runTraceCommand() try { List arguments = new ArrayList(Arrays.asList(parseCommandTxt.getText().split(" "))); //$NON-NLS-1$ - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); IStatus status = processRunner.runInBackground(arguments, Path.ROOT, environment); if (status == null) { diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java index 454499415..6f9da3cce 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java @@ -143,7 +143,7 @@ protected IStatus runCommand(List arguments, MessageConsoleStream consol console.println(cmdMsg); Logger.log(cmdMsg); - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); Logger.log(environment.toString()); environment.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java index bc8f6264f..65dde2705 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java @@ -14,11 +14,13 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.console.MessageConsoleStream; import com.espressif.idf.core.IDFConstants; import com.espressif.idf.core.IDFCorePlugin; +import com.espressif.idf.core.IDFCorePreferenceConstants; import com.espressif.idf.core.IDFEnvironmentVariables; import com.espressif.idf.core.ProcessBuilderFactory; import com.espressif.idf.core.logging.Logger; @@ -46,7 +48,7 @@ public IStatus runToolsExportAndProcessOutput(final String pythonExePath, final final String cmd = Messages.AbstractToolsHandler_ExecutingMsg + " " + getCommandString(arguments); //$NON-NLS-1$ log(cmd, console); - final Map environment = new HashMap<>(System.getenv()); + final Map environment = new HashMap<>(IDFUtil.getSystemEnv()); if (gitExePath != null) { addGitToEnvironment(environment, gitExePath); @@ -88,7 +90,7 @@ public IStatus getToolsExportOutput(final String pythonExePath, final String git final String cmd = Messages.AbstractToolsHandler_ExecutingMsg + " " + getCommandString(arguments); //$NON-NLS-1$ log(cmd, console); - final Map environment = new HashMap<>(System.getenv()); + final Map environment = new HashMap<>(IDFUtil.getSystemEnv()); if (gitExePath != null) { addGitToEnvironment(environment, gitExePath); @@ -126,11 +128,12 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath, final String cmd = Messages.AbstractToolsHandler_ExecutingMsg + " " + getCommandString(arguments); //$NON-NLS-1$ log(cmd, console); - final Map environment = new HashMap<>(System.getenv()); + final Map environment = new HashMap<>(IDFUtil.getSystemEnv()); if (gitExePath != null) { addGitToEnvironment(environment, gitExePath); } + final ProcessBuilderFactory processRunner = new ProcessBuilderFactory(); try { @@ -225,7 +228,7 @@ private void processExportCmdOutput(final String exportCmdOp, final String gitEx private String replacePathVariable(String value) { // Get system PATH - Map systemEnv = new HashMap<>(System.getenv()); + Map systemEnv = new HashMap<>(IDFUtil.getSystemEnv()); String pathEntry = systemEnv.get("PATH"); //$NON-NLS-1$ if (pathEntry == null) { diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/InstallToolsHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/InstallToolsHandler.java index 3d47e530a..15ec76edf 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/InstallToolsHandler.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/InstallToolsHandler.java @@ -247,7 +247,7 @@ public IStatus handleWebSocketClientInstall() } Logger.log(cmdMsg); - Map environment = new HashMap<>(System.getenv()); + Map environment = new HashMap<>(IDFUtil.getSystemEnv()); Logger.log(environment.toString()); IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, environment);