use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.
the class UsbdmDebuggerPanel method getToolInformationDataFromConfig.
/**
* Try to get interface type from project via ILaunchConfiguration
*
* @param configuration
* @return
*/
private ToolInformationData getToolInformationDataFromConfig(ILaunchConfiguration configuration) {
String buildToolsId = null;
try {
// ToDo Consider using - ICProject projectHandle =
// CDebugUtils.verifyCProject(configuration);
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
String projectBuildId = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String) null);
if ((projectName != null) && (projectBuildId != null)) {
ICProject projectHandle = CoreModel.getDefault().getCModel().getCProject(projectName);
IConfiguration buildConfig = ManagedBuildManager.getBuildInfo(projectHandle.getProject()).getManagedProject().getConfiguration(projectBuildId);
if (buildConfig != null) {
IToolChain toolChain = buildConfig.getToolChain();
if (toolChain != null) {
IOption option = toolChain.getOptionBySuperClassId("net.sourceforge.usbdm.cdt.arm.toolchain.buildtools");
if (option == null) {
option = toolChain.getOptionBySuperClassId("net.sourceforge.usbdm.cdt.coldfire.toolchain.buildtools");
}
if (option != null) {
// System.err.println("option(net.sourceforge.usbdm.cdt.arm.toolchain.buildtools).getId()
// = "+option.getId());
// System.err.println("option(net.sourceforge.usbdm.cdt.arm.toolchain.buildtools).getName()
// = "+option.getName());
buildToolsId = option.getStringValue();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// System.err.println("Selected Build Tools ID = " + buildToolsId);
ToolInformationData toolInformationData = null;
if (buildToolsId != null) {
toolInformationData = ToolInformationData.get(buildToolsId);
}
// System.err.println("Selected Build Tools = " + toolInformationData);
return toolInformationData;
}
use of org.eclipse.cdt.managedbuilder.core.IToolChain in project m2e-nar by maven-nar.
the class CProjectConfigurator method getToolChain.
/**
* Reorders selected configurations in "physical" order. Although toolchains
* are displayed in alphabetical order in Wizard, it's required to create
* corresponding configurations in the same order as they are listed in xml
* file, inside of single project type.
*
* @param its
* - items in initial order.
* @return
* @return - items in "physical" order.
*/
/*
* public static List<IConfiguration> reorder(List<IConfiguration> cfgs) {
* List<IConfiguration> ls = new ArrayList<IConfiguration>(cfgs.size());
* IConfiguration[] its = cfgs.toArray(new IConfiguration[cfgs.size()]);
* boolean found = true; while (found) { found = false; for (int i=0;
* i<its.length; i++) { if (its[i] == null) continue; found = true;
* IProjectType pt = its[i].getProjectType(); if (pt == null) {
* ls.add(its[i]); its[i] = null; continue; } IConfiguration[] cfs =
* pt.getConfigurations(); for (int j=0; j<cfs.length; j++) { for (int k=0;
* k<its.length; k++) { if (its[k] == null) continue; if
* (cfs[j].equals(its[k].getTcCfg())) { ls.add(its[k]); its[k] = null; } } }
* } } return ls.toArray(new CfgHolder[ls.size()]); }
*/
private IToolChain getToolChain(final String toolChain, final String artefactType) throws CoreException {
// Find the tool chains supported on our system for the selected
// artefact type
IToolChain[] tcs = ManagedBuildManager.getExtensionsToolChains(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artefactType, true);
// Find the tool chain
IToolChain tc = null;
for (IToolChain tc2 : tcs) {
if (isValid(tc2) && toolChain.equals(tc2.getUniqueRealName())) {
tc = tc2;
break;
}
}
if (tc == null) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Could not find valid tool chain \"" + toolChain + "\""));
}
return tc;
}
use of org.eclipse.cdt.managedbuilder.core.IToolChain in project m2e-nar by maven-nar.
the class CProjectConfigurator method configure.
@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
final ConfiguratorContext context = new ConfiguratorContext(maven, projectManager);
IProject project = request.getProject();
monitor.setTaskName(Messages.CProjectConfigurator_task_name + project.getName());
logger.info("configure");
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
// Set the first created configuration as active.
boolean setActive = true;
final IMavenProjectFacade facade = request.getMavenProjectFacade();
List<NarExecution> narExecutions = MavenUtils.buildCompileNarExecutions(context, facade, monitor);
narExecutions.addAll(MavenUtils.buildTestCompileNarExecutions(context, facade, monitor));
for (NarExecution narSettings : narExecutions) {
if (!narSettings.isSkip()) {
final String os = narSettings.getOS();
final String linkerName = narSettings.getLinkerName();
final AbstractSettingsSynchroniser synchro = SynchroniserFactory.getSettingsSynchroniser(os, linkerName);
final String toolchain = synchro.getToolchain();
for (NarBuildArtifact artifactSettings : narSettings.getArtifactSettings()) {
final String configName = artifactSettings.getConfigName();
final String cdtArtefactType = CdtUtils.convertArtefactType(artifactSettings.getType());
IToolChain tc = getToolChain(toolchain, cdtArtefactType);
ICProjectDescription desc = getCdtProject(project, tc, cdtArtefactType, monitor);
ICConfigurationDescription cfg = getCdtMavenConfig(project, desc, tc, cdtArtefactType, configName, setActive, monitor);
setActive = false;
synchro.fullSync(cfg, artifactSettings);
mngr.setProjectDescription(project, desc);
}
}
}
AbstractProjectConfigurator jConfig = LifecycleMappingFactory.createProjectConfigurator(JAVA_CONFIGURATOR_ID);
jConfig.configure(request, monitor);
// ensure CDT builder is after the Maven one
boolean changed = false;
IProjectDescription description = project.getDescription();
ICommand cdtBuilder = null;
ICommand mavenBuilder = null;
ArrayList<ICommand> newSpec = new ArrayList<ICommand>();
for (ICommand command : description.getBuildSpec()) {
if (ManagedCProjectNature.getBuilderID().equals(command.getBuilderName()) && mavenBuilder == null) {
cdtBuilder = command;
} else {
newSpec.add(command);
}
if (IMavenConstants.BUILDER_ID.equals(command.getBuilderName())) {
mavenBuilder = command;
if (cdtBuilder != null) {
newSpec.add(cdtBuilder);
changed = true;
}
}
}
if (changed) {
description.setBuildSpec(newSpec.toArray(new ICommand[newSpec.size()]));
project.setDescription(description, monitor);
}
}
use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.
the class UsbdmGCCSpecsRunSIProvider method getToolPrefix.
/**
* @param project The project to look in for options
* @return The prefix for the build tools
*/
private String getToolPrefix(IProject project) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if (info == null) {
return "";
}
IConfiguration cfg = info.getDefaultConfiguration();
// System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found IConfiguration = " + cfg.getName());
IToolChain toolChain = cfg.getToolChain();
// System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found toolChain = " + toolChain.getName());
// Find selected build tool (either ARM or Coldfire)
IOption buildToolOption = toolChain.getOptionBySuperClassId(UsbdmConstants.ARM_BUILDTOOLS_OPTIONS);
if (buildToolOption == null) {
buildToolOption = toolChain.getOptionBySuperClassId(UsbdmConstants.COLDFIRE_BUILDTOOLS_OPTIONS);
}
if (buildToolOption == null) {
return "";
}
// Get build path variable
ToolInformationData toolData = ToolInformationData.getToolInformationTable().get(buildToolOption.getValue().toString());
if (toolData == null) {
return "";
}
String toolPrefixVariableId = toolData.getPrefixVariableName();
if (toolPrefixVariableId == null) {
return "";
}
UsbdmSharedSettings settings = UsbdmSharedSettings.getSharedSettings();
String toolPrefix = null;
if (settings != null) {
toolPrefix = settings.get(toolPrefixVariableId);
}
if (toolPrefix == null) {
toolPrefix = "Tool Prefix not set";
return "";
}
// System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found tool prefix = " + toolPrefix);
return toolPrefix;
}
use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.
the class ProjectUtilities method createIncludeFolder.
public static void createIncludeFolder(IProject project, String targetPath, IProgressMonitor progressMonitor) throws CoreException, BuildException {
// createSourceFolder(project, targetPath, progressMonitor);
createFolder(project, targetPath, progressMonitor);
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
// Add to Include search paths
IConfiguration[] configs = info.getManagedProject().getConfigurations();
for (IConfiguration config : configs) {
// Creates include folder path that is portable (e.g. rename project doesn't break paths)
String path = "\"${ProjDirPath}/" + project.getFolder(targetPath).getProjectRelativePath().toOSString() + "\"";
IToolChain toolChain = config.getToolChain();
setIncludePathOptionForConfig(path, config, toolChain.getOptions(), toolChain);
ITool[] tools = config.getTools();
for (ITool tool : tools) {
setIncludePathOptionForConfig(path, config, tool.getOptions(), tool);
}
}
ManagedBuildManager.saveBuildInfo(project, true);
}
Aggregations