use of org.eclipse.cdt.core.settings.model.CSourceEntry 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.CSourceEntry 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;
}
use of org.eclipse.cdt.core.settings.model.CSourceEntry in project usbdm-eclipse-plugins by podonoghue.
the class ProjectUtilities method createNewStyleProjectFolder.
/**
* @param monitor
* @param projectHandle
* @param folder
* @throws CoreException
* @throws WriteAccessException
*/
private static void createNewStyleProjectFolder(IProgressMonitor monitor, IProject projectHandle, IFolder folder) throws CoreException, WriteAccessException {
ICSourceEntry newEntry = new CSourceEntry(folder, null, 0);
ICProjectDescription description = CCorePlugin.getDefault().getProjectDescription(projectHandle);
ICConfigurationDescription[] configs = description.getConfigurations();
for (int i = 0; i < configs.length; i++) {
ICConfigurationDescription config = configs[i];
ICSourceEntry[] entries = config.getSourceEntries();
Set<ICSourceEntry> set = new HashSet<ICSourceEntry>();
for (int j = 0; j < entries.length; j++) {
if (new Path(entries[j].getValue()).segmentCount() == 1)
continue;
set.add(entries[j]);
}
set.add(newEntry);
config.setSourceEntries(set.toArray(new ICSourceEntry[set.size()]));
}
CCorePlugin.getDefault().setProjectDescription(projectHandle, description, false, monitor);
}
Aggregations