use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project arduino-eclipse-plugin by Sloeber.
the class ArduinoGnuMakefileGenerator method initialize.
@Override
public void initialize(int buildKind, IConfiguration cfg, IBuilder _builder, IProgressMonitor monitor1) {
IBuilder builder1 = _builder;
// Save the project so we can get path and member information
this.project = cfg.getOwner().getProject();
if (builder1 == null) {
builder1 = cfg.getEditableBuilder();
}
try {
this.projectResources = this.project.members();
} catch (CoreException e) {
this.projectResources = null;
}
// Save the monitor reference for reporting back to the user
this.monitor = monitor1;
// Get the build info for the project
// this.info = info;
// Get the name of the build target
this.buildTargetName = cfg.getArtifactName();
// Get its extension
this.buildTargetExt = cfg.getArtifactExtension();
try {
// try to resolve the build macros in the target extension
this.buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(this.buildTargetExt, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, builder1);
} catch (BuildMacroException e) {
/* JABA is not going to write this code */
}
try {
// try to resolve the build macros in the target name
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(this.buildTargetName, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, builder1);
if (resolved != null) {
resolved = resolved.trim();
if (resolved.length() > 0)
this.buildTargetName = resolved;
}
} catch (BuildMacroException e) {
/* JABA is not going to write this code */
}
if (this.buildTargetExt == null) {
this.buildTargetExt = new String();
}
// Cache the build tools
this.config = cfg;
this.builder = builder1;
initToolInfos();
// set the top build dir path
this.topBuildDir = this.project.getFolder(cfg.getName()).getFullPath();
this.srcEntries = this.config.getSourceEntries();
if (this.srcEntries.length == 0) {
this.srcEntries = new ICSourceEntry[] { new CSourceEntry(Path.EMPTY, null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH) };
} else {
ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(this.config);
this.srcEntries = CDataUtil.resolveEntries(this.srcEntries, cfgDes);
}
}
use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project usbdm-eclipse-plugins by podonoghue.
the class ProjectUtilities method changeExcludedItem.
private static void changeExcludedItem(IProject project, String targetPath, boolean isFolder, boolean excluded, IProgressMonitor progressMonitor) throws CoreException, BuildException {
IPath path = project.getFolder(targetPath).getProjectRelativePath();
System.err.println(String.format("changeExcludedItem(target=%s, isfolder=%s, exclude=%s)", path.toString(), Boolean.toString(isFolder), Boolean.toString(excluded)));
// ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(project, true);
// ICConfigurationDescription configDecriptions[] = projectDescription.getConfigurations();
// for (ICConfigurationDescription configDescription : configDecriptions) {
// // Exclude in each configuration
// System.err.println(String.format("Excluding in configuration %s", configDescription.toString()));
// ICSourceEntry[] sourceEntries = configDescription.getSourceEntries();
// ICSourceEntry[] modifiedSourceEntries = CDataUtil.setExcludedIfPossible(path, isFolder, excluded, sourceEntries);
// configDescription.setSourceEntries(modifiedSourceEntries);
// }
// CoreModel.getDefault().setProjectDescription(project, projectDescription);
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
IConfiguration[] configurations = info.getManagedProject().getConfigurations();
for (IConfiguration configuration : configurations) {
// Exclude in each configuration
System.err.println(String.format("Excluding in configuration %s", configuration.toString()));
ICSourceEntry[] sourceEntries = configuration.getSourceEntries();
ICSourceEntry[] modifiedSourceEntries = CDataUtil.setExcludedIfPossible(path, isFolder, excluded, sourceEntries);
configuration.setSourceEntries(modifiedSourceEntries);
}
}
use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project m2e-nar by maven-nar.
the class AbstractSettingsSynchroniser method setSourceDirs.
private void setSourceDirs(final ICConfigurationDescription conf, final NarBuildArtifact settings) throws CoreException {
final Map<String, Set<String>> sourceDirs = new HashMap<String, Set<String>>();
for (final File f : settings.getCppSettings().getSourceDirectories()) {
sourceDirs.put(f.getPath(), settings.getCppSettings().getExcludes());
}
for (final File f : settings.getCSettings().getSourceDirectories()) {
sourceDirs.put(f.getPath(), settings.getCSettings().getExcludes());
}
final ICSourceEntry[] sourceEntries = new ICSourceEntry[sourceDirs.size()];
int i = 0;
for (final Map.Entry<String, Set<String>> sourceDir : sourceDirs.entrySet()) {
sourceEntries[i] = createSourcePathEntry(sourceDir.getKey(), sourceDir.getValue(), 0);
++i;
}
conf.setSourceEntries(sourceEntries);
}
use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project m2e-nar by maven-nar.
the class AbstractSettingsSynchroniser method createSourcePathEntry.
private ICSourceEntry createSourcePathEntry(final String path, final Set<String> excludes, final int flags) {
IPath[] exclusionPatterns = null;
if (excludes.size() > 0) {
exclusionPatterns = new IPath[excludes.size()];
int i = 0;
for (String exclude : excludes) {
exclusionPatterns[i] = Path.fromOSString(exclude);
++i;
}
logger.debug("Excludes for source path " + path + ": " + Arrays.deepToString(exclusionPatterns));
}
final IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
final File file = new File(path);
if (!file.isAbsolute()) {
return (ICSourceEntry) CDataUtil.createEntry(ICLanguageSettingEntry.SOURCE_PATH, path, null, exclusionPatterns, ICSettingEntry.VALUE_WORKSPACE_PATH | flags);
} else {
IContainer container = workspace.getContainerForLocation(Path.fromOSString(path));
if (container == null) {
return (ICSourceEntry) CDataUtil.createEntry(ICLanguageSettingEntry.SOURCE_PATH, path, null, exclusionPatterns, flags);
} else {
return (ICSourceEntry) CDataUtil.createEntry(ICLanguageSettingEntry.SOURCE_PATH, container.getFullPath().toOSString(), null, exclusionPatterns, ICSettingEntry.VALUE_WORKSPACE_PATH | flags);
}
}
}
use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project arduino-eclipse-plugin by Sloeber.
the class BoardDescriptor method createProject.
/*
* Method to create a project based on the board
*/
public IProject createProject(String projectName, URI projectURI, ArrayList<ConfigurationDescriptor> cfgNamesAndTCIds, CodeDescriptor codeDescription, CompileOptions compileOptions, IProgressMonitor monitor) throws Exception {
IProject projectHandle;
projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(Common.MakeNameCompileSafe(projectName));
// try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription desc = workspace.newProjectDescription(projectHandle.getName());
desc.setLocationURI(projectURI);
projectHandle.create(desc, monitor);
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
projectHandle.open(IResource.BACKGROUND_REFRESH, monitor);
// Creates the .cproject file with the configurations
ICProjectDescription prjCDesc = ShouldHaveBeenInCDT.setCProjectDescription(projectHandle, cfgNamesAndTCIds, true, monitor);
// Add the C C++ AVR and other needed Natures to the project
Helpers.addTheNatures(desc);
// Add the Arduino folder
Helpers.createNewFolder(projectHandle, Const.ARDUINO_CODE_FOLDER_NAME, null);
for (ConfigurationDescriptor curConfig : cfgNamesAndTCIds) {
ICConfigurationDescription configurationDescription = prjCDesc.getConfigurationByName(curConfig.configName);
compileOptions.save(configurationDescription);
save(configurationDescription);
}
// Set the path variables
// ArduinoHelpers.setProjectPathVariables(prjCDesc.getActiveConfiguration());
// Intermediately save or the adding code will fail
// Release is the active config (as that is the "IDE" Arduino
// type....)
ICConfigurationDescription defaultConfigDescription = prjCDesc.getConfigurationByName(cfgNamesAndTCIds.get(0).configName);
ICResourceDescription cfgd = defaultConfigDescription.getResourceDescription(new Path(new String()), true);
ICExclusionPatternPathEntry[] entries = cfgd.getConfiguration().getSourceEntries();
if (entries.length == 1) {
Path[] exclusionPath = new Path[6];
exclusionPath[0] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/?xamples/**");
exclusionPath[1] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/?xtras/**");
exclusionPath[2] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/test*/**");
exclusionPath[3] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/third-party/**");
exclusionPath[4] = new Path(LIBRARY_PATH_SUFFIX + "/**/._*");
exclusionPath[5] = new Path(LIBRARY_PATH_SUFFIX + "/?*/utility/*/*");
ICExclusionPatternPathEntry newSourceEntry = new CSourceEntry(entries[0].getFullPath(), exclusionPath, ICSettingEntry.VALUE_WORKSPACE_PATH);
ICSourceEntry[] out = null;
out = new ICSourceEntry[1];
out[0] = (ICSourceEntry) newSourceEntry;
try {
cfgd.getConfiguration().setSourceEntries(out);
} catch (CoreException e) {
// ignore
}
} else {
// this should not happen
}
Set<String> librariesToInstall = codeDescription.createFiles(projectHandle, monitor);
Libraries.addLibrariesToProject(projectHandle, defaultConfigDescription, librariesToInstall);
prjCDesc.setActiveConfiguration(defaultConfigDescription);
prjCDesc.setCdtProjectCreated();
CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(projectHandle, prjCDesc, true, null);
projectHandle.setDescription(desc, new NullProgressMonitor());
projectHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
monitor.done();
return projectHandle;
}
Aggregations