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 ret = new String();
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(currentProject);
if (prjDesc == null)
return ret;
ICConfigurationDescription confDesc = prjDesc.getActiveConfiguration();
String codanVarName = new String();
if (languageId.equals("org.eclipse.cdt.core.gcc")) {
codanVarName = Const.CODAN_C_to_O;
} else if (languageId.equals("org.eclipse.cdt.core.g++")) {
codanVarName = Const.CODAN_CPP_to_O;
} else {
ManagedBuilderCorePlugin.error("Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId());
}
try {
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
ret = envManager.getVariable(codanVarName, confDesc, false).getValue();
} catch (Exception e) {
ret = new String();
}
return ret;
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.
the class SloeberConfigurationVariableSupplier method getSloeberProject.
private static SloeberProject getSloeberProject(IConfiguration configuration) {
ICConfigurationDescription confDesc = ManagedBuildManager.getDescriptionForConfiguration(configuration);
ICProjectDescription projDesc = confDesc.getProjectDescription();
IProject project = projDesc.getProject();
return SloeberProject.getSloeberProject(project);
}
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 confDesc = projectDescription.getActiveConfiguration();
if (confDesc != null) {
Set<String> UnresolvedIncludedHeaders = getUnresolvedProjectIncludes(affectedProject);
Set<String> alreadyAddedLibs = getAllLibrariesFromProject(affectedProject);
// remove pgmspace as it gives a problem
// $NON-NLS-1$
UnresolvedIncludedHeaders.remove("pgmspace");
if (UnresolvedIncludedHeaders.isEmpty()) {
return;
}
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(confDesc);
Set<String> uninstalledIncludedHeaders = new TreeSet<>(UnresolvedIncludedHeaders);
uninstalledIncludedHeaders.removeAll(installedLibs.keySet());
if (!uninstalledIncludedHeaders.isEmpty()) {
// some libraries may need to be installed
Map<String, ArduinoLibraryVersion> availableLibs = LibraryManager.getLatestInstallableLibraries(uninstalledIncludedHeaders);
if (!availableLibs.isEmpty()) {
// Ask the user which libs need installing
availableLibs = installHandler.selectLibrariesToInstall(availableLibs);
for (Entry<String, ArduinoLibraryVersion> curLib : availableLibs.entrySet()) {
LibraryManager.install(curLib.getValue(), new NullProgressMonitor());
}
}
}
}
Map<String, IPath> installedLibs = getAllInstalledLibraries(confDesc);
installedLibs.keySet().retainAll(UnresolvedIncludedHeaders);
if (!installedLibs.isEmpty()) {
// there are possible libraries to add
Common.log(new Status(IStatus.INFO, CORE_PLUGIN_ID, // $NON-NLS-1$
"list of libraries to add to project " + affectedProject.getName() + // $NON-NLS-1$
": " + installedLibs.keySet().toString()));
Map<String, List<IPath>> foldersToChange = addLibrariesToProject(affectedProject, installedLibs);
if (adjustProjectDescription(confDesc, foldersToChange)) {
try {
mngr.setProjectDescription(affectedProject, projectDescription, true, null);
} 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) {
boolean descNeedsSet = false;
Set<String> AllLibrariesOriginallyUsed = getAllLibrariesFromProject(project);
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
ICProjectDescription projDesc = mngr.getProjectDescription(project, true);
ICConfigurationDescription[] configurationDescriptions = projDesc.getConfigurations();
for (ICConfigurationDescription curconfDesc : configurationDescriptions) {
Map<String, List<IPath>> foldersToChange = addLibrariesToProject(project, curconfDesc, AllLibrariesOriginallyUsed);
descNeedsSet = descNeedsSet || adjustProjectDescription(curconfDesc, foldersToChange);
}
if (descNeedsSet) {
try {
mngr.setProjectDescription(project, projDesc, true, null);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.
the class RegressionTest method issue555.
/**
* make sure when switching between a board with variant file and without the
* build still succeeds
*/
@Test
public void issue555() {
if (MySystem.getTeensyPlatform().isEmpty()) {
// skip test due to no teensy install folder provided
// do not fail as this will always fail on travis
System.out.println("skipping the test because teensy is not installed.");
return;
}
System.out.println("Teensy is installed at " + MySystem.getTeensyPlatform());
BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
BoardDescription teensyBoardid = Teensy.Teensy3_1().getBoardDescriptor();
IProject theTestProject = null;
CodeDescription codeDescriptor = CodeDescription.createDefaultIno();
String projectName = "issue555";
NullProgressMonitor monitor = new NullProgressMonitor();
try {
theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), monitor);
// for the indexer
Shared.waitForAllJobsToFinish();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create the project:" + projectName);
return;
}
try {
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " as uno build errors");
}
} catch (CoreException e) {
e.printStackTrace();
fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as uno exception");
}
SloeberProject arduinoProject = SloeberProject.getSloeberProject(theTestProject);
ICProjectDescription cProjectDescription = CCorePlugin.getDefault().getProjectDescription(theTestProject);
arduinoProject.setBoardDescription(cProjectDescription.getActiveConfiguration().getName(), teensyBoardid, true);
Shared.waitForAllJobsToFinish();
try {
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
Shared.waitForAllJobsToFinish();
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " as teensy");
}
}
} catch (CoreException e) {
e.printStackTrace();
fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as teensy exception");
}
}
Aggregations