Support environment variables in Core Build projects for Local (#901)

Added an Environment tab to the Core Build launch configurations for
the Local target. Similar as the standard C/C++ Application launch
configurations for Managed Build.
This commit is contained in:
ewaterlander 2024-09-17 03:20:28 +02:00 committed by GitHub
parent cfe1db70b4
commit c51cecd75a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 4 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
Bundle-Version: 8.8.500.qualifier
Bundle-Version: 8.8.600.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -15,7 +15,9 @@ import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.model.IBinary;
@ -32,6 +34,7 @@ import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
@ -65,7 +68,15 @@ public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLaunchConfigDelega
builder.directory(new File(workingDirectory));
}
buildConfig.setBuildEnvironment(builder.environment());
Map<String, String> environment = builder.environment();
Map<String, String> launchEnvironment = configuration
.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap<>());
if (!configuration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true)) {
environment.clear();
}
environment.putAll(launchEnvironment);
buildConfig.setBuildEnvironment(environment);
Process process = builder.start();
DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment());
} catch (IOException e) {

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
Bundle-Version: 10.4.500.qualifier
Bundle-Version: 10.4.600.qualifier
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -14,6 +14,7 @@ import org.eclipse.cdt.launch.ui.CArgumentsTab;
import org.eclipse.cdt.launch.ui.corebuild.CoreBuildMainTab;
import org.eclipse.cdt.launch.ui.corebuild.CoreBuildTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
@ -24,8 +25,9 @@ public class LocalLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
ILaunchConfigurationTab mainTab = new CoreBuildMainTab();
ILaunchConfigurationTab buildTab = new CoreBuildTab();
ILaunchConfigurationTab argumentsTab = new CArgumentsTab();
ILaunchConfigurationTab environmentTab = new EnvironmentTab();
setTabs(new ILaunchConfigurationTab[] { mainTab, buildTab, argumentsTab });
setTabs(new ILaunchConfigurationTab[] { mainTab, buildTab, argumentsTab, environmentTab });
}
}