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

Support arguments and working directory in launching Core Build proje… #821

Merged
merged 2 commits into from
Sep 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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.400.qualifier
Bundle-Version: 8.8.500.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.launch;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
import org.eclipse.cdt.utils.CommandLineUtil;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
Expand All @@ -38,7 +45,26 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
IBinary exeFile = getBinary(buildConfig);

try {
ProcessBuilder builder = new ProcessBuilder(Paths.get(exeFile.getLocationURI()).toString());
String args = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
if (args.length() != 0) {
args = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(args);
}

String[] arguments = CommandLineUtil.argumentsToArray(args);
List<String> command = new ArrayList<>(1 + arguments.length);
command.add(Paths.get(exeFile.getLocationURI()).toString());
command.addAll(Arrays.asList(arguments));

ProcessBuilder builder = new ProcessBuilder(command);

String workingDirectory = configuration
.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, ""); //$NON-NLS-1$
if (!workingDirectory.isBlank()) {
workingDirectory = VariablesPlugin.getDefault().getStringVariableManager()
.performStringSubstitution(workingDirectory);
builder.directory(new File(workingDirectory));
}

buildConfig.setBuildEnvironment(builder.environment());
Process process = builder.start();
DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment());
Expand Down
2 changes: 1 addition & 1 deletion launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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.400.qualifier
Bundle-Version: 10.4.500.qualifier
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.launch.internal.corebuild;

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;
Expand All @@ -22,8 +23,9 @@ public class LocalLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab mainTab = new CoreBuildMainTab();
ILaunchConfigurationTab buildTab = new CoreBuildTab();
ILaunchConfigurationTab argumentsTab = new CArgumentsTab();

setTabs(new ILaunchConfigurationTab[] { mainTab, buildTab });
setTabs(new ILaunchConfigurationTab[] { mainTab, buildTab, argumentsTab });
}

}
Loading