mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Make launchMode a core thing and add Debug for CMake configs.
Change-Id: Ie431824dddda07cd6985e5b644970eb525280577
This commit is contained in:
parent
0868cf82ee
commit
fa84dad370
4 changed files with 63 additions and 17 deletions
|
@ -60,12 +60,12 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
}
|
||||
|
||||
public CMakeBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
|
||||
this(config, name, toolChain, null);
|
||||
this(config, name, toolChain, null, "run"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public CMakeBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain,
|
||||
ICMakeToolChainFile toolChainFile) {
|
||||
super(config, name, toolChain);
|
||||
ICMakeToolChainFile toolChainFile, String launchMode) {
|
||||
super(config, name, toolChain, launchMode);
|
||||
this.toolChainFile = toolChainFile;
|
||||
|
||||
if (toolChainFile != null) {
|
||||
|
@ -120,6 +120,13 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
command.add("-DCMAKE_TOOLCHAIN_FILE=" + toolChainFile.getPath().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
switch (getLaunchMode()) {
|
||||
// TODO what to do with other modes
|
||||
case "debug": //$NON-NLS-1$
|
||||
command.add("-DCMAKE_BUILD_TYPE=Debug"); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
|
||||
command.add("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"); //$NON-NLS-1$
|
||||
command.add(new File(project.getLocationURI()).getAbsolutePath());
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
|||
public static final String ID = "org.eclipse.cdt.cmake.core.provider"; //$NON-NLS-1$
|
||||
|
||||
private ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class);
|
||||
private IToolChainManager tcManager = Activator.getService(IToolChainManager.class);
|
||||
private ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class);
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +78,8 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
|||
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
|
||||
if (cconfig != null) {
|
||||
CMakeBuildConfiguration cmakeConfig = cconfig.getAdapter(CMakeBuildConfiguration.class);
|
||||
if (cmakeConfig != null && cmakeConfig.getToolChain().equals(toolChain)) {
|
||||
if (cmakeConfig != null && cmakeConfig.getToolChain().equals(toolChain)
|
||||
&& launchMode.equals(cmakeConfig.getLaunchMode())) {
|
||||
return cconfig;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,8 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
|||
// create config
|
||||
String configName = "cmake." + launchMode + '.' + toolChain.getId(); //$NON-NLS-1$
|
||||
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, monitor);
|
||||
CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, configName, toolChain, file);
|
||||
CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, configName, toolChain, file,
|
||||
launchMode);
|
||||
configManager.addBuildConfiguration(config, cmakeConfig);
|
||||
return cmakeConfig;
|
||||
}
|
||||
|
|
|
@ -92,12 +92,14 @@ public abstract class CBuildConfiguration extends PlatformObject
|
|||
private static final String TOOLCHAIN_TYPE = "cdt.toolChain.type"; //$NON-NLS-1$
|
||||
private static final String TOOLCHAIN_ID = "cdt.toolChain.id"; //$NON-NLS-1$
|
||||
private static final String TOOLCHAIN_VERSION = "cdt.toolChain.version"; //$NON-NLS-1$
|
||||
private static final String LAUNCH_MODE = "cdt.launchMode"; //$NON-NLS-1$
|
||||
|
||||
private static final List<String> DEFAULT_COMMAND = new ArrayList<>(0);
|
||||
|
||||
private final String name;
|
||||
private final IBuildConfiguration config;
|
||||
private final IToolChain toolChain;
|
||||
private String launchMode;
|
||||
|
||||
private final Map<IResource, List<IScannerInfoChangeListener>> scannerInfoListeners = new HashMap<>();
|
||||
private ScannerInfoCache scannerInfoCache;
|
||||
|
@ -127,12 +129,23 @@ public abstract class CBuildConfiguration extends PlatformObject
|
|||
}
|
||||
}
|
||||
toolChain = tc;
|
||||
|
||||
launchMode = settings.get(LAUNCH_MODE, null); // $NON-NLS-1$
|
||||
}
|
||||
|
||||
protected CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
|
||||
this(config, name, toolChain, "run"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.2
|
||||
*/
|
||||
protected CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain,
|
||||
String launchMode) {
|
||||
this.config = config;
|
||||
this.name = name;
|
||||
this.toolChain = toolChain;
|
||||
this.launchMode = launchMode;
|
||||
|
||||
Preferences settings = getSettings();
|
||||
settings.put(TOOLCHAIN_TYPE, toolChain.getProvider().getId());
|
||||
|
@ -158,6 +171,27 @@ public abstract class CBuildConfiguration extends PlatformObject
|
|||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.2
|
||||
*/
|
||||
public String getLaunchMode() {
|
||||
return launchMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.2
|
||||
*/
|
||||
protected void setLaunchMode(String launchMode) {
|
||||
this.launchMode = launchMode;
|
||||
Preferences settings = getSettings();
|
||||
settings.put(LAUNCH_MODE, launchMode);
|
||||
try {
|
||||
settings.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
return config.getProject();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
|||
private static final String QTINSTALL_SPEC = "cdt.qt.install.spec"; //$NON-NLS-1$
|
||||
private static final String LAUNCH_MODE = "cdt.qt.launchMode"; //$NON-NLS-1$
|
||||
|
||||
private final String launchMode;
|
||||
private final String qtInstallSpec;
|
||||
private IQtInstall qtInstall;
|
||||
private Map<String, String> properties;
|
||||
|
@ -89,15 +88,23 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
|||
Activator.error(String.format("Qt Install for build configuration %s not found.", name)));
|
||||
}
|
||||
|
||||
launchMode = settings.get(LAUNCH_MODE, null); // $NON-NLS-1$
|
||||
String oldLaunchMode = settings.get(LAUNCH_MODE, null);
|
||||
if (oldLaunchMode != null) {
|
||||
setLaunchMode(oldLaunchMode);
|
||||
settings.remove(LAUNCH_MODE);
|
||||
try {
|
||||
settings.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain, IQtInstall qtInstall,
|
||||
String launchMode) throws CoreException {
|
||||
super(config, name, toolChain);
|
||||
super(config, name, toolChain, launchMode);
|
||||
this.qtInstall = qtInstall;
|
||||
this.qtInstallSpec = qtInstall.getSpec();
|
||||
this.launchMode = launchMode;
|
||||
|
||||
IQtInstallManager manager = Activator.getService(IQtInstallManager.class);
|
||||
manager.addListener(this);
|
||||
|
@ -135,11 +142,6 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchMode() {
|
||||
return launchMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getQmakeCommand() {
|
||||
return getQtInstall().getQmakePath();
|
||||
|
@ -147,6 +149,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
|||
|
||||
@Override
|
||||
public String[] getQmakeConfig() {
|
||||
String launchMode = getLaunchMode();
|
||||
if (launchMode != null) {
|
||||
switch (launchMode) {
|
||||
case "run": //$NON-NLS-1$
|
||||
|
@ -185,7 +188,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
|||
case Platform.OS_WIN32:
|
||||
return getBuildDirectory().resolve(projectName + ".exe"); //$NON-NLS-1$
|
||||
case Platform.OS_LINUX:
|
||||
return getBuildDirectory().resolve(projectName); //$NON-NLS-1$
|
||||
return getBuildDirectory().resolve(projectName);
|
||||
default:
|
||||
Path releaseFolder = getBuildDirectory().resolve("release"); //$NON-NLS-1$
|
||||
return releaseFolder.resolve(projectName);
|
||||
|
@ -344,7 +347,8 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
|||
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||
getToolChain().getErrorParserIds())) {
|
||||
// run make
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString(), "all").directory(buildDir.toFile());
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString(), "all") //$NON-NLS-1$
|
||||
.directory(buildDir.toFile());
|
||||
setBuildEnvironment(processBuilder.environment());
|
||||
Process process = processBuilder.start();
|
||||
outStream.write(makeCommand.toString() + '\n');
|
||||
|
|
Loading…
Add table
Reference in a new issue