1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 392404 - Change Cross GCC toolchain to use language setting provider

Add cross toolchain prefix to the command macro.

Change-Id: I3188d21050b84fdc6d6a4b8d3b6aa540710f1790
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/17189
This commit is contained in:
Marc-Andre Laperle 2013-10-09 00:21:36 -04:00
parent 35b004c5d4
commit c644a857ba
4 changed files with 56 additions and 71 deletions

View file

@ -22,4 +22,5 @@ tool.gpp.compiler = Cross G++ Compiler
tool.gcc.linker = Cross GCC Linker
tool.gpp.linker = Cross G++ Linker
tool.gcc.archiver = Cross GCC Archiver
tool.gcc.assembler = Cross GCC Assembler
tool.gcc.assembler = Cross GCC Assembler
CrossGCCBuiltinSpecsDetector.name = CDT Cross GCC Built-in Compiler Settings

View file

@ -23,9 +23,10 @@
configurationEnvironmentSupplier="org.eclipse.cdt.internal.build.crossgcc.CrossEnvironmentVariableSupplier"
id="cdt.managedbuild.toolchain.gnu.cross.base"
isAbstract="false"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser;org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector"
name="%toolChain.name"
targetTool="cdt.managedbuild.tool.gnu.cross.c.linker;cdt.managedbuild.tool.gnu.cross.cpp.linker;cdt.managedbuild.tool.gnu.archiver"
osList="all">
osList="all"
targetTool="cdt.managedbuild.tool.gnu.cross.c.linker;cdt.managedbuild.tool.gnu.cross.cpp.linker;cdt.managedbuild.tool.gnu.archiver">
<targetPlatform
archList="all"
binaryParser="org.eclipse.cdt.core.ELF"
@ -257,4 +258,16 @@
</toolchain>
</wizardPage>
</extension>
<extension
point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector"
id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector"
name="%CrossGCCBuiltinSpecsDetector.name"
parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;"
prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</plugin>

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2013 Ericsson 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc-Andre Laperle (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.build.crossgcc;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
public class CrossGCCBuiltinSpecsDetector extends GCCBuiltinSpecsDetector {
@Override
protected String getCompilerCommand(String languageId) {
// Include the cross command prefix (tool option) in the ${COMMAND} macro
// For example: "arch-os-" + "gcc"
String prefix = "";
IToolChain toolchain = null;
if (currentCfgDescription != null) {
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(currentCfgDescription);
toolchain = cfg != null ? cfg.getToolChain() : null;
if (toolchain != null) {
IOption option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.prefix"); //$NON-NLS-1$
prefix = (String)option.getValue();
}
}
return prefix + super.getCompilerCommand(languageId);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2009, 2013 Wind River Systems, Inc. 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,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.build.crossgcc;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
import org.eclipse.cdt.core.templateengine.SharedDefaults;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
@ -35,9 +21,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
/**
@ -74,60 +58,9 @@ public class SetCrossCommandOperation implements IRunnableWithProgress {
ManagedBuildManager.setOption(config, toolchain, option, prefix);
option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.path"); //$NON-NLS-1$
ManagedBuildManager.setOption(config, toolchain, option, path);
ICfgScannerConfigBuilderInfo2Set cbi = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(config);
Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = cbi.getInfoMap();
for (CfgInfoContext cfgInfoContext : map.keySet()) {
IScannerConfigBuilderInfo2 bi = map.get(cfgInfoContext);
String providerId = "specsFile"; //$NON-NLS-1$
String runCommand = bi.getProviderRunCommand(providerId);
bi.setProviderRunCommand(providerId, prefix + runCommand);
try {
bi.save();
} catch (CoreException e) {
Activator.log(e);
}
// Clear the path info that was captured at project creation time
// TODO we need an API to do this to avoid the discouraged access warnings.
DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project);
InfoContext infoContext = cfgInfoContext.toInfoContext();
// 1. Remove scanner info from .metadata/.plugins/org.eclipse.cdt.make.core/Project.sc
DiscoveredScannerInfoStore dsiStore = DiscoveredScannerInfoStore.getInstance();
try {
dsiStore.saveDiscoveredScannerInfoToState(project, infoContext, pathInfo);
} catch (CoreException e) {
e.printStackTrace();
}
// 2. Remove scanner info from CfgDiscoveredPathManager cache and from the Tool
CfgDiscoveredPathManager cdpManager = CfgDiscoveredPathManager.getInstance();
cdpManager.removeDiscoveredInfo(project, cfgInfoContext);
// 3. Remove scanner info from SI collector
IScannerConfigBuilderInfo2 buildInfo2 = map.get(cfgInfoContext);
if (buildInfo2!=null) {
ScannerConfigProfileManager scpManager = ScannerConfigProfileManager.getInstance();
String selectedProfileId = buildInfo2.getSelectedProfileId();
SCProfileInstance profileInstance = scpManager.getSCProfileInstance(project, infoContext, selectedProfileId);
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
if (collector instanceof IScannerInfoCollectorCleaner) {
((IScannerInfoCollectorCleaner) collector).deleteAll(project);
}
buildInfo2 = null;
}
}
}
ManagedBuildManager.saveBuildInfo(project, true);
for (IConfiguration config : configs) {
ScannerConfigBuilder.build(config, ScannerConfigBuilder.PERFORM_CORE_UPDATE, new NullProgressMonitor());
}
}
}