use of org.eclipse.cdt.managedbuilder.core.IResourceInfo in project arduino-eclipse-plugin by Sloeber.
the class ArduinoGnuMakefileGenerator method regenerateDependencies.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#
* regenerateDependencies()
*/
@Override
public void regenerateDependencies(boolean force) throws CoreException {
// A hack for the pre-3.x GCC compilers is to put dummy targets for deps
final IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
final CoreException[] es = new CoreException[1];
this.toolInfos.accept(new IPathSettingsContainerVisitor() {
@SuppressWarnings("synthetic-access")
@Override
public boolean visit(PathSettingsContainer container) {
ToolInfoHolder h = (ToolInfoHolder) container.getValue();
// Collect the methods that will need to be called
List<String> depExts = new ArrayList<>();
IManagedDependencyGenerator2[] postProcessors = new IManagedDependencyGenerator2[h.buildTools.length];
boolean callPopulateDummyTargets = collectDependencyGeneratorInformation(h, depExts, postProcessors);
// Is there anyone to call if we do find dependency files?
if (!callPopulateDummyTargets) {
int i;
for (i = 0; i < postProcessors.length; i++) {
if (postProcessors[i] != null)
break;
}
if (i == postProcessors.length)
return true;
}
IResourceInfo rcInfo = ArduinoGnuMakefileGenerator.this.config.getResourceInfo(container.getPath(), false);
for (IPath path : getDependencyMakefiles(h)) {
// The path to search for the dependency makefile
IPath relDepFilePath = ArduinoGnuMakefileGenerator.this.topBuildDir.append(path);
IFile depFile = root.getFile(relDepFilePath);
if (depFile == null || !depFile.isAccessible())
continue;
try {
callDependencyPostProcessors(rcInfo, h, depFile, postProcessors, callPopulateDummyTargets, true);
} catch (CoreException e) {
es[0] = e;
return false;
}
}
return true;
}
});
if (es[0] != null)
throw es[0];
}
use of org.eclipse.cdt.managedbuilder.core.IResourceInfo in project arduino-eclipse-plugin by Sloeber.
the class ArduinoGnuMakefileGenerator method deleteBuildTarget.
private void deleteBuildTarget(IResource deletedFile) {
// Get the project relative path of the file
String fileName = getFileName(deletedFile);
String srcExtension = deletedFile.getFileExtension();
IPath folderPath = inFullPathFromOutFullPath(deletedFile.getFullPath().removeLastSegments(1));
if (folderPath != null) {
folderPath = folderPath.removeFirstSegments(1);
} else {
folderPath = new Path(new String());
}
IResourceInfo rcInfo = this.config.getResourceInfo(folderPath, false);
if (rcInfo instanceof IFileInfo) {
rcInfo = this.config.getResourceInfo(folderPath.removeLastSegments(1), false);
}
String targetExtension = ((IFolderInfo) rcInfo).getOutputExtension(srcExtension);
if (!targetExtension.isEmpty())
fileName += DOT + targetExtension;
IPath projectRelativePath = deletedFile.getProjectRelativePath().removeLastSegments(1);
IPath targetFilePath = getBuildWorkingDir().append(projectRelativePath).append(fileName);
IResource depFile = this.project.findMember(targetFilePath);
if (depFile != null && depFile.exists()) {
try {
depFile.delete(true, this.monitor);
} catch (CoreException e) {
// This had better be allowed during a build
}
}
}
use of org.eclipse.cdt.managedbuilder.core.IResourceInfo in project arduino-eclipse-plugin by Sloeber.
the class ArduinoGnuMakefileGenerator method getFolderToolInfo.
private ToolInfoHolder getFolderToolInfo(IPath _path) {
IPath path = _path;
IResourceInfo rcInfo = this.config.getResourceInfo(path, false);
while (rcInfo instanceof IFileInfo) {
path = path.removeLastSegments(1);
rcInfo = this.config.getResourceInfo(path, false);
}
return getToolInfo(path, false);
}
use of org.eclipse.cdt.managedbuilder.core.IResourceInfo in project arduino-eclipse-plugin by Sloeber.
the class ArduinoGnuMakefileGenerator method initToolInfos.
private void initToolInfos() {
this.toolInfos = PathSettingsContainer.createRootContainer();
IResourceInfo[] rcInfos = this.config.getResourceInfos();
for (IResourceInfo rcInfo : rcInfos) {
if (rcInfo.isExcluded())
/* && !((ResourceInfo)rcInfo).isRoot() */
continue;
ToolInfoHolder h = getToolInfo(rcInfo.getPath(), true);
if (rcInfo instanceof IFolderInfo) {
IFolderInfo fo = (IFolderInfo) rcInfo;
h.buildTools = fo.getFilteredTools();
h.buildToolsUsed = new boolean[h.buildTools.length];
h.gnuToolInfos = new ArduinoManagedBuildGnuToolInfo[h.buildTools.length];
} else {
IFileInfo fi = (IFileInfo) rcInfo;
h.buildTools = fi.getToolsToInvoke();
h.buildToolsUsed = new boolean[h.buildTools.length];
h.gnuToolInfos = new ArduinoManagedBuildGnuToolInfo[h.buildTools.length];
}
}
}
use of org.eclipse.cdt.managedbuilder.core.IResourceInfo in project arduino-eclipse-plugin by Sloeber.
the class ArduinoGnuMakefileGenerator method generateDependencies.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator
* #generateDependencies()
*/
@Override
public void generateDependencies() throws CoreException {
final PathSettingsContainer postProcs = PathSettingsContainer.createRootContainer();
// Note: PopulateDummyTargets is a hack for the pre-3.x GCC compilers
// Collect the methods that will need to be called
this.toolInfos.accept(new IPathSettingsContainerVisitor() {
@SuppressWarnings("synthetic-access")
@Override
public boolean visit(PathSettingsContainer container) {
ToolInfoHolder h = (ToolInfoHolder) container.getValue();
List<String> depExts = new ArrayList<>();
IManagedDependencyGenerator2[] postProcessors = new IManagedDependencyGenerator2[h.buildTools.length];
boolean callPopulateDummyTargets = collectDependencyGeneratorInformation(h, depExts, postProcessors);
// Is there anyone to call if we do find dependency files?
if (!callPopulateDummyTargets) {
int i;
for (i = 0; i < postProcessors.length; i++) {
if (postProcessors[i] != null)
break;
}
if (i == postProcessors.length)
return true;
}
PathSettingsContainer child = postProcs.getChildContainer(container.getPath(), true, true);
DepInfo di = new DepInfo();
di.depExts = depExts;
di.postProcessors = postProcessors;
di.callPopulateDummyTargets = callPopulateDummyTargets;
child.setValue(di);
return true;
}
});
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
for (IResource res : getSubdirList()) {
// The builder creates a subdir with same name as source in the
// build location
IContainer subDir = (IContainer) res;
IPath projectRelativePath = subDir.getProjectRelativePath();
IResourceInfo rcInfo = this.config.getResourceInfo(projectRelativePath, false);
PathSettingsContainer cr = postProcs.getChildContainer(rcInfo.getPath(), false, true);
if (cr == null || cr.getValue() == null)
continue;
DepInfo di = (DepInfo) cr.getValue();
ToolInfoHolder h = getToolInfo(projectRelativePath);
IPath buildRelativePath = this.topBuildDir.append(projectRelativePath);
IFolder buildFolder = root.getFolder(buildRelativePath);
if (buildFolder == null)
continue;
if (!buildFolder.exists())
continue;
// Find all of the dep files in the generated subdirectories
IResource[] files = buildFolder.members();
for (IResource file : files) {
String fileExt = file.getFileExtension();
for (String ext : di.depExts) {
if (ext.equals(fileExt)) {
IFile depFile = root.getFile(file.getFullPath());
if (depFile == null)
continue;
callDependencyPostProcessors(rcInfo, h, depFile, di.postProcessors, di.callPopulateDummyTargets, false);
}
}
}
}
}
Aggregations