mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 530673 Fix issue with CMake and changing toolchains.
Cleaned up add and remove of toolchain files, handling of when a toolchain changes for a config, and the launch bar tracker to be more accurate with toolchains. Change-Id: I1a1efdf08a5f47058552c85404fe8d602d158e73
This commit is contained in:
parent
e8f619c344
commit
5b29b5b5d8
5 changed files with 63 additions and 18 deletions
|
@ -81,6 +81,10 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
public ICMakeToolChainFile getToolChainFile() {
|
||||
return toolChainFile;
|
||||
}
|
||||
|
||||
private void saveToolChainFile() {
|
||||
Preferences settings = getSettings();
|
||||
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
|
||||
|
|
|
@ -37,7 +37,8 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
|||
}
|
||||
|
||||
@Override
|
||||
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
|
||||
public synchronized ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name)
|
||||
throws CoreException {
|
||||
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
|
||||
IToolChain toolChain = null;
|
||||
|
||||
|
@ -66,7 +67,20 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
|||
return null;
|
||||
}
|
||||
} else {
|
||||
return new CMakeBuildConfiguration(config, name);
|
||||
CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, name);
|
||||
ICMakeToolChainFile tcFile = cmakeConfig.getToolChainFile();
|
||||
IToolChain toolChain = cmakeConfig.getToolChain();
|
||||
if (toolChain == null || tcFile == null) {
|
||||
// config not complete?
|
||||
return null;
|
||||
}
|
||||
if (!toolChain.equals(tcFile.getToolChain())) {
|
||||
// toolchain changed
|
||||
return new CMakeBuildConfiguration(config, name, tcFile.getToolChain(), tcFile,
|
||||
cmakeConfig.getLaunchMode());
|
||||
} else {
|
||||
return cmakeConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ CMakeBuildConfiguration_BuildingIn=Building in: %s\n
|
|||
CMakeBuildConfiguration_BuildingComplete=Build complete: %s\n
|
||||
CMakeBuildConfiguration_Cleaning=Cleaning %s
|
||||
CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean.
|
||||
CMakeBuildConfiguration_NoToolchainFile=No toolchain file found for this target.
|
||||
CMakeBuildConfiguration_NoToolchainFile=No CMake toolchain file found for this target.
|
||||
CMakeBuildConfiguration_ProcCompCmds=Processing compile commands %s
|
||||
CMakeBuildConfiguration_ProcCompJson=Processing compile_commands.json
|
||||
|
|
|
@ -100,11 +100,11 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
|
|||
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
||||
if (dialog.open() == Window.OK) {
|
||||
ICMakeToolChainFile file = wizard.getNewFile();
|
||||
if (filesToRemove.containsKey(file.getPath())) {
|
||||
filesToRemove.remove(file.getPath());
|
||||
} else {
|
||||
filesToAdd.put(file.getPath(), file);
|
||||
ICMakeToolChainFile oldFile = manager.getToolChainFile(file.getPath());
|
||||
if (oldFile != null) {
|
||||
filesToRemove.put(oldFile.getPath(), oldFile);
|
||||
}
|
||||
filesToAdd.put(file.getPath(), file);
|
||||
updateTable();
|
||||
}
|
||||
}
|
||||
|
@ -162,27 +162,27 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
|
|||
files.put(file.getPath(), file);
|
||||
}
|
||||
|
||||
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
||||
files.put(file.getPath(), file);
|
||||
}
|
||||
|
||||
for (ICMakeToolChainFile file : filesToRemove.values()) {
|
||||
files.remove(file.getPath());
|
||||
}
|
||||
|
||||
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
||||
files.put(file.getPath(), file);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
||||
manager.addToolChainFile(file);
|
||||
}
|
||||
|
||||
for (ICMakeToolChainFile file : filesToRemove.values()) {
|
||||
manager.removeToolChainFile(file);
|
||||
}
|
||||
|
||||
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
||||
manager.addToolChainFile(file);
|
||||
}
|
||||
|
||||
filesToAdd.clear();
|
||||
filesToRemove.clear();
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.build.IToolChainManager;
|
|||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -95,11 +96,37 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
|
|||
properties.putAll(target.getAttributes());
|
||||
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
|
||||
if (!tcs.isEmpty()) {
|
||||
IToolChain toolChain = tcs.iterator().next();
|
||||
ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
|
||||
mode.getIdentifier(), monitor);
|
||||
ICBuildConfiguration buildConfig = null;
|
||||
|
||||
// First, see if any existing non default build configs match
|
||||
configs: for (IBuildConfiguration config : finalProject.getBuildConfigs()) {
|
||||
if (!config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
|
||||
ICBuildConfiguration testConfig = configManager.getBuildConfiguration(config);
|
||||
if (testConfig != null) {
|
||||
for (IToolChain tc : tcs) {
|
||||
if (testConfig.getToolChain().equals(tc)) {
|
||||
buildConfig = testConfig;
|
||||
break configs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buildConfig == null) {
|
||||
for (IToolChain tc : tcs) {
|
||||
IToolChain toolChain = tcs.iterator().next();
|
||||
buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
|
||||
mode.getIdentifier(), monitor);
|
||||
if (buildConfig != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buildConfig != null
|
||||
&& !buildConfig.getBuildConfiguration().equals(finalProject.getActiveBuildConfig())) {
|
||||
// set it as active
|
||||
IProjectDescription desc = finalProject.getDescription();
|
||||
desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
|
||||
finalProject.setDescription(desc, monitor);
|
||||
|
|
Loading…
Add table
Reference in a new issue