Skip to content
Draft
Show file tree
Hide file tree
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 @@ -151,6 +151,9 @@ default IBinary[] getBuildOutput() throws CoreException {
* @param env
* build environment
* @since 6.1
* @implNote Ensure you pass a new non-empty map containing the base environment
* as this method modifies the passed in map adding the ICBuildConfiguration specific
* overrides, such as applying the project's build environment.
*/
default void setBuildEnvironment(Map<String, String> env) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand Down Expand Up @@ -76,10 +77,20 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
ICBuildConfiguration buildConfig = getBuildConfiguration(configuration, mode, target, monitor);

Map<String, String> buildEnv = new HashMap<>();
buildConfig.setBuildEnvironment(buildEnv);
Map<String, String> systemEnv = new HashMap<>();
Properties environmentVariables = EnvironmentReader.getEnvVars();
for (String key : environmentVariables.stringPropertyNames()) {
String value = environmentVariables.getProperty(key);
systemEnv.put(key, value);
}

var before = new HashMap<>(systemEnv);
buildConfig.setBuildEnvironment(systemEnv);

before.forEach((k, v) -> systemEnv.remove(k, v));

Properties envProps = new Properties();
envProps.putAll(buildEnv);
envProps.putAll(systemEnv);
gdbLaunch.setInitialEnvironment(envProps);

String debugger = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
Expand Down
Loading