diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java index 3be804388aa..e9ec4ddbe2a 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 QNX Software Systems and others. + * Copyright (c) 2016, 2019 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -126,12 +126,17 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv } } String name = configName.toString(); - int i = 0; - while (configManager.hasConfiguration(this, project, name)) { - name = configName.toString() + '.' + (++i); + IBuildConfiguration config = null; + // reuse any IBuildConfiguration with the same name for the project + // so adding the CBuildConfiguration will override the old one stored + // by the CBuildConfigurationManager + if (configManager.hasConfiguration(this, project, name)) { + config = project.getBuildConfig(this.getId() + '/' + name); + } + if (config == null) { + config = configManager.createBuildConfiguration(this, project, name, monitor); } - IBuildConfiguration config = configManager.createBuildConfiguration(this, project, name, monitor); CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, name, toolChain, file, launchMode); configManager.addBuildConfiguration(config, cmakeConfig); return cmakeConfig; diff --git a/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfigurationProvider.java b/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfigurationProvider.java index ae4f6087d1f..ae2a48d7780 100644 --- a/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfigurationProvider.java +++ b/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfigurationProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Intel Corporation and others. + * Copyright (c) 2017, 2019 Intel Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -111,12 +111,17 @@ public class AutotoolsBuildConfigurationProvider implements ICBuildConfiguration } } String name = configName.toString(); - int i = 0; - while (configManager.hasConfiguration(this, project, name)) { - name = configName.toString() + '.' + (++i); + IBuildConfiguration config = null; + // reuse any IBuildConfiguration with the same name for the project + // so adding the CBuildConfiguration will override the old one stored + // by the CBuildConfigurationManager + if (configManager.hasConfiguration(this, project, name)) { + config = project.getBuildConfig(this.getId() + '/' + name); + } + if (config == null) { + config = configManager.createBuildConfiguration(this, project, name, monitor); } - IBuildConfiguration config = configManager.createBuildConfiguration(this, project, name, monitor); AutotoolsBuildConfiguration autotoolsConfig = new AutotoolsBuildConfiguration(config, name, toolChain, launchMode); configManager.addBuildConfiguration(config, autotoolsConfig); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java index 1b12ceeb1d3..64c34e34c2d 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java @@ -95,12 +95,16 @@ public class MakefileBuildConfigurationProvider implements ICBuildConfigurationP } } String name = configName.toString(); - int i = 0; - while (configManager.hasConfiguration(this, project, name)) { - name = configName.toString() + '.' + (++i); + IBuildConfiguration config = null; + // reuse any IBuildConfiguration with the same name for the project + // so adding the CBuildConfiguration will override the old one stored + // by the CBuildConfigurationManager + if (configManager.hasConfiguration(this, project, name)) { + config = project.getBuildConfig(this.getId() + '/' + name); + } + if (config == null) { + config = configManager.createBuildConfiguration(this, project, name, monitor); } - - IBuildConfiguration config = configManager.createBuildConfiguration(this, project, name, monitor); StandardBuildConfiguration makeConfig = new StandardBuildConfiguration(config, name, toolChain, launchMode); configManager.addBuildConfiguration(config, makeConfig); return makeConfig; diff --git a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfigurationProvider.java b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfigurationProvider.java index b0e35455777..87959aa19b3 100644 --- a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfigurationProvider.java +++ b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfigurationProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2018 QNX Software Systems and others. + * Copyright (c) 2016, 2019 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -129,12 +129,17 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv } } String name = configName.toString(); - int i = 0; - while (configManager.hasConfiguration(this, project, name)) { - name = configName.toString() + '.' + (++i); + IBuildConfiguration config = null; + // reuse any IBuildConfiguration with the same name for the project + // so adding the CBuildConfiguration will override the old one stored + // by the CBuildConfigurationManager + if (configManager.hasConfiguration(this, project, name)) { + config = project.getBuildConfig(this.getId() + '/' + name); + } + if (config == null) { + config = configManager.createBuildConfiguration(this, project, name, monitor); } - IBuildConfiguration config = configManager.createBuildConfiguration(this, project, name, monitor); MesonBuildConfiguration mesonConfig = new MesonBuildConfiguration(config, name, toolChain, file, launchMode); configManager.addBuildConfiguration(config, mesonConfig); return mesonConfig;