use of org.eclipse.cdt.managedbuilder.core.BuildException in project usbdm-eclipse-plugins by podonoghue.
the class GccCommandLineGenerator method addFlags.
private String[] addFlags(ITool tool, String[] flags) {
IToolChain toolChain = getToolChain(tool);
// Create list of new flags
ArrayList<String> newFlags = new ArrayList<String>();
if (toolChain != null) {
for (String newFlag : optionKeys) {
// $NON-NLS-1$
IOption option = toolChain.getOptionBySuperClassId(newFlag);
if (option == null) {
// System.err.println("GccCommandLineGenerator.addFlags() - option("+newFlag+"): not found");
continue;
}
try {
String command = option.getCommand();
if (command == null) {
command = "";
}
String value = null;
if (option.getValueType() == IOption.ENUMERATED) {
String enumId = option.getSelectedEnum();
value = option.getEnumCommand(enumId);
} else if (option.getValueType() == IOption.STRING) {
value = option.getStringValue();
} else if (option.getValueType() == IOption.BOOLEAN) {
boolean booleanValue = option.getBooleanValue();
if (!booleanValue) {
command = option.getCommandFalse();
}
option.getDefaultValue();
} else {
System.err.println("GccCommandLineGenerator.addFlags() - option(" + newFlag + "): Unexpected option type");
continue;
}
if (value == null) {
value = "";
}
if ((command.isEmpty()) && (value.isEmpty())) {
// System.err.println("GccCommandLineGenerator.addFlags() - option("+newFlag+"): Command && value ==> null/empty");
continue;
}
String flag = "";
if (command.contains("{value}")) {
flag = command.replace("{value}", value);
} else {
flag = command + value;
}
// System.err.println("GccCommandLineGenerator.addFlags() - option("+newFlag+") ==> \'"+flag+"\'");
newFlags.add(flag);
} catch (BuildException e) {
e.printStackTrace();
}
}
}
// Create combined list of newFlags + flags as array
if (flags == null) {
flags = new String[0];
}
String[] allFlags = new String[newFlags.size() + flags.length];
int index = 0;
StringBuffer allFlagsBuffer = new StringBuffer();
boolean firstFlag = false;
for (String flag : newFlags) {
allFlags[index] = flag;
if (!firstFlag) {
allFlagsBuffer.append(" ");
}
allFlagsBuffer.append(flag);
index++;
}
for (String flag : flags) {
allFlags[index++] = flag;
}
// String flag = UsbdmSharedSettings.getSharedSettings().get(UsbdmSharedConstants.USBDM_COMPILER_FLAGS_VAR);
return allFlags;
}
use of org.eclipse.cdt.managedbuilder.core.BuildException in project m2e-nar by maven-nar.
the class CProjectConfigurator method getCdtProject.
private ICProjectDescription getCdtProject(IProject project, IToolChain tc, String artefactType, IProgressMonitor monitor) throws CoreException {
try {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) {
MavenNarPlugin.getDefault().log("Configuring project with " + tc.getUniqueRealName() + " tool chain");
// Add the C++ Nature
CCorePlugin.getDefault().convertProjectToNewCC(project, ManagedBuildManager.CFG_DATA_PROVIDER_ID, monitor);
ICProjectDescription des = mngr.createProjectDescription(project, false, false);
IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
List<IConfiguration> cfgs = getCfgs(tc, artefactType);
if (cfgs.isEmpty()) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Cannot find any configurations"));
}
IConfiguration cf = cfgs.get(0);
IManagedProject mProj = ManagedBuildManager.createManagedProject(project, cf.getProjectType());
info.setManagedProject(mProj);
return des;
} else {
ICProjectDescription des = mngr.getProjectDescription(project, true);
return des;
}
} catch (BuildException e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Cannot create CDT managed project", e));
}
}
use of org.eclipse.cdt.managedbuilder.core.BuildException in project m2e-nar by maven-nar.
the class OptionSetter method setOption.
public void setOption(final String optionId, final String value) throws CoreException {
try {
for (final ITool tool : config.getToolsBySuperClassId(toolId)) {
final IOption option = tool.getOptionBySuperClassId(optionId);
config.setOption(tool, option, value);
}
} catch (BuildException e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't set " + optionId + " option", e));
}
}
use of org.eclipse.cdt.managedbuilder.core.BuildException in project m2e-nar by maven-nar.
the class OptionSetter method setOption.
public void setOption(final String optionId, final String[] values) throws CoreException {
try {
for (final ITool tool : config.getToolsBySuperClassId(toolId)) {
final IOption option = tool.getOptionBySuperClassId(optionId);
config.setOption(tool, option, values);
}
} catch (BuildException e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't set " + optionId + " option", e));
}
}
Aggregations