@@ -575,7 +575,7 @@ public boolean configureProject(IProject project, IProgressMonitor monitor) {
575
575
* Method to create a project based on the board
576
576
*/
577
577
public IProject createProject (String projectName , URI projectURI , CodeDescriptor codeDescription ,
578
- CompileOptions compileOptions , IProgressMonitor monitor ) {
578
+ CompileOptions compileOptions , IProgressMonitor monitor ) {
579
579
580
580
String realProjectName = Common .MakeNameCompileSafe (projectName );
581
581
@@ -584,70 +584,73 @@ public IProject createProject(String projectName, URI projectURI, CodeDescriptor
584
584
final IWorkspace workspace = ResourcesPlugin .getWorkspace ();
585
585
ICoreRunnable runnable = new ICoreRunnable () {
586
586
@ Override
587
- public void run (IProgressMonitor internalMonitor ) throws CoreException {
587
+ public void run (IProgressMonitor internalMonitor ) throws CoreException {
588
588
try {
589
- // Create the base project
590
589
IWorkspaceDescription workspaceDesc = workspace .getDescription ();
591
590
workspaceDesc .setAutoBuilding (false );
592
591
workspace .setDescription (workspaceDesc );
592
+ IProjectType sloeberProjType = ManagedBuildManager .getProjectType ("io.sloeber.core.sketch" ); //$NON-NLS-1$
593
593
594
+ // create a eclipse project
594
595
IProjectDescription description = workspace .newProjectDescription (newProjectHandle .getName ());
595
596
if (projectURI != null ) {
596
597
description .setLocationURI (projectURI );
597
598
}
598
599
600
+ // make the eclipse project a cdt project
599
601
CCorePlugin .getDefault ().createCProject (description , newProjectHandle , new NullProgressMonitor (),
600
602
ManagedBuilderCorePlugin .MANAGED_MAKE_PROJECT_ID );
601
- // Add the managed build nature and builder
602
- addManagedBuildNature (newProjectHandle );
603
603
604
- // Find the base project type definition
605
- IProjectType projType = ManagedBuildManager .getProjectType ("io.sloeber.core.sketch" ); //$NON-NLS-1$
604
+ // add the required natures
605
+ ManagedCProjectNature .addNature (newProjectHandle , "org.eclipse.cdt.core.ccnature" , internalMonitor ); //$NON-NLS-1$
606
+ ManagedCProjectNature .addNature (newProjectHandle , Const .ARDUINO_NATURE_ID , internalMonitor );
607
+ ManagedCProjectNature .addManagedNature (newProjectHandle , internalMonitor );
608
+ ManagedCProjectNature .addManagedBuilder (newProjectHandle , internalMonitor );
609
+
606
610
607
- // Create the managed-project (.cdtbuild) for our project that builds an
608
- // executable.
609
- IManagedProject newProject = null ;
610
- newProject = ManagedBuildManager .createManagedProject (newProjectHandle , projType );
611
+
612
+ // make the cdt project a managed build project
613
+ ManagedBuildManager .createBuildInfo (newProjectHandle );
614
+ IManagedProject newProject = ManagedBuildManager .createManagedProject (newProjectHandle ,
615
+ sloeberProjType );
611
616
ManagedBuildManager .setNewProjectVersion (newProjectHandle );
612
- // Copy over the configs
617
+ // Copy over the Sloeber configs
613
618
IConfiguration defaultConfig = null ;
614
- IConfiguration [] configs = projType .getConfigurations ();
619
+ IConfiguration [] configs = sloeberProjType .getConfigurations ();
615
620
for (int i = 0 ; i < configs .length ; ++i ) {
621
+ IConfiguration curConfig = newProject .createConfiguration (configs [i ],
622
+ sloeberProjType .getId () + "." + i ); //$NON-NLS-1$
623
+ curConfig .setArtifactName (newProject .getDefaultArtifactName ());
616
624
// Make the first configuration the default
617
625
if (i == 0 ) {
618
- defaultConfig = newProject .createConfiguration (configs [i ], projType .getId () + "." + i ); //$NON-NLS-1$
619
- } else {
620
- newProject .createConfiguration (configs [i ], projType .getId () + "." + i ); //$NON-NLS-1$
626
+ defaultConfig = curConfig ;
621
627
}
622
628
}
623
- ManagedBuildManager .setDefaultConfiguration (newProjectHandle , defaultConfig );
624
629
625
- IConfiguration cfgs [] = newProject .getConfigurations ();
626
- for (int i = 0 ; i < cfgs .length ; i ++) {
627
- cfgs [i ].setArtifactName (newProject .getDefaultArtifactName ());
628
- }
630
+ ManagedBuildManager .setDefaultConfiguration (newProjectHandle , defaultConfig );
629
631
Map <String , IPath > librariesToAdd = codeDescription .createFiles (newProjectHandle ,
630
632
new NullProgressMonitor ());
631
633
632
- ManagedCProjectNature .addNature (newProjectHandle , "org.eclipse.cdt.core.ccnature" , internalMonitor ); //$NON-NLS-1$
633
- ManagedCProjectNature .addNature (newProjectHandle , Const .ARDUINO_NATURE_ID , internalMonitor );
634
-
635
634
CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
636
635
ICProjectDescription prjCDesc = cCorePlugin .getProjectDescription (newProjectHandle );
637
- Libraries . addLibrariesToProject ( newProjectHandle , prjCDesc . getActiveConfiguration (), librariesToAdd );
636
+
638
637
for (ICConfigurationDescription curConfig : prjCDesc .getConfigurations ()) {
639
638
compileOptions .save (curConfig );
640
639
save (curConfig );
640
+ Libraries .addLibrariesToProject (newProjectHandle , curConfig , librariesToAdd );
641
641
}
642
+
642
643
SubMonitor refreshMonitor = SubMonitor .convert (internalMonitor , 3 );
643
644
newProjectHandle .open (refreshMonitor );
644
645
newProjectHandle .refreshLocal (IResource .DEPTH_INFINITE , refreshMonitor );
645
646
cCorePlugin .setProjectDescription (newProjectHandle , prjCDesc , true , null );
647
+
646
648
} catch (Exception e ) {
647
649
Common .log (new Status (IStatus .INFO , io .sloeber .core .Activator .getId (),
648
650
"Project creation failed: " + newProjectHandle .getName (), e )); //$NON-NLS-1$
649
651
}
650
- Common .log (new Status (Const .SLOEBER_STATUS_DEBUG , Activator .getId (),"internal creation of project is done: " +newProjectHandle .getName ())); //$NON-NLS-1$
652
+ Common .log (new Status (Const .SLOEBER_STATUS_DEBUG , Activator .getId (),
653
+ "internal creation of project is done: " + newProjectHandle .getName ())); //$NON-NLS-1$
651
654
}
652
655
};
653
656
@@ -656,7 +659,7 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
656
659
workspace .run (runnable , root , IWorkspace .AVOID_UPDATE , monitor );
657
660
} catch (Exception e ) {
658
661
Common .log (new Status (IStatus .INFO , io .sloeber .core .Activator .getId (),
659
- "Project creation failed: " + newProjectHandle .getName (),e )); //$NON-NLS-1$
662
+ "Project creation failed: " + newProjectHandle .getName (), e )); //$NON-NLS-1$
660
663
}
661
664
662
665
monitor .done ();
@@ -728,8 +731,7 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
728
731
getActualCoreCodePath ());
729
732
IPath variantPath = getActualVariantPath ();
730
733
if (variantPath != null ) {
731
- Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_BUILD_VARIANT_PATH ,
732
- variantPath );
734
+ Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_BUILD_VARIANT_PATH , variantPath );
733
735
} else {// teensy does not use variants
734
736
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_BUILD_VARIANT_PATH , emptyString );
735
737
}
@@ -1100,26 +1102,5 @@ public boolean isNetworkUpload() {
1100
1102
return getHost () != null ;
1101
1103
}
1102
1104
1103
- static private void addManagedBuildNature (IProject project ) throws Exception {
1104
- // Create the buildinformation object for the project
1105
- ManagedBuildManager .createBuildInfo (project );
1106
-
1107
- // Add the managed build nature
1108
- ManagedCProjectNature .addManagedNature (project , new NullProgressMonitor ());
1109
- ManagedCProjectNature .addManagedBuilder (project , new NullProgressMonitor ());
1110
-
1111
- // Associate the project with the managed builder so the clients can get proper
1112
- // information
1113
1105
1114
- CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
1115
- ICProjectDescription projDesc = cCorePlugin .getProjectDescription (project , true );
1116
-
1117
- for (ICConfigurationDescription curConfig : projDesc .getConfigurations ()) {
1118
- curConfig .remove (CCorePlugin .BUILD_SCANNER_INFO_UNIQ_ID );
1119
- curConfig .create (CCorePlugin .BUILD_SCANNER_INFO_UNIQ_ID , ManagedBuildManager .INTERFACE_IDENTITY );
1120
- }
1121
-
1122
- cCorePlugin .setProjectDescription (project , projDesc , true , null );
1123
-
1124
- }
1125
1106
}
0 commit comments