use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project linuxtools by eclipse.
the class STSymbolManager method getBinaryParser.
/**
* Retrieve the list of binary parsers defined for the given project.
* @param project The project.
* @return The binary parsers for this project.
*/
private List<IBinaryParser> getBinaryParser(IProject project) {
List<IBinaryParser> parsers = new LinkedList<>();
ICProjectDescription projDesc = CCorePlugin.getDefault().getProjectDescription(project);
if (projDesc == null) {
return parsers;
}
ICConfigurationDescription[] cfgs = projDesc.getConfigurations();
String[] binaryParserIds = CoreModelUtil.getBinaryParserIds(cfgs);
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
for (String id : binaryParserIds) {
IExtension extension = extensionPoint.getExtension(id);
if (extension != null) {
IConfigurationElement[] element = extension.getConfigurationElements();
for (IConfigurationElement element2 : element) {
if (element2.getName().equalsIgnoreCase("cextension")) {
// $NON-NLS-1$
try {
// $NON-NLS-1$
IBinaryParser parser = (IBinaryParser) element2.createExecutableExtension("run");
if (parser != null) {
parsers.add(parser);
}
} catch (CoreException e) {
// TODO: handle exception ?
}
}
}
}
}
return parsers;
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project linuxtools by eclipse.
the class CProjectHelper method addDefaultBinaryParser.
/**
* Add the default binary parser if no binary parser configured.
*
* @param project
* @throws CoreException
*/
private static boolean addDefaultBinaryParser(IProject project) throws CoreException {
ICConfigExtensionReference[] binaryParsers = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
if (binaryParsers == null || binaryParsers.length == 0) {
ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project);
if (desc == null) {
return false;
}
desc.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID, CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID);
CCorePlugin.getDefault().setProjectDescription(project, desc);
}
return true;
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.
the class ArduinoLanguageProvider method getCompilerCommand.
@Override
protected String getCompilerCommand(String languageId) {
String compilerCommand = new String();
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(this.currentProject);
if (prjDesc == null)
return compilerCommand;
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
ICConfigurationDescription confDesc = prjDesc.getActiveConfiguration();
String recipeKey = new String();
String extraOptions = new String();
CompileOptions compileOptions = new CompileOptions(confDesc);
if (languageId.equals("org.eclipse.cdt.core.gcc")) {
recipeKey = Common.get_ENV_KEY_RECIPE(Const.ACTION_C_to_O);
extraOptions = compileOptions.get_C_CompileOptions();
} else if (languageId.equals("org.eclipse.cdt.core.g++")) {
recipeKey = Common.get_ENV_KEY_RECIPE(Const.ACTION_CPP_to_O);
extraOptions = compileOptions.get_CPP_CompileOptions();
} else {
ManagedBuilderCorePlugin.error("Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId());
}
extraOptions = extraOptions + " " + compileOptions.get_C_andCPP_CompileOptions() + " " + compileOptions.get_All_CompileOptions();
try {
compilerCommand = envManager.getVariable(recipeKey + Const.DOT + "1", confDesc, false).getValue();
compilerCommand = compilerCommand + envManager.getVariable(recipeKey + Const.DOT + "2", confDesc, false).getValue();
compilerCommand = compilerCommand + envManager.getVariable(recipeKey + Const.DOT + "3", confDesc, false).getValue();
} catch (Exception e) {
compilerCommand = new String();
}
compilerCommand = compilerCommand + ' ' + extraOptions;
return compilerCommand.replaceAll(" -o ", " ");
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.
the class Libraries method checkLibraries.
public static void checkLibraries(IProject affectedProject) {
Map<String, String> includeHeaderReplacement = getIncludeHeaderReplacement();
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
if (mngr != null) {
ICProjectDescription projectDescription = mngr.getProjectDescription(affectedProject, true);
if (projectDescription != null) {
ICConfigurationDescription configurationDescription = projectDescription.getActiveConfiguration();
if (configurationDescription != null) {
Set<String> UnresolvedIncludedHeaders = getUnresolvedProjectIncludes(affectedProject);
Set<String> alreadyAddedLibs = getAllLibrariesFromProject(affectedProject);
// remove pgmspace as it gives a problem
// $NON-NLS-1$
UnresolvedIncludedHeaders.remove("pgmspace");
for (Map.Entry<String, String> entry : includeHeaderReplacement.entrySet()) {
if (UnresolvedIncludedHeaders.contains(entry.getKey())) {
UnresolvedIncludedHeaders.remove(entry.getKey());
UnresolvedIncludedHeaders.add(entry.getValue());
}
}
UnresolvedIncludedHeaders.removeAll(alreadyAddedLibs);
IInstallLibraryHandler installHandler = LibraryManager.getInstallLibraryHandler();
if (installHandler.autoInstall()) {
// Check if there are libraries that are not found in the installed libraries
Map<String, IPath> installedLibs = getAllInstalledLibraries(configurationDescription);
Set<String> uninstalledIncludedHeaders = new TreeSet<>(UnresolvedIncludedHeaders);
uninstalledIncludedHeaders.removeAll(installedLibs.keySet());
if (!uninstalledIncludedHeaders.isEmpty()) {
// some libraries may need to be installed
Map<String, LibraryDescriptor> availableLibs = LibraryManager.getLatestInstallableLibraries(uninstalledIncludedHeaders);
if (!availableLibs.isEmpty()) {
// We now know which libraries to install
// TODO for now I just install but there should be some user
// interaction
availableLibs = installHandler.selectLibrariesToInstall(availableLibs);
for (Entry<String, LibraryDescriptor> curLib : availableLibs.entrySet()) {
curLib.getValue().toLibrary().install(new NullProgressMonitor());
}
}
}
}
Map<String, IPath> installedLibs = getAllInstalledLibraries(configurationDescription);
installedLibs.keySet().retainAll(UnresolvedIncludedHeaders);
if (!installedLibs.isEmpty()) {
// there are possible libraries to add
Common.log(new Status(IStatus.INFO, Const.CORE_PLUGIN_ID, // $NON-NLS-1$
"list of libraries to add to project " + affectedProject.getName() + ": " + // $NON-NLS-1$
installedLibs.keySet().toString()));
addLibrariesToProject(affectedProject, configurationDescription, installedLibs);
try {
// TODO remove this logging code if this code is not causing the disrupts
long startTime = System.nanoTime();
mngr.setProjectDescription(affectedProject, projectDescription, true, null);
// in miliseconds
long duration = (System.nanoTime() - startTime) / 1000000;
if (duration > 45000) {
// $NON-NLS-1$ //$NON-NLS-2$
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, "setProjectDescription took " + duration + " miliseconds!!!"));
}
} catch (CoreException e) {
// this can fail because the project may already
// be
// deleted
}
}
}
}
}
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.
the class Libraries method reAttachLibrariesToProject.
public static void reAttachLibrariesToProject(IProject project) {
Set<String> AllLibrariesOriginallyUsed = getAllLibrariesFromProject(project);
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
ICProjectDescription projectDescription = mngr.getProjectDescription(project, true);
ICConfigurationDescription[] configurationDescriptions = projectDescription.getConfigurations();
for (ICConfigurationDescription CurItem : configurationDescriptions) {
addLibrariesToProject(project, CurItem, AllLibrariesOriginallyUsed);
}
try {
mngr.setProjectDescription(project, projectDescription, true, null);
} catch (CoreException e) {
e.printStackTrace();
}
}
Aggregations