diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java index c10adce4907..27e40a598f2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java @@ -225,6 +225,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { provider.execute(); assertEquals(true, provider.isExecuted()); + assertEquals(null, provider.getSettingEntries(null, null, null)); } } @@ -307,7 +308,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // check entries { MockDetectorCloneable clone = provider.clone(); - clone.setSettingEntries(null, null, null, null); + List entries2 = new ArrayList(); + entries2.add(new CMacroEntry("MACRO2", "VALUE2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY)); + clone.setSettingEntries(null, null, null, entries2); assertFalse(provider.equals(clone)); } diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java index 870cc21e0c0..d8f3eab1379 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java @@ -14,16 +14,23 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage; +import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CMacroEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.internal.core.Cygwin; +import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin; import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; /** * Test cases to test GCC built-in specs detector. @@ -45,6 +52,20 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase { } } + /** + * Mock GCCBuiltinSpecsDetectorCygwin to gain access to protected methods. + */ + class MockGCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetectorCygwin { + @Override + public void startupForLanguage(String languageId) throws CoreException { + super.startupForLanguage(languageId); + } + @Override + public void shutdownForLanguage() { + super.shutdownForLanguage(); + } + } + @Override protected void setUp() throws Exception { super.setUp(); @@ -55,6 +76,21 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase { super.tearDown(); } + /** + * Helper method to fetch configuration descriptions. + */ + private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) { + CoreModel coreModel = CoreModel.getDefault(); + ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager(); + // project description + ICProjectDescription projectDescription = mngr.getProjectDescription(project); + assertNotNull(projectDescription); + assertEquals(1, projectDescription.getConfigurations().length); + // configuration description + ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations(); + return cfgDescriptions; + } + /** * Test expansion of variables in build command. */ @@ -365,4 +401,68 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase { assertEquals(1, entries.size()); } + /** + * Test parsing of include directives for Cygwin for global provider. + */ + public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception { + if (!Cygwin.isAvailable()) { + // Skip the test if Cygwin is not available. + return; + } + + String cygwinLocation = "/usr/include"; + String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation); + assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null); + + MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin(); + + detector.startup(null, null); + detector.startupForLanguage(null); + detector.processLine("#include <...> search starts here:"); + detector.processLine(" /usr/include"); + detector.processLine("End of search list."); + detector.shutdownForLanguage(); + detector.shutdown(); + + // check populated entries + List entries = detector.getSettingEntries(null, null, null); + assertEquals(new CIncludePathEntry(new Path(windowsLocation), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0)); + assertEquals(1, entries.size()); + } + + /** + * Test parsing of include directives for Cygwin for provider running for a configuration. + */ + public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception { + if (!Cygwin.isAvailable()) { + // Skip the test if Cygwin is not available. + return; + } + + String cygwinLocation = "/usr/include"; + String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation); + assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null); + + // Create model project and folders to test + String projectName = getName(); + IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); + ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); + ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + + MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin(); + + detector.startup(cfgDescription, null); + detector.startupForLanguage(null); + detector.processLine("#include <...> search starts here:"); + detector.processLine(" /usr/include"); + detector.processLine("End of search list."); + detector.shutdownForLanguage(); + detector.shutdown(); + + // check populated entries + List entries = detector.getSettingEntries(null, null, null); + assertEquals(new CIncludePathEntry(new Path(windowsLocation), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0)); + assertEquals(1, entries.size()); + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml index f808643a31b..5c198d3ad4f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml @@ -613,6 +613,14 @@ + + + + environmentMap = null; + protected List detectedSettingEntries = null; protected int collected = 0; - protected boolean isExecuted = false; + protected volatile boolean isExecuted = false; + private int envPathHash = 0; private BuildRunnerHelper buildRunnerHelper; private SDMarkerGenerator markerGenerator = new SDMarkerGenerator(); @@ -348,6 +358,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti mappedRootURI = null; buildDirURI = getBuildDirURI(mappedRootURI); + environmentMap = createEnvironmentMap(currentCfgDescription); } @Override @@ -358,18 +369,46 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti super.shutdown(); } + /** + * This method does 2 related things: + *
+ * 1. Validate environment, i.e. check that environment for running the command has not changed. + * If environment changed {@link #execute()} will rerun the command even if flag {@link #isExecuted} + * suggests that it was run already. + *
+ * 2. The relevant environment is cached here so the new one is validated against it at the next call. + * {@link #validateEnvironment()} will be called right before running the job to execute the command. + * + * @since 8.2 + */ + protected boolean validateEnvironment() { + String envPathValue = environmentMap.get(ENV_PATH); + int envPathValueHash = envPathValue != null ? envPathValue.hashCode() : 0; + if (envPathValueHash != envPathHash || envPathValueHash == 0) { + envPathHash = envPathValueHash; + return false; + } + return true; + } + /** * Execute provider's command which is expected to print built-in compiler options (specs) to build output. * The parser will parse output and generate language settings for corresponding resources. */ protected void execute() { - if (isExecuted) { + environmentMap = createEnvironmentMap(currentCfgDescription); + if (validateEnvironment() && isExecuted) { return; } WorkspaceJob job = new WorkspaceJob(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName")) { //$NON-NLS-1$ @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { + isExecuted = false; + if (!isEmpty()) { + clear(); + serializeLanguageSettings(currentCfgDescription); + } IStatus status; try { startup(currentCfgDescription, null); @@ -550,7 +589,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } } - String[] envp = getEnvp(); + String[] envp = toEnvp(environmentMap); // Using GMAKE_ERROR_PARSER_ID as it can handle generated error messages ErrorParserManager epm = new ErrorParserManager(currentProject, buildDirURI, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); @@ -592,8 +631,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti * @since 8.2 */ protected List getEnvironmentVariables() { - IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); - List vars = new ArrayList(Arrays.asList(mngr.getVariables(currentCfgDescription, true))); + if (envMngr == null) { + envMngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); + } + List vars = new ArrayList(Arrays.asList(envMngr.getVariables(currentCfgDescription, true))); // On POSIX (Linux, UNIX) systems reset language variables to default (English) // with UTF-8 encoding since GNU compilers can handle only UTF-8 characters. @@ -608,16 +649,23 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } /** - * Get array of environment variables in format "var=value". + * Create a handy map of environment variables. */ - private String[] getEnvp() { - EnvironmentCollector collector = new EnvironmentCollector(); - List vars = getEnvironmentVariables(); - collector.addVariables(vars.toArray(new IEnvironmentVariable[vars.size()])); + private Map createEnvironmentMap(ICConfigurationDescription cfgDescription) { + Map envMap = new HashMap(); + for (IEnvironmentVariable var : getEnvironmentVariables()) { + envMap.put(var.getName(), var.getValue()); + } + return envMap; + } + /** + * Convert map of environment variables to array in format "var=value". + */ + private String[] toEnvp(Map environmentMap) { Set envp = new HashSet(); - for (IEnvironmentVariable var : collector.getVariables()) { - envp.add(var.getName() + '=' + var.getValue()); + for (Entry var: environmentMap.entrySet()) { + envp.add(var.getKey() + '=' + var.getValue()); } return envp.toArray(new String[envp.size()]); } @@ -736,6 +784,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti public Element serializeAttributes(Element parentElement) { Element elementProvider = super.serializeAttributes(parentElement); elementProvider.setAttribute(ATTR_CONSOLE, Boolean.toString(isConsoleEnabled)); + if (envPathHash != 0) { + elementProvider.setAttribute(ATTR_ENV_HASH, Integer.toString(envPathHash)); + } return elementProvider; } @@ -747,6 +798,16 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti if (consoleValue != null) { isConsoleEnabled = Boolean.parseBoolean(consoleValue); } + + envPathHash = 0; + String envPathHashStr = XmlUtil.determineAttributeValue(providerNode, ATTR_ENV_HASH); + if (envPathHashStr != null) { + try { + envPathHash = Integer.parseInt(envPathHashStr); + } catch (Exception e) { + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Wrong integer format [" + envPathHashStr + "]", e)); //$NON-NLS-1$ //$NON-NLS-2$ + } + } } @Override @@ -774,6 +835,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti protected AbstractBuiltinSpecsDetector cloneShallow() throws CloneNotSupportedException { AbstractBuiltinSpecsDetector clone = (AbstractBuiltinSpecsDetector) super.cloneShallow(); clone.isExecuted = false; + clone.envMngr = null; + clone.environmentMap = null; + clone.envPathHash = 0; return clone; } @@ -783,6 +847,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti int result = super.hashCode(); result = prime * result + (isConsoleEnabled ? 1231 : 1237); result = prime * result + (isExecuted ? 1231 : 1237); + result = prime * result + envPathHash; return result; } @@ -792,13 +857,15 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti return true; if (!super.equals(obj)) return false; - if (!(obj instanceof AbstractBuiltinSpecsDetector)) + if (getClass() != obj.getClass()) return false; AbstractBuiltinSpecsDetector other = (AbstractBuiltinSpecsDetector) obj; if (isConsoleEnabled != other.isConsoleEnabled) return false; if (isExecuted != other.isExecuted) return false; + if (envPathHash != other.envPathHash) + return false; return true; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java index 9d8d5347644..f11ec08a8ea 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Andrew Gvozdev and others. + * Copyright (c) 2009, 2013 Andrew Gvozdev and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,6 +25,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.EFSExtensionProvider; import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; @@ -80,6 +81,37 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett protected String parsedResourceName = null; protected boolean isResolvingPaths = true; + /** @since 8.2 */ + protected EFSExtensionProvider efsProvider = null; + + private static final EFSExtensionProvider efsProviderDefault = new EFSExtensionProvider() { + final EFSExtensionManager efsManager = EFSExtensionManager.getDefault(); + @Override + public String getPathFromURI(URI locationURI) { + return efsManager.getPathFromURI(locationURI); + } + @Override + public URI getLinkedURI(URI locationURI) { + return efsManager.getLinkedURI(locationURI); + } + @Override + public URI createNewURIFromPath(URI locationOnSameFilesystem, String path) { + return efsManager.createNewURIFromPath(locationOnSameFilesystem, path); + } + @Override + public String getMappedPath(URI locationURI) { + return efsManager.getMappedPath(locationURI); + } + @Override + public boolean isVirtual(URI locationURI) { + return efsManager.isVirtual(locationURI); + } + @Override + public URI append(URI baseURI, String extension) { + return efsManager.append(baseURI, extension); + } + }; + /** * Abstract class defining common functionality for option parsers. * The purpose of this parser is to parse a portion of string representing @@ -373,6 +405,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett this.currentCfgDescription = cfgDescription; this.currentProject = cfgDescription != null ? cfgDescription.getProjectDescription().getProject() : null; this.cwdTracker = cwdTracker; + this.efsProvider = getEFSProvider(); } @Override @@ -429,7 +462,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett if (isResolvingPaths && (optionParser.isForFile() || optionParser.isForFolder())) { URI baseURI = mappedRootURI; if (buildDirURI != null && !new Path(optionParser.parsedName).isAbsolute()) { - baseURI = EFSExtensionManager.getDefault().append(mappedRootURI, buildDirURI.getPath()); + baseURI = efsProvider.append(mappedRootURI, buildDirURI.getPath()); } entry = createResolvedPathEntry(optionParser, optionParser.parsedName, 0, baseURI); } else { @@ -494,7 +527,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } } // this creates URI with schema and other components from resourceURI but path as mappedRoot - URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(resourceURI, mappedRoot); + URI uri = efsProvider.createNewURIFromPath(resourceURI, mappedRoot); return uri; } @@ -513,9 +546,9 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett if (currentResource != null && parsedResourceName != null && !new Path(parsedResourceName).isAbsolute()) { cwdURI = findBaseLocationURI(currentResource.getLocationURI(), parsedResourceName); } - String cwdPath = cwdURI != null ? EFSExtensionManager.getDefault().getPathFromURI(cwdURI) : null; + String cwdPath = cwdURI != null ? efsProvider.getPathFromURI(cwdURI) : null; if (cwdPath != null && mappedRootURI != null) { - buildDirURI = EFSExtensionManager.getDefault().append(mappedRootURI, cwdPath); + buildDirURI = efsProvider.append(mappedRootURI, cwdPath); } else { buildDirURI = cwdURI; } @@ -674,7 +707,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett if (sourceFile == null && cwdTracker != null) { URI cwdURI = cwdTracker.getWorkingDirectoryURI(); if (cwdURI != null) { - URI uri = EFSExtensionManager.getDefault().append(cwdURI, parsedResourceName); + URI uri = efsProvider.append(cwdURI, parsedResourceName); sourceFile = findFileForLocationURI(uri, currentProject); } } @@ -804,7 +837,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett * @param baseURI - base {@link URI} where path to the resource is rooted * @return {@link URI} of the resource */ - private static URI determineMappedURI(String pathStr, URI baseURI) { + private URI determineMappedURI(String pathStr, URI baseURI) { URI uri = null; if (baseURI == null) { @@ -819,9 +852,9 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } else { // location on a remote file-system IPath path = new Path(pathStr); // use canonicalized path here, in particular replace all '\' with '/' for Windows paths - URI remoteUri = EFSExtensionManager.getDefault().append(baseURI, path.toString()); + URI remoteUri = efsProvider.append(baseURI, path.toString()); if (remoteUri != null) { - String localPath = EFSExtensionManager.getDefault().getMappedPath(remoteUri); + String localPath = efsProvider.getMappedPath(remoteUri); if (localPath != null) { uri = org.eclipse.core.filesystem.URIUtil.toURI(localPath); } @@ -929,13 +962,13 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Get location on the local file-system considering possible mapping by {@link EFSExtensionManager}. + * Get location on the local file-system considering possible mapping by EFS provider. See {@link EFSExtensionManager}. */ - private static IPath getFilesystemLocation(URI uri) { + private IPath getFilesystemLocation(URI uri) { if (uri == null) return null; - String pathStr = EFSExtensionManager.getDefault().getMappedPath(uri); + String pathStr = efsProvider.getMappedPath(uri); uri = org.eclipse.core.filesystem.URIUtil.toURI(pathStr); if (uri != null && uri.isAbsolute()) { @@ -1065,6 +1098,20 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett return pattern; } + + /** + * This {@link EFSExtensionProvider} is capable to translate EFS paths to and from local + * file-system. Added mostly for Cygwin translations. + * + * This usage of {@link EFSExtensionProvider} is somewhat a misnomer. This provider is not + * an "extension" provider but rather a wrapper on {@link EFSExtensionManager} which in fact + * will use genuine {@link EFSExtensionProvider}s defined as extensions. + * + * @since 8.2 + */ + protected EFSExtensionProvider getEFSProvider() { + return efsProviderDefault; + } @Override public Element serializeAttributes(Element parentElement) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java index 8d4d6b7cb1a..2a2322d3aa7 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Andrew Gvozdev and others. + * Copyright (c) 2009, 2013 Andrew Gvozdev and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,22 +11,17 @@ package org.eclipse.cdt.managedbuilder.language.settings.providers; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; -import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IInputType; import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; -import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; -import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; -import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; +import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableManagerToolChain; /** * Abstract parser capable to execute compiler command printing built-in compiler @@ -120,19 +115,12 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs @Override protected List getEnvironmentVariables() { - List vars = new ArrayList(super.getEnvironmentVariables()); - - String toolchainId = getToolchainId(); - for (IToolChain toolchain = ManagedBuildManager.getExtensionToolChain(toolchainId); toolchain != null; toolchain = toolchain.getSuperClass()) { - IConfigurationEnvironmentVariableSupplier envSupplier = toolchain.getEnvironmentVariableSupplier(); - if (envSupplier != null) { - IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(currentCfgDescription); - IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider(); - IBuildEnvironmentVariable[] added = envSupplier.getVariables(cfg, provider); - vars.addAll(Arrays.asList(added)); - break; - } + if (envMngr == null && currentCfgDescription == null) { + // For global provider need to include toolchain in the equation + IToolChain toolchain = ManagedBuildManager.getExtensionToolChain(getToolchainId()); + envMngr = new EnvironmentVariableManagerToolChain(toolchain); } + List vars = super.getEnvironmentVariables(); return vars; } diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml index da844d82768..eaa55a1ea6f 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml @@ -1772,6 +1772,7 @@ configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier" id="cdt.managedbuild.toolchain.gnu.cygwin.base" isToolChainSupported="org.eclipse.cdt.managedbuilder.gnu.cygwin.IsGnuCygwinToolChainSupported" + languageSettingsProviders="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser;org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin" name="%ToolChainName.Cygwin" osList="win32" targetTool="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base;cdt.managedbuild.tool.gnu.c.linker.cygwin.base;cdt.managedbuild.tool.gnu.archiver">