@@ -127,8 +127,8 @@ public class BoardDescriptor {
127
127
*/
128
128
private String myProjectName = emptyString ;
129
129
private String myOSName = Platform .getOS ();
130
- private String myWorkSpaceLocation = Common .getWorkspaceRoot (). toString ();
131
- private String myWorkEclipseLocation = ConfigurationPreferences .getEclipseHome (). toString ();
130
+ private IPath myWorkSpaceLocation = Common .getWorkspaceRoot ();
131
+ private IPath myWorkEclipseLocation = ConfigurationPreferences .getEclipseHome ();
132
132
133
133
/*
134
134
* Stuff to make things work
@@ -428,8 +428,8 @@ protected BoardDescriptor(ICConfigurationDescription confdesc) {
428
428
this .myProjectName = getFromBuildEnv (confdesc , ENV_KEY_JANTJE_PROJECT_NAME );
429
429
this .myTxtFile = new TxtFile (this .myreferencingBoardsFile , true );
430
430
this .myOSName = getFromBuildEnv (confdesc , ENV_KEY_JANTJE_OS );
431
- this .myWorkSpaceLocation = getFromBuildEnv (confdesc , ENV_KEY_JANTJE_WORKSPACE_LOCATION );
432
- this .myWorkEclipseLocation = getFromBuildEnv (confdesc , ENV_KEY_JANTJE_ECLIPSE_LOCATION );
431
+ this .myWorkSpaceLocation = new Path ( getFromBuildEnv (confdesc , ENV_KEY_JANTJE_WORKSPACE_LOCATION ) );
432
+ this .myWorkEclipseLocation = new Path ( getFromBuildEnv (confdesc , ENV_KEY_JANTJE_ECLIPSE_LOCATION ) );
433
433
String optinconcat = getFromBuildEnv (confdesc , ENV_KEY_JANTJE_MENU_SELECTION );
434
434
this .myOptions = KeyValue .makeMap (optinconcat );
435
435
}
@@ -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 .addManagedNature (newProjectHandle , internalMonitor );
606
+ ManagedCProjectNature .addManagedBuilder (newProjectHandle , internalMonitor );
607
+ ManagedCProjectNature .addNature (newProjectHandle , "org.eclipse.cdt.core.ccnature" , internalMonitor ); //$NON-NLS-1$
608
+ ManagedCProjectNature .addNature (newProjectHandle , Const .ARDUINO_NATURE_ID , 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 ();
@@ -705,7 +708,7 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
705
708
706
709
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_BOARD_NAME , getBoardName ());
707
710
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_BOARDS_FILE ,
708
- getReferencingBoardsFile (). toString () );
711
+ getReferencingBoardsFile ());
709
712
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_BOARD_ID , this .myBoardID );
710
713
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_ARCITECTURE_ID , getArchitecture ());
711
714
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_PACKAGE_ID , getPackage ());
@@ -725,11 +728,10 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
725
728
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_SERIAL_PORT_FILE ,
726
729
getActualUploadPort ().replace ("/dev/" , emptyString )); //$NON-NLS-1$
727
730
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_BUILD_ACTUAL_CORE_PATH ,
728
- getActualCoreCodePath (). toOSString () );
731
+ getActualCoreCodePath ());
729
732
IPath variantPath = getActualVariantPath ();
730
733
if (variantPath != null ) {
731
- Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_BUILD_VARIANT_PATH ,
732
- variantPath .toOSString ());
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
}
@@ -738,11 +740,11 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
738
740
// referencing such as jantjes hardware
739
741
740
742
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_REFERENCED_CORE_PLATFORM_PATH ,
741
- getReferencedCorePlatformPath (). toOSString () );
743
+ getReferencedCorePlatformPath ());
742
744
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_REFERENCED_VARIANT_PLATFORM_PATH ,
743
- getReferencedVariantPlatformPath (). toOSString () );
745
+ getReferencedVariantPlatformPath ());
744
746
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_REFERENCED_UPLOAD_PLATFORM_PATH ,
745
- getReferencedUploadPlatformPath (). toOSString () );
747
+ getReferencedUploadPlatformPath ());
746
748
747
749
}
748
750
@@ -919,11 +921,11 @@ private String getMyOSName() {
919
921
return this .myOSName ;
920
922
}
921
923
922
- private String getMyWorkSpaceLocation () {
924
+ private IPath getMyWorkSpaceLocation () {
923
925
return this .myWorkSpaceLocation ;
924
926
}
925
927
926
- private String getMyWorkEclipseLocation () {
928
+ private IPath getMyWorkEclipseLocation () {
927
929
return this .myWorkEclipseLocation ;
928
930
}
929
931
@@ -1031,9 +1033,9 @@ public String getUploadCommand(ICConfigurationDescription confdesc) {
1031
1033
}
1032
1034
String networkPrefix = empty ;
1033
1035
if (isNetworkUpload ()) {
1034
- networkPrefix = Const .NETWORK_PREFIX ;
1036
+ networkPrefix = DOT + Const .NETWORK_PREFIX ;
1035
1037
}
1036
- String key = Const .A_TOOLS + upLoadTool + DOT + action + DOT + networkPrefix + DOT + Const .PATTERN ;
1038
+ String key = Const .A_TOOLS + upLoadTool + DOT + action + networkPrefix + DOT + Const .PATTERN ;
1037
1039
String ret = Common .getBuildEnvironmentVariable (confdesc , key , empty );
1038
1040
if (ret .isEmpty ()) {
1039
1041
Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , key + " : not found in the platform.txt file" )); //$NON-NLS-1$
@@ -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