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() {
|
private void saveToolChainFile() {
|
||||||
Preferences settings = getSettings();
|
Preferences settings = getSettings();
|
||||||
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
|
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)) {
|
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
|
||||||
IToolChain toolChain = null;
|
IToolChain toolChain = null;
|
||||||
|
|
||||||
|
@ -66,7 +67,20 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} 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_BuildingComplete=Build complete: %s\n
|
||||||
CMakeBuildConfiguration_Cleaning=Cleaning %s
|
CMakeBuildConfiguration_Cleaning=Cleaning %s
|
||||||
CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean.
|
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_ProcCompCmds=Processing compile commands %s
|
||||||
CMakeBuildConfiguration_ProcCompJson=Processing compile_commands.json
|
CMakeBuildConfiguration_ProcCompJson=Processing compile_commands.json
|
||||||
|
|
|
@ -100,11 +100,11 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
|
||||||
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
||||||
if (dialog.open() == Window.OK) {
|
if (dialog.open() == Window.OK) {
|
||||||
ICMakeToolChainFile file = wizard.getNewFile();
|
ICMakeToolChainFile file = wizard.getNewFile();
|
||||||
if (filesToRemove.containsKey(file.getPath())) {
|
ICMakeToolChainFile oldFile = manager.getToolChainFile(file.getPath());
|
||||||
filesToRemove.remove(file.getPath());
|
if (oldFile != null) {
|
||||||
} else {
|
filesToRemove.put(oldFile.getPath(), oldFile);
|
||||||
filesToAdd.put(file.getPath(), file);
|
|
||||||
}
|
}
|
||||||
|
filesToAdd.put(file.getPath(), file);
|
||||||
updateTable();
|
updateTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,27 +162,27 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
|
||||||
files.put(file.getPath(), file);
|
files.put(file.getPath(), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
|
||||||
files.put(file.getPath(), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ICMakeToolChainFile file : filesToRemove.values()) {
|
for (ICMakeToolChainFile file : filesToRemove.values()) {
|
||||||
files.remove(file.getPath());
|
files.remove(file.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
||||||
|
files.put(file.getPath(), file);
|
||||||
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
|
||||||
manager.addToolChainFile(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ICMakeToolChainFile file : filesToRemove.values()) {
|
for (ICMakeToolChainFile file : filesToRemove.values()) {
|
||||||
manager.removeToolChainFile(file);
|
manager.removeToolChainFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ICMakeToolChainFile file : filesToAdd.values()) {
|
||||||
|
manager.addToolChainFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
filesToAdd.clear();
|
filesToAdd.clear();
|
||||||
filesToRemove.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.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -95,11 +96,37 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
|
||||||
properties.putAll(target.getAttributes());
|
properties.putAll(target.getAttributes());
|
||||||
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
|
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
|
||||||
if (!tcs.isEmpty()) {
|
if (!tcs.isEmpty()) {
|
||||||
IToolChain toolChain = tcs.iterator().next();
|
ICBuildConfiguration buildConfig = null;
|
||||||
ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
|
|
||||||
mode.getIdentifier(), monitor);
|
// 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
|
if (buildConfig != null
|
||||||
&& !buildConfig.getBuildConfiguration().equals(finalProject.getActiveBuildConfig())) {
|
&& !buildConfig.getBuildConfiguration().equals(finalProject.getActiveBuildConfig())) {
|
||||||
|
// set it as active
|
||||||
IProjectDescription desc = finalProject.getDescription();
|
IProjectDescription desc = finalProject.getDescription();
|
||||||
desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
|
desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
|
||||||
finalProject.setDescription(desc, monitor);
|
finalProject.setDescription(desc, monitor);
|
||||||
|
|
Loading…
Add table
Reference in a new issue