- Notifications
You must be signed in to change notification settings - Fork 133
#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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
jantje commented Aug 27, 2020
/* | ||
* 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.
jantje commented Aug 27, 2020
Comment on lines +521 to +607
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
No description provided.