Skip to content

Commit 4eab5b6

Browse files
committed
To make zero work under windows
1 parent 67100d5 commit 4eab5b6

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

it.baeyens.arduino.common/src/it/baeyens/arduino/common/ArduinoConst.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class ArduinoConst {
1010
// General stuff
1111
public static final String PluginStart = "it.baeyens."; //$NON-NLS-1$
12-
public static final String CORE_PLUGIN_ID = PluginStart + "core"; //$NON-NLS-1$
12+
public static final String CORE_PLUGIN_ID = PluginStart + "arduino.core"; //$NON-NLS-1$
1313

1414
// prefix to be added to the arduino environment
1515
protected static final String UploadPortPrefix_WIN = "-P\\\\.\\"; //$NON-NLS-1$

it.baeyens.arduino.core/build.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ bin.includes = .,\
1111
OSGI-INF/,\
1212
OSGI-INF/l10n/bundle.properties,\
1313
lib/jsch-0.1.50.jar,\
14-
lib/jmdns-3.4.1.jar
14+
lib/jmdns-3.4.1.jar,\
15+
config/
1516
src.includes = icons/,\
1617
bin/
1718
jars.compile.order = .,\
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#for the zero to be able to compile
2+
arduino_zero_edbg.build.usb_product.windows=\"Arduino Zero\"
3+
arduino_zero_edbg.build.usb_manufacturer.windows=\"Arduino LLC\"
4+
arduino_zero_edbg.build.usb_flags.windows=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON "-DUSB_MANUFACTURER={build.usb_manufacturer}" "-DUSB_PRODUCT={build.usb_product}"
5+
arduino_zero_native.build.usb_product.windows=\"Arduino Zero\"
6+
arduino_zero_native.build.usb_manufacturer.windows=\"Arduino LLC\"
7+
arduino_zero_native.build.usb_flags.windows=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON "-DUSB_MANUFACTURER={build.usb_manufacturer}" "-DUSB_PRODUCT={build.usb_product}"

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/ArduinoHelpers.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.io.InputStream;
1414
import java.io.InputStreamReader;
1515
import java.net.URI;
16+
import java.net.URISyntaxException;
17+
import java.net.URL;
1618
import java.util.ArrayList;
1719
import java.util.Calendar;
1820
import java.util.Date;
@@ -54,6 +56,7 @@
5456
import org.eclipse.core.resources.IWorkspace;
5557
import org.eclipse.core.resources.ResourcesPlugin;
5658
import org.eclipse.core.runtime.CoreException;
59+
import org.eclipse.core.runtime.FileLocator;
5760
import org.eclipse.core.runtime.IPath;
5861
import org.eclipse.core.runtime.IProgressMonitor;
5962
import org.eclipse.core.runtime.IStatus;
@@ -64,6 +67,7 @@
6467
import org.eclipse.ui.console.IConsole;
6568
import org.eclipse.ui.console.IConsoleManager;
6669
import org.eclipse.ui.console.MessageConsole;
70+
import org.osgi.framework.Bundle;
6771

6872
/**
6973
* ArduinoHelpers is a static class containing general purpose functions
@@ -739,11 +743,16 @@ private static boolean isThisMenuItemSelected(ArduinoBoards boardsFile, ICConfig
739743
}
740744

741745
/**
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
743747
* way boards.txt settings can overwrite common settings in platform.txt The environment variables are only valid for the project given as
744748
* 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
745749
* board.txt file At the end also the path variable is set
746750
*
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+
*
747756
* @param project
748757
* the project for which the environment variables are set
749758
* @param arduinoProperties
@@ -759,16 +768,18 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
759768
ArduinoInstancePreferences.getLastUsedBoardsFile()));
760769
IPath localPlatformFilename = new Path(Common.getBuildEnvironmentVariable(confDesc, ArduinoConst.ENV_KEY_JANTJE_PLATFORM_FILE, ""));
761770

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());
772783

773784
String boardID = Common.getBuildEnvironmentVariable(confDesc, ArduinoConst.ENV_KEY_JANTJE_BOARD_ID, "");
774785
String architecture = Common.getBuildEnvironmentVariable(confDesc, ArduinoConst.ENV_KEY_JANTJE_ARCITECTURE_ID, "");
@@ -808,6 +819,13 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
808819
}
809820
// now process the boards file
810821
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+
811829
// Do some post processing
812830
setTheEnvironmentVariablesPostProcessing(contribEnv, confDesc);
813831

0 commit comments

Comments
 (0)