13
13
import java .io .InputStream ;
14
14
import java .io .InputStreamReader ;
15
15
import java .net .URI ;
16
+ import java .net .URISyntaxException ;
17
+ import java .net .URL ;
16
18
import java .util .ArrayList ;
17
19
import java .util .Calendar ;
18
20
import java .util .Date ;
54
56
import org .eclipse .core .resources .IWorkspace ;
55
57
import org .eclipse .core .resources .ResourcesPlugin ;
56
58
import org .eclipse .core .runtime .CoreException ;
59
+ import org .eclipse .core .runtime .FileLocator ;
57
60
import org .eclipse .core .runtime .IPath ;
58
61
import org .eclipse .core .runtime .IProgressMonitor ;
59
62
import org .eclipse .core .runtime .IStatus ;
64
67
import org .eclipse .ui .console .IConsole ;
65
68
import org .eclipse .ui .console .IConsoleManager ;
66
69
import org .eclipse .ui .console .MessageConsole ;
70
+ import org .osgi .framework .Bundle ;
67
71
68
72
/**
69
73
* ArduinoHelpers is a static class containing general purpose functions
@@ -739,11 +743,16 @@ private static boolean isThisMenuItemSelected(ArduinoBoards boardsFile, ICConfig
739
743
}
740
744
741
745
/**
742
- * This method creates environment variables based on the platform.txt and boards.txt platform.txt is processed first and then boards.txt. This
746
+ * This method creates environment variables based on the platform.txt and boards.txt. platform.txt is processed first and then boards.txt. This
743
747
* way boards.txt settings can overwrite common settings in platform.txt The environment variables are only valid for the project given as
744
748
* parameter The project properties are used to identify the boards.txt and platform.txt as well as the board id to select the settings in the
745
749
* board.txt file At the end also the path variable is set
746
750
*
751
+ * from arduino IDE 1.6.5 an additional file generated by the arduino ide is processed. This is the first file processed.
752
+ *
753
+ * To be able to quickly fix boards.txt and pmatform.txt problems I also added a arduino_eclipse_plugin.txt that is processed as a boards.txt file
754
+ * and is processed after the arduino delivered boards.txt file.
755
+ *
747
756
* @param project
748
757
* the project for which the environment variables are set
749
758
* @param arduinoProperties
@@ -759,16 +768,18 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
759
768
ArduinoInstancePreferences .getLastUsedBoardsFile ()));
760
769
IPath localPlatformFilename = new Path (Common .getBuildEnvironmentVariable (confDesc , ArduinoConst .ENV_KEY_JANTJE_PLATFORM_FILE , "" ));
761
770
762
- // if (!platformFilename.toFile().exists()) {
763
- // for (int cursegment = 0; cursegment < platformFilename.segmentCount(); cursegment++) {
764
- // if (ARDUINO_HARDWARE_FOLDER_NAME.equals(platformFilename.segment(cursegment))) {
765
- //
766
- // platformFilename = getArduinoPath().append(ARDUINO_HARDWARE_FOLDER_NAME).append("arduino")
767
- // .append(platformFilename.removeFirstSegments(cursegment + 2));
768
- // cursegment = platformFilename.segmentCount();
769
- // }
770
- // }
771
- // }
771
+ Bundle bundle = Platform .getBundle (ArduinoConst .CORE_PLUGIN_ID );
772
+ URL fileURL = bundle .getEntry ("config/arduino_eclipse_plugin.txt" );
773
+ File file = null ;
774
+ try {
775
+ file = new File (FileLocator .resolve (fileURL ).toURI ());
776
+ } catch (URISyntaxException e1 ) {
777
+ e1 .printStackTrace ();
778
+ } catch (IOException e1 ) {
779
+ e1 .printStackTrace ();
780
+ }
781
+
782
+ IPath arduinoEclipsePluginFile = new Path (file .getAbsolutePath ());
772
783
773
784
String boardID = Common .getBuildEnvironmentVariable (confDesc , ArduinoConst .ENV_KEY_JANTJE_BOARD_ID , "" );
774
785
String architecture = Common .getBuildEnvironmentVariable (confDesc , ArduinoConst .ENV_KEY_JANTJE_ARCITECTURE_ID , "" );
@@ -808,6 +819,13 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
808
819
}
809
820
// now process the boards file
810
821
setTheEnvironmentVariablesAddtheBoardsTxt (contribEnv , confDesc , boardsFile , boardID );
822
+
823
+ // also process the file as part of the plugin
824
+ if (arduinoEclipsePluginFile .toFile ().exists ()) {
825
+ ArduinoBoards myBoardsFile = new ArduinoBoards (arduinoEclipsePluginFile .toOSString ());
826
+ setTheEnvironmentVariablesAddtheBoardsTxt (contribEnv , confDesc , myBoardsFile , boardID );
827
+ }
828
+
811
829
// Do some post processing
812
830
setTheEnvironmentVariablesPostProcessing (contribEnv , confDesc );
813
831
0 commit comments