From 2c4921bca0925a343ba88f5fec731d6a463fd55e Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 10 May 2016 12:45:02 -0400 Subject: Add binary parsers to new build system. Clean up some toolchain stuff. new build configs now support binary parsers which are by default driven from the toolchains. Ran into problem with new versions of toolchains. Added versioning info to toolchains to take that into account. Change-Id: Ie1fb7755e84239b525dca0ae11759027a0b44574 --- .../cdt/internal/core/model/CModelManager.java | 62 ++++++++++++++++------ 1 file changed, 47 insertions(+), 15 deletions(-) (limited to 'core/org.eclipse.cdt.core/model') 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 400ae89cdbd..b9e110c6499 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 @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCorePlugin; @@ -34,6 +35,7 @@ import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; +import org.eclipse.cdt.core.build.ICBuildConfiguration; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeEvent; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeListener; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; @@ -68,6 +70,7 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -604,22 +607,51 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang public BinaryParserConfig[] getBinaryParser(IProject project) { BinaryParserConfig[] parsers = binaryParsersMap.get(project); if (parsers == null) { - ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project, false); - if (desc != null) { - ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration(); - if (cfgDesc != null) { - ICConfigExtensionReference[] refs = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID); - if (refs.length > 0) { - ArrayList list = new ArrayList<>(refs.length); - for (ICConfigExtensionReference ref : refs) { - BinaryParserConfig config = new BinaryParserConfig(ref); - list.add(config); + try { + // Check for new style build configs first + Set parserIds = new HashSet<>(); + for (IBuildConfiguration config : project.getBuildConfigs()) { + if (!IBuildConfiguration.DEFAULT_CONFIG_NAME.equals(config.getName())) { + ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class); + if (cconfig != null) { + parserIds.add(cconfig.getBinaryParserId()); + } + } + } + if (!parserIds.isEmpty()) { + String[] ids = parserIds.toArray(new String[parserIds.size()]); + parsers = new BinaryParserConfig[parserIds.size()]; + for (int i = 0; i < parsers.length; ++i) { + String id = ids[i]; + IBinaryParser parser = CCorePlugin.getDefault().getBinaryParser(id); + if (parser != null) { + parsers[i] = new BinaryParserConfig(parser, id); + } + } + } + } catch (CoreException e) { + CCorePlugin.log(e); + parsers = null; + } + + if (parsers == null) { + ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project, false); + if (desc != null) { + ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration(); + if (cfgDesc != null) { + ICConfigExtensionReference[] refs = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID); + if (refs.length > 0) { + ArrayList list = new ArrayList<>(refs.length); + for (ICConfigExtensionReference ref : refs) { + BinaryParserConfig config = new BinaryParserConfig(ref); + list.add(config); + } + parsers = new BinaryParserConfig[list.size()]; + list.toArray(parsers); + } else { + // no parser configured + parsers = new BinaryParserConfig[0]; } - parsers = new BinaryParserConfig[list.size()]; - list.toArray(parsers); - } else { - // no parser configured - parsers = new BinaryParserConfig[0]; } } } -- cgit v1.2.3