-
Notifications
You must be signed in to change notification settings - Fork 132
#1163 create project the cdt way #1201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
https://github.com/Sloeber/arduino-eclipse-plugin.git into #1163_create_project_the_cdt_way Conflicts: io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java io.sloeber.core/src/io/sloeber/core/tools/Helpers.java io.sloeber.core/src/io/sloeber/core/tools/ShouldHaveBeenInCDT.java
/* | ||
* Method to create a project based on the board | ||
*/ | ||
public IProject createProject(String projectName, URI projectURI, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the old create project that uses the "shouldhaveBeeninCDT.java" that has been deleted.
public IProject createProject(String projectName, URI projectURI, CodeDescriptor codeDescription, | ||
CompileOptions compileOptions, IProgressMonitor monitor) throws Exception { | ||
|
||
String realProjectName = Common.MakeNameCompileSafe(projectName); | ||
// IProject newProjectHandle = ManagedBuildTestHelper.createProject(realProjectName, projectURI, | ||
// "io.sloeber.core.sketch"); | ||
|
||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); | ||
final IProject newProjectHandle = root.getProject(realProjectName); | ||
final IWorkspace workspace = ResourcesPlugin.getWorkspace(); | ||
|
||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() { | ||
@Override | ||
public void run(IProgressMonitor monitor) throws CoreException { | ||
|
||
try { | ||
// Create the base project | ||
IWorkspaceDescription workspaceDesc = workspace.getDescription(); | ||
workspaceDesc.setAutoBuilding(false); | ||
workspace.setDescription(workspaceDesc); | ||
|
||
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); | ||
if (projectURI != null) { | ||
description.setLocationURI(projectURI); | ||
} | ||
|
||
CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), | ||
ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); | ||
// Add the managed build nature and builder | ||
addManagedBuildNature(newProjectHandle); | ||
|
||
// Find the base project type definition | ||
IProjectType projType = ManagedBuildManager.getProjectType("io.sloeber.core.sketch"); | ||
|
||
// Create the managed-project (.cdtbuild) for our project that builds an | ||
// executable. | ||
IManagedProject newProject = null; | ||
newProject = ManagedBuildManager.createManagedProject(newProjectHandle, projType); | ||
ManagedBuildManager.setNewProjectVersion(newProjectHandle); | ||
// Copy over the configs | ||
IConfiguration defaultConfig = null; | ||
IConfiguration[] configs = projType.getConfigurations(); | ||
for (int i = 0; i < configs.length; ++i) { | ||
// Make the first configuration the default | ||
if (i == 0) { | ||
defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i); //$NON-NLS-1$ | ||
} else { | ||
newProject.createConfiguration(configs[i], projType.getId() + "." + i); //$NON-NLS-1$ | ||
} | ||
} | ||
ManagedBuildManager.setDefaultConfiguration(newProjectHandle, defaultConfig); | ||
|
||
IConfiguration cfgs[] = newProject.getConfigurations(); | ||
for (int i = 0; i < cfgs.length; i++) { | ||
cfgs[i].setArtifactName(newProject.getDefaultArtifactName()); | ||
} | ||
codeDescription.createFiles(newProjectHandle, new NullProgressMonitor()); | ||
ManagedCProjectNature.addNature(newProjectHandle, "org.eclipse.cdt.core.ccnature", monitor); | ||
ManagedCProjectNature.addNature(newProjectHandle, Const.ARDUINO_NATURE_ID, monitor); | ||
|
||
CCorePlugin cCorePlugin = CCorePlugin.getDefault(); | ||
ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(newProjectHandle); | ||
for (ICConfigurationDescription curConfig : prjCDesc.getConfigurations()) { | ||
compileOptions.save(curConfig); | ||
save(curConfig); | ||
} | ||
cCorePlugin.setProjectDescription(newProjectHandle, prjCDesc, true, null); | ||
|
||
ManagedBuildManager.getBuildInfo(newProjectHandle).setValid(true); | ||
} catch (Exception e) { | ||
|
||
return; | ||
} | ||
|
||
} | ||
}; | ||
|
||
try { | ||
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor); | ||
} catch (CoreException e2) { | ||
|
||
} | ||
|
||
monitor.done(); | ||
|
||
return newProjectHandle; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is the new way that still kicks in the indexer to early
No description provided.