use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project m2e-nar by maven-nar.
the class BuildPathManager method updateBuildPaths.
private void updateBuildPaths(IProject project, IProgressMonitor monitor) throws CoreException {
final IMavenProjectFacade facade = projectManager.getProject(project);
if (facade != null) {
final ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
final ICProjectDescription des = mngr.getProjectDescription(project, true);
if (des != null) {
boolean changed = false;
logger.debug("updateBuildPaths: project=" + project.getName());
final ConfiguratorContext context = new ConfiguratorContext(MavenPlugin.getMaven(), projectManager);
List<NarExecution> narExecutions = MavenUtils.buildCompileNarExecutions(context, facade, monitor);
narExecutions.addAll(MavenUtils.buildTestCompileNarExecutions(context, facade, monitor));
for (NarExecution narSettings : narExecutions) {
if (!narSettings.isSkip()) {
final String os = narSettings.getOS();
final String linkerName = narSettings.getLinkerName();
final AbstractSettingsSynchroniser synchro = SynchroniserFactory.getSettingsSynchroniser(os, linkerName);
changed = updateCdtBuildPaths(des, synchro, narSettings);
}
}
if (changed) {
mngr.setProjectDescription(project, des);
}
}
}
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project m2e-nar by maven-nar.
the class CProjectConfigurator method configure.
@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
final ConfiguratorContext context = new ConfiguratorContext(maven, projectManager);
IProject project = request.getProject();
monitor.setTaskName(Messages.CProjectConfigurator_task_name + project.getName());
logger.info("configure");
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
// Set the first created configuration as active.
boolean setActive = true;
final IMavenProjectFacade facade = request.getMavenProjectFacade();
List<NarExecution> narExecutions = MavenUtils.buildCompileNarExecutions(context, facade, monitor);
narExecutions.addAll(MavenUtils.buildTestCompileNarExecutions(context, facade, monitor));
for (NarExecution narSettings : narExecutions) {
if (!narSettings.isSkip()) {
final String os = narSettings.getOS();
final String linkerName = narSettings.getLinkerName();
final AbstractSettingsSynchroniser synchro = SynchroniserFactory.getSettingsSynchroniser(os, linkerName);
final String toolchain = synchro.getToolchain();
for (NarBuildArtifact artifactSettings : narSettings.getArtifactSettings()) {
final String configName = artifactSettings.getConfigName();
final String cdtArtefactType = CdtUtils.convertArtefactType(artifactSettings.getType());
IToolChain tc = getToolChain(toolchain, cdtArtefactType);
ICProjectDescription desc = getCdtProject(project, tc, cdtArtefactType, monitor);
ICConfigurationDescription cfg = getCdtMavenConfig(project, desc, tc, cdtArtefactType, configName, setActive, monitor);
setActive = false;
synchro.fullSync(cfg, artifactSettings);
mngr.setProjectDescription(project, desc);
}
}
}
AbstractProjectConfigurator jConfig = LifecycleMappingFactory.createProjectConfigurator(JAVA_CONFIGURATOR_ID);
jConfig.configure(request, monitor);
// ensure CDT builder is after the Maven one
boolean changed = false;
IProjectDescription description = project.getDescription();
ICommand cdtBuilder = null;
ICommand mavenBuilder = null;
ArrayList<ICommand> newSpec = new ArrayList<ICommand>();
for (ICommand command : description.getBuildSpec()) {
if (ManagedCProjectNature.getBuilderID().equals(command.getBuilderName()) && mavenBuilder == null) {
cdtBuilder = command;
} else {
newSpec.add(command);
}
if (IMavenConstants.BUILDER_ID.equals(command.getBuilderName())) {
mavenBuilder = command;
if (cdtBuilder != null) {
newSpec.add(cdtBuilder);
changed = true;
}
}
}
if (changed) {
description.setBuildSpec(newSpec.toArray(new ICommand[newSpec.size()]));
project.setDescription(description, monitor);
}
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project m2e-nar by maven-nar.
the class AbstractTestBuild method buildAllConfigurations.
protected void buildAllConfigurations(final IProject project) {
final ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(project, false);
if (prjd != null) {
final ICConfigurationDescription[] cfgDescriptions = prjd.getConfigurations();
if (cfgDescriptions != null && cfgDescriptions.length > 0) {
final IConfiguration[] cfgs = new IConfiguration[cfgDescriptions.length];
for (int i = 0; i < cfgDescriptions.length; ++i) {
cfgs[i] = ManagedBuildManager.getConfigurationForDescription(cfgDescriptions[i]);
}
final Job job = new Job("Building all configurations") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
ManagedBuildManager.buildConfigurations(cfgs, monitor);
} catch (CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
};
job.schedule();
waitForJobs();
}
}
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class TestProjectHolder method setupProjectReferencesAsync.
@Override
public ProjectHolderJob setupProjectReferencesAsync() {
return ProjectHolderJob.create("Setup members of project " + projectName, ITestProjectHolder.SETUP_PROJECT_REFERENCES_JOB_FAMILY, mon -> {
if (!referencedProjects.isEmpty()) {
final ICProjectDescription description = CCorePlugin.getDefault().getProjectDescription(getProject(), true);
for (final ICConfigurationDescription config : description.getConfigurations()) {
final Map<String, String> refMap = config.getReferenceInfo();
for (final ICProject refProject : referencedProjects) {
refMap.put(refProject.getProject().getName(), "");
}
config.setReferenceInfo(refMap);
}
CCorePlugin.getDefault().setProjectDescription(getProject(), description);
}
});
}
use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.
the class SloeberProject method createArduinoProject.
/*
* Method to create a project based on the board
*/
public static IProject createArduinoProject(String projectName, URI projectURI, BoardDescription boardDescriptor, CodeDescription codeDesc, CompileDescription compileDescriptor, OtherDescription otherDesc, IProgressMonitor monitor) {
String realProjectName = Common.MakeNameCompileSafe(projectName);
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
ICoreRunnable runnable = new ICoreRunnable() {
@Override
public void run(IProgressMonitor internalMonitor) throws CoreException {
IProject newProjectHandle = root.getProject(realProjectName);
IndexerController.doNotIndex(newProjectHandle);
try {
// create a eclipse project
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
if (projectURI != null) {
description.setLocationURI(projectURI);
}
newProjectHandle.create(description, internalMonitor);
newProjectHandle.open(internalMonitor);
// Add the sketch code
Map<String, IPath> librariesToAdd = codeDesc.createFiles(newProjectHandle, internalMonitor);
// Add the arduino code folders
List<IPath> addToIncludePath = Helpers.addArduinoCodeToProject(newProjectHandle, boardDescriptor);
Map<String, List<IPath>> pathMods = Libraries.addLibrariesToProject(newProjectHandle, librariesToAdd);
// make the eclipse project a cdt project
CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID);
// add the required natures
ManagedCProjectNature.addManagedNature(newProjectHandle, internalMonitor);
ManagedCProjectNature.addManagedBuilder(newProjectHandle, internalMonitor);
// $NON-NLS-1$
ManagedCProjectNature.addNature(newProjectHandle, "org.eclipse.cdt.core.ccnature", internalMonitor);
ManagedCProjectNature.addNature(newProjectHandle, Const.ARDUINO_NATURE_ID, internalMonitor);
// make the cdt project a managed build project
// $NON-NLS-1$
IProjectType sloeberProjType = ManagedBuildManager.getProjectType("io.sloeber.core.sketch");
ManagedBuildManager.createBuildInfo(newProjectHandle);
IManagedProject newProject = ManagedBuildManager.createManagedProject(newProjectHandle, sloeberProjType);
ManagedBuildManager.setNewProjectVersion(newProjectHandle);
// Copy over the Sloeber configs
IConfiguration defaultConfig = null;
IConfiguration[] configs = sloeberProjType.getConfigurations();
for (int i = 0; i < configs.length; ++i) {
IConfiguration curConfig = newProject.createConfiguration(configs[i], // $NON-NLS-1$
sloeberProjType.getId() + "." + i);
curConfig.setArtifactName(newProject.getDefaultArtifactName());
curConfig.getEditableBuilder().setParallelBuildOn(compileDescriptor.isParallelBuildEnabled());
// Make the first configuration the default
if (i == 0) {
defaultConfig = curConfig;
}
}
// create a sloeber project
SloeberProject arduinoProjDesc = new SloeberProject(newProjectHandle);
arduinoProjDesc.myIsInMemory = true;
// the line below will trigger environment var requests causing loops if called to early
ManagedBuildManager.setDefaultConfiguration(newProjectHandle, defaultConfig);
Map<String, String> configs2 = new HashMap<>();
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(newProjectHandle);
for (ICConfigurationDescription curConfigDesc : prjCDesc.getConfigurations()) {
arduinoProjDesc.myCompileDescriptions.put(getConfigKey(curConfigDesc), compileDescriptor);
arduinoProjDesc.myBoardDescriptions.put(getConfigKey(curConfigDesc), boardDescriptor);
arduinoProjDesc.myOtherDescriptions.put(getConfigKey(curConfigDesc), otherDesc);
Libraries.adjustProjectDescription(curConfigDesc, pathMods);
Helpers.addIncludeFolder(curConfigDesc, addToIncludePath, true);
String curConfigKey = getConfigKey(curConfigDesc);
arduinoProjDesc.myEnvironmentVariables.put(curConfigKey, arduinoProjDesc.getEnvVars(curConfigKey));
configs2.put(curConfigDesc.getName(), curConfigDesc.getId());
}
arduinoProjDesc.createSloeberConfigFiles(prjCDesc);
arduinoProjDesc.setAllEnvironmentVars(prjCDesc);
arduinoProjDesc.myIsInMemory = true;
SubMonitor refreshMonitor = SubMonitor.convert(internalMonitor, 3);
newProjectHandle.open(refreshMonitor);
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, refreshMonitor);
cCorePlugin.setProjectDescription(newProjectHandle, prjCDesc, true, null);
} catch (Exception e) {
Common.log(new Status(IStatus.INFO, io.sloeber.core.Activator.getId(), "Project creation failed: " + realProjectName, // $NON-NLS-1$
e));
}
Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(), // $NON-NLS-1$
"internal creation of project is done: " + realProjectName));
IndexerController.index(newProjectHandle);
}
};
try {
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor);
} catch (Exception e) {
Common.log(new Status(IStatus.INFO, io.sloeber.core.Activator.getId(), "Project creation failed: " + realProjectName, // $NON-NLS-1$
e));
}
monitor.done();
return root.getProject(realProjectName);
}
Aggregations