From b6d218a6524829af84c977d2e5cf948f5fa1b8a8 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Wed, 2 Nov 2016 14:30:27 -0400 Subject: [PATCH] Fix no binaries issue with Core Build. When a second config is added, the binary parsers wasn't getting reset so the new binary parser wasn't getting called. Also cleans up the reset to remove the close that happens. Not sure why it was needed so will keep an eye out for new bad behavior. Change-Id: I0b4cb628829b138e2ceb3f08833649b90255648c --- .../internal/core/model/CModelManager.java | 20 ++++++------------- .../cdt/core/build/CBuildConfiguration.java | 16 +++++++++++++++ .../build/CBuildConfigurationManager.java | 6 +++++- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index e3c90e9cfa4..8f9938389c6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -787,21 +787,13 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (project != null) { ICProject cproject = create(project); if (cproject != null) { - // Let the function remove the children - // but it has the side of effect of removing the CProject also - // so we have to recall create again. - try { - cproject.close(); - } catch (CModelException e) { - CCorePlugin.log(e); + if (binaryParsersMap.remove(project) != null) { + // Fired and ICElementDelta.PARSER_CHANGED + CElementDelta delta = new CElementDelta(getCModel()); + delta.binaryParserChanged(cproject); + registerCModelDelta(delta); + fire(ElementChangedEvent.POST_CHANGE); } - binaryParsersMap.remove(project); - - // Fired and ICElementDelta.PARSER_CHANGED - CElementDelta delta = new CElementDelta(getCModel()); - delta.binaryParserChanged(cproject); - registerCModelDelta(delta); - fire(ElementChangedEvent.POST_CHANGE); } } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java index ff4d69aad60..148f4d5bac6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java @@ -48,6 +48,8 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IncludeExportPatterns; import org.eclipse.cdt.core.resources.IConsole; +import org.eclipse.cdt.internal.core.model.BinaryRunner; +import org.eclipse.cdt.internal.core.model.CModelManager; import org.eclipse.cdt.internal.core.parser.ParserSettings2; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.resources.IBuildConfiguration; @@ -246,6 +248,20 @@ public abstract class CBuildConfiguration extends PlatformObject outputs.add(binary); } } + + if (outputs.isEmpty()) { + // Give the binary runner a kick and try again. + BinaryRunner runner = CModelManager.getDefault().getBinaryRunner(cproject); + runner.start(); + runner.waitIfRunning(); + + for (IBinary binary : binaries.getBinaries()) { + if (binary.isExecutable() && outputPath.isPrefixOf(binary.getPath())) { + outputs.add(binary); + } + } + } + return outputs.toArray(new IBinary[outputs.size()]); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java index ebe71c5b998..3a492c7b870 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java @@ -161,6 +161,9 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager, synchronized (configs) { configs.put(buildConfig, cConfig); } + + // reset the binary parsers + CModelManager.getDefault().resetBinaryParser(buildConfig.getProject()); } @Override @@ -193,7 +196,8 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager, config = provider.getCBuildConfiguration(buildConfig, configName); if (config != null) { configs.put(buildConfig, config); - // Also make sure we reset the binary parser cache for the new config + // Also make sure we reset the binary parser cache + // for the new config resetBinaryParser = true; } }