Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'toolchains/arduino/org.eclipse.cdt.arduino.core')
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/.classpath8
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/.gitignore2
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/.project34
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.m2e.core.prefs4
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF22
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/about.html24
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/build.properties8
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/libs/freemarker-2.3.22.jarbin0 -> 1300487 bytes
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml151
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/pom.xml17
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/schema/consoleService.exsd102
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoLaunchConsoleService.java23
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoProjectGenerator.java211
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/Board.java41
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoBoardManager.java21
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoRemoteConnection.java45
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java61
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoHome.java40
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoProjectNature.java50
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/AvrLanguageSettingsProvider.java71
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/EnvVarSupplier.java154
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Messages.java28
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java182
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java24
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchDescriptorType.java40
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/messages.properties13
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoBoardManager.java85
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnection.java115
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/templates/Makefile3
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/templates/arduino.cpp9
31 files changed, 1595 insertions, 0 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/.classpath b/toolchains/arduino/org.eclipse.cdt.arduino.core/.classpath
new file mode 100644
index 00000000000..cb036ff1ca2
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry exported="true" kind="lib" path="libs/freemarker-2.3.22.jar"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/.gitignore b/toolchains/arduino/org.eclipse.cdt.arduino.core/.gitignore
new file mode 100644
index 00000000000..09e3bc9b241
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/.gitignore
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/.project b/toolchains/arduino/org.eclipse.cdt.arduino.core/.project
new file mode 100644
index 00000000000..dd517dedd34
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.arduino.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.jdt.core.prefs b/toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f42de363afa
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.m2e.core.prefs b/toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000000..f897a7f1cb2
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF b/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..9226c305c68
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Arduino C++ Core
+Bundle-SymbolicName: org.eclipse.cdt.arduino.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.arduino.core.internal.Activator
+Bundle-Vendor: Doug Schaefer
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.cdt.core,
+ org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.managedbuilder.gnu.ui,
+ org.eclipse.launchbar.core,
+ org.eclipse.remote.core;bundle-version="2.0.0",
+ org.eclipse.cdt.native.serial;bundle-version="1.0.0",
+ org.eclipse.remote.serial.core;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: libs/freemarker-2.3.22.jar,
+ .
+Export-Package: org.eclipse.cdt.arduino.core
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/about.html b/toolchains/arduino/org.eclipse.cdt.arduino.core/about.html
new file mode 100644
index 00000000000..d7c511887d6
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 22, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/build.properties b/toolchains/arduino/org.eclipse.cdt.arduino.core/build.properties
new file mode 100644
index 00000000000..3d058e35069
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ templates/,\
+ libs/freemarker-2.3.22.jar,\
+ about.html,\
+ schema/
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/libs/freemarker-2.3.22.jar b/toolchains/arduino/org.eclipse.cdt.arduino.core/libs/freemarker-2.3.22.jar
new file mode 100644
index 00000000000..a67a1c127e3
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/libs/freemarker-2.3.22.jar
Binary files differ
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
new file mode 100644
index 00000000000..21dab122fb0
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="consoleService" name="Arduino Launch Console Service" schema="schema/consoleService.exsd"/>
+ <extension
+ point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
+ <managedBuildRevision
+ fileVersion="4.0.0">
+ </managedBuildRevision>
+ <toolChain
+ archList="all"
+ configurationEnvironmentSupplier="org.eclipse.cdt.arduino.core.internal.EnvVarSupplier"
+ id="org.eclipse.cdt.arduino.toolChain.avr"
+ isAbstract="false"
+ languageSettingsProviders="org.eclipse.cdt.arduino.avr.builtins;org.eclipse.cdt.arduino.avr.outputParser"
+ name="Arduino AVR C++"
+ osList="all"
+ supportsManagedBuild="false">
+ <targetPlatform
+ id="org.eclipse.cdt.arduino.targetPlatform"
+ isAbstract="false"
+ name="Arduino">
+ </targetPlatform>
+ <builder
+ autoBuildTarget="all"
+ buildRunner="org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner"
+ cleanBuildTarget="clean"
+ command="make"
+ commandLauncher="org.eclipse.cdt.core.CommandLauncher"
+ id="org.eclipse.cdt.arduino.builder.make"
+ incrementalBuildTarget="all"
+ isAbstract="false"
+ isVariableCaseSensitive="false"
+ name="Arduino Make">
+ </builder>
+ <tool
+ command="avr-g++"
+ id="org.eclipse.cdt.arduino.tool.avr.compiler"
+ isAbstract="false"
+ name="Arduino AVR C++ Compiler"
+ natureFilter="ccnature"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+ </tool>
+ <option
+ category="org.eclipse.cdt.arduino.optionCategory.board"
+ id="org.eclipse.cdt.arduino.option.board"
+ isAbstract="false"
+ name="Board Type"
+ resourceFilter="all"
+ valueType="string">
+ </option>
+ <optionCategory
+ id="org.eclipse.cdt.arduino.optionCategory.board"
+ name="Board Type">
+ </optionCategory>
+ </toolChain>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.LanguageSettingsProvider">
+ <provider
+ class="org.eclipse.cdt.arduino.core.internal.AvrLanguageSettingsProvider"
+ id="org.eclipse.cdt.arduino.avr.builtins"
+ name="Arduino AVR Compiler Built-ins"
+ parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;"
+ prefer-non-shared="true">
+ <language-scope
+ id="org.eclipse.cdt.core.g++">
+ </language-scope>
+ </provider>
+ <provider
+ class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser"
+ id="org.eclipse.cdt.arduino.avr.outputParser"
+ name="Arduino AVR Built Output Parser"
+ parameter="(avr-gcc)|(avr-g\+\+)"
+ prefer-non-shared="true">
+ </provider>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.eclipse.cdt.arduino.core.internal.launch.ArduinoLaunchConfigurationDelegate"
+ id="org.eclipse.cdt.arduino.core.launchConfigurationType"
+ modes="run"
+ name="Arduino">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.remote.core.remoteServices">
+ <connectionType
+ capabilities="7"
+ id="org.eclipse.cdt.arduino.core.connectionType"
+ name="Arduino">
+ </connectionType>
+ <connectionService
+ connectionTypeId="org.eclipse.cdt.arduino.core.connectionType"
+ factory="org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection$Factory"
+ service="org.eclipse.cdt.arduino.core.IArduinoRemoteConnection">
+ </connectionService>
+ <connectionService
+ connectionTypeId="org.eclipse.cdt.arduino.core.connectionType"
+ factory="org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection$Factory"
+ service="org.eclipse.remote.core.IRemoteCommandShellService">
+ </connectionService>
+ <connectionService
+ connectionTypeId="org.eclipse.cdt.arduino.core.connectionType"
+ factory="org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection$Factory"
+ service="org.eclipse.remote.core.IRemoteConnectionPropertyService">
+ </connectionService>
+ </extension>
+ <extension
+ point="org.eclipse.launchbar.core.launchBarContributions">
+ <descriptorType
+ class="org.eclipse.cdt.arduino.core.internal.launch.ArduinoLaunchDescriptorType"
+ id="org.eclipse.cdt.arduino.core.descriptorType"
+ priority="5">
+ </descriptorType>
+ <configProvider
+ class="org.eclipse.cdt.arduino.core.internal.launch.ArduinoLaunchConfigurationProvider"
+ launchConfigurationType="org.eclipse.cdt.arduino.core.launchConfigurationType">
+ </configProvider>
+ <configType
+ descriptorType="org.eclipse.cdt.arduino.core.descriptorType"
+ isDefault="true"
+ launchConfigurationType="org.eclipse.cdt.arduino.core.launchConfigurationType"
+ targetType="org.eclipse.cdt.arduino.core.targetType">
+ </configType>
+ <targetType
+ connectionTypeId="org.eclipse.cdt.arduino.core.connectionType"
+ id="org.eclipse.cdt.arduino.core.targetType">
+ </targetType>
+ </extension>
+ <extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.cdt.core.binaryFile"
+ file-extensions="hex"
+ id="org.eclipse.cdt.arduino.core.contentType.hex"
+ name="Arduino Hex download file"
+ priority="normal">
+ </content-type>
+ </extension>
+ <extension
+ id="arduinoNature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.eclipse.cdt.arduino.core.internal.ArduinoProjectNature">
+ </run>
+ </runtime>
+ </extension>
+</plugin>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/pom.xml b/toolchains/arduino/org.eclipse.cdt.arduino.core/pom.xml
new file mode 100644
index 00000000000..4b2ac95fd09
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>8.6.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.cdt.arduino.core</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/schema/consoleService.exsd b/toolchains/arduino/org.eclipse.cdt.arduino.core/schema/consoleService.exsd
new file mode 100644
index 00000000000..e56c770ca91
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/schema/consoleService.exsd
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.arduino.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.cdt.arduino.core" id="consoleService" name="Arduino Launch Console Service"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="provider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.arduino.core.internal.launch.ArduinoLaunchConsoleService"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoLaunchConsoleService.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoLaunchConsoleService.java
new file mode 100644
index 00000000000..41b871d0152
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoLaunchConsoleService.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core;
+
+
+public interface ArduinoLaunchConsoleService {
+
+ /**
+ * Capture the output for the process and display on the console.
+ *
+ * @param process
+ */
+ void monitor(Process process);
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoProjectGenerator.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoProjectGenerator.java
new file mode 100644
index 00000000000..d80377612f6
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/ArduinoProjectGenerator.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.Writer;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.arduino.core.internal.Activator;
+import org.eclipse.cdt.arduino.core.internal.ArduinoProjectNature;
+import org.eclipse.cdt.arduino.core.internal.Messages;
+import org.eclipse.cdt.arduino.core.internal.launch.ArduinoLaunchConfigurationDelegate;
+import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
+
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+
+@SuppressWarnings("restriction")
+public class ArduinoProjectGenerator {
+
+ public static final String BOARD_OPTION_ID = "org.eclipse.cdt.arduino.option.board"; //$NON-NLS-1$
+ public static final String AVR_TOOLCHAIN_ID = "org.eclipse.cdt.arduino.toolChain.avr"; //$NON-NLS-1$
+
+ private final IProject project;
+ private IFile sourceFile;
+
+ public ArduinoProjectGenerator(IProject project) {
+ this.project = project;
+ }
+
+ public void setupArduinoProject(IProgressMonitor monitor) throws CoreException {
+ // create the CDT-ness of the project
+ IProjectDescription projDesc = project.getDescription();
+ CCorePlugin.getDefault().createCDTProject(projDesc, project, monitor);
+
+ String[] oldIds = projDesc.getNatureIds();
+ String[] newIds = new String[oldIds.length + 3];
+ System.arraycopy(oldIds, 0, newIds, 0, oldIds.length);
+ newIds[newIds.length - 1] = ArduinoProjectNature.ID;
+ newIds[newIds.length - 2] = CCProjectNature.CC_NATURE_ID;
+ newIds[newIds.length - 3] = CProjectNature.C_NATURE_ID;
+ projDesc.setNatureIds(newIds);
+ project.setDescription(projDesc, monitor);
+
+ ICProjectDescription cprojDesc = CCorePlugin.getDefault().createProjectDescription(project, false);
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ ManagedProject mProj = new ManagedProject(cprojDesc);
+ info.setManagedProject(mProj);
+
+ Board board = null;
+
+ IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
+ IRemoteLaunchConfigService remoteLaunchService = Activator.getService(IRemoteLaunchConfigService.class);
+ IRemoteConnection remoteConnection = remoteLaunchService.getLastActiveConnection(ArduinoLaunchConfigurationDelegate.getLaunchConfigurationType());
+ if (remoteConnection != null) {
+ IArduinoRemoteConnection arduinoRemote = remoteConnection.getService(IArduinoRemoteConnection.class);
+ board = arduinoRemote.getBoard();
+ } else {
+ IRemoteConnectionType connectionType = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
+ Collection<IRemoteConnection> connections = connectionType.getConnections();
+ if (!connections.isEmpty()) {
+ IRemoteConnection firstConnection = connections.iterator().next();
+ IArduinoRemoteConnection firstArduino = firstConnection.getService(IArduinoRemoteConnection.class);
+ board = firstArduino.getBoard();
+ }
+ }
+
+ if (board == null) {
+ IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
+ board = boardManager.getBoard("uno"); // the default //$NON-NLS-1$
+ }
+
+ createBuildConfiguration(cprojDesc, board);
+
+ CCorePlugin.getDefault().setProjectDescription(project, cprojDesc, true, monitor);
+
+ // Generate files
+ try {
+ Configuration fmConfig = new Configuration(Configuration.VERSION_2_3_22);
+ URL templateDirURL = FileLocator.find(Activator.getContext().getBundle(), new Path("/templates"), null); //$NON-NLS-1$
+ fmConfig.setDirectoryForTemplateLoading(new File(FileLocator.toFileURL(templateDirURL).toURI()));
+
+ final Map<String, Object> fmModel = new HashMap<>();
+ fmModel.put("projectName", project.getName()); //$NON-NLS-1$
+
+ generateFile(fmModel, fmConfig.getTemplate("Makefile"), project.getFile("Makefile")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ sourceFile = project.getFile(project.getName() + ".cpp"); //$NON-NLS-1$
+ generateFile(fmModel, fmConfig.getTemplate("arduino.cpp"), sourceFile); //$NON-NLS-1$
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
+ } catch (URISyntaxException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
+ } catch (TemplateException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
+ }
+
+ // Do the initial build
+ project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ }
+
+ private static void generateFile(Object model, Template template, final IFile outputFile) throws TemplateException, IOException, CoreException {
+ final PipedInputStream in = new PipedInputStream();
+ PipedOutputStream out = new PipedOutputStream(in);
+ final Writer writer = new OutputStreamWriter(out);
+ Job job = new Job(Messages.ArduinoProjectGenerator_0) {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ outputFile.create(in, true, monitor);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setRule(outputFile.getProject());
+ job.schedule();
+ template.process(model, writer);
+ writer.close();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // TODO anything?
+ }
+ IStatus status = job.getResult();
+ if (!status.isOK())
+ throw new CoreException(status);
+ }
+
+ public static ICConfigurationDescription createBuildConfiguration(ICProjectDescription projDesc, Board board) throws CoreException {
+ ManagedProject managedProject = new ManagedProject(projDesc);
+ String configId = ManagedBuildManager.calculateChildId(AVR_TOOLCHAIN_ID, null);
+ IToolChain avrToolChain = ManagedBuildManager.getExtensionToolChain(AVR_TOOLCHAIN_ID);
+ org.eclipse.cdt.managedbuilder.internal.core.Configuration newConfig = new org.eclipse.cdt.managedbuilder.internal.core.Configuration(managedProject, (ToolChain) avrToolChain, configId, board.getId());
+ IToolChain newToolChain = newConfig.getToolChain();
+ IOption newOption = newToolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
+ ManagedBuildManager.setOption(newConfig, newToolChain, newOption, board.getId());
+
+ CConfigurationData data = newConfig.getConfigurationData();
+ return projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ }
+
+ public static Board getBoard(IConfiguration configuration) throws CoreException {
+ try {
+ IToolChain toolChain = configuration.getToolChain();
+ IOption boardOption = toolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
+ String boardId = boardOption.getStringValue();
+
+ IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
+ Board board = boardManager.getBoard(boardId);
+ if (board == null) {
+ board = boardManager.getBoard("uno"); //$NON-NLS-1$
+ }
+ return board;
+ } catch (BuildException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
+ }
+
+ }
+
+ public IFile getSourceFile() {
+ return sourceFile;
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/Board.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/Board.java
new file mode 100644
index 00000000000..d072d6c0a72
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/Board.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core;
+
+import java.util.Properties;
+
+public class Board {
+
+ private final String id;
+ private final Properties properties;
+
+ public Board(String key, Properties properties) {
+ this.id = key;
+ this.properties = properties;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getProperty(String localKey) {
+ return properties.getProperty(id + '.' + localKey);
+ }
+
+ public String getName() {
+ return getProperty("name"); //$NON-NLS-1$
+ }
+
+ public String getMCU() {
+ return getProperty("build.mcu"); //$NON-NLS-1$
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoBoardManager.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoBoardManager.java
new file mode 100644
index 00000000000..8930f73d974
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoBoardManager.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core;
+
+import java.util.Collection;
+
+public interface IArduinoBoardManager {
+
+ Board getBoard(String id);
+
+ Collection<Board> getBoards();
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoRemoteConnection.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoRemoteConnection.java
new file mode 100644
index 00000000000..f76577a1bcb
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/IArduinoRemoteConnection.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core;
+
+import org.eclipse.remote.core.IRemoteConnection;
+
+/**
+ * Arduino specific extensions to IRemoteConnection.
+ *
+ * @author dschaefer
+ *
+ */
+public interface IArduinoRemoteConnection extends IRemoteConnection.Service {
+
+ final String TYPE_ID = "org.eclipse.cdt.arduino.core.connectionType"; //$NON-NLS-1$
+ final String PORT_NAME = "ardiuno.portname"; //$NON-NLS-1$
+ final String BOARD_ID = "arduino.board"; //$NON-NLS-1$
+
+ /**
+ * Return the serial port name.
+ *
+ * @return serial port name
+ */
+ String getPortName();
+
+ /**
+ * Get the board type at the end of this connection.
+ *
+ * @return Board
+ */
+ Board getBoard();
+
+ void pause();
+
+ void resume();
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java
new file mode 100644
index 00000000000..1dbe641f7c6
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal;
+
+import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
+import org.eclipse.cdt.arduino.core.internal.remote.ArduinoBoardManager;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class Activator extends Plugin {
+
+ private static Plugin plugin;
+
+ public static BundleContext getContext() {
+ return plugin.getBundle().getBundleContext();
+ }
+
+ public static Plugin getPlugin() {
+ return plugin;
+ }
+
+ public static String getId() {
+ return plugin.getBundle().getSymbolicName();
+ }
+
+ public static void log(Exception e) {
+ if (e instanceof CoreException) {
+ plugin.getLog().log(((CoreException) e).getStatus());
+ } else {
+ plugin.getLog().log(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
+ }
+ }
+
+ public void start(BundleContext bundleContext) throws Exception {
+ plugin = this;
+ bundleContext.registerService(IArduinoBoardManager.class, new ArduinoBoardManager(), null);
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ plugin = null;
+ }
+
+ public static <T> T getService(Class<T> service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference<T> ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoHome.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoHome.java
new file mode 100644
index 00000000000..5501eed06e6
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoHome.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal;
+
+import java.io.File;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.Platform;
+
+public class ArduinoHome {
+
+ private static File home;
+
+ public static File get() {
+ if (home == null) {
+ String arduinoPathStr = System.getProperty("org.eclipse.cdt.arduino.home"); //$NON-NLS-1$
+ if (arduinoPathStr != null) {
+ home = new File(arduinoPathStr);
+ } else {
+ try {
+ home = new File(new File(Platform.getInstallLocation().getURL().toURI()), "arduino"); //$NON-NLS-1$
+ } catch (URISyntaxException e) {
+ // TODO log
+ e.printStackTrace();
+ home = new File("nohome"); //$NON-NLS-1$
+ }
+ }
+ }
+ return home;
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoProjectNature.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoProjectNature.java
new file mode 100644
index 00000000000..5eac539ad69
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoProjectNature.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+public class ArduinoProjectNature implements IProjectNature {
+
+ private IProject project;
+ public static final String ID = Activator.getId() + ".arduinoNature"; //$NON-NLS-1$
+
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public static boolean hasNature(IProject project) throws CoreException {
+ IProjectDescription projDesc = project.getDescription();
+ for (String id : projDesc.getNatureIds()) {
+ if (id.equals(ID))
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void configure() throws CoreException {
+ }
+
+ @Override
+ public void deconfigure() throws CoreException {
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/AvrLanguageSettingsProvider.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/AvrLanguageSettingsProvider.java
new file mode 100644
index 00000000000..417405a28af
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/AvrLanguageSettingsProvider.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
+import org.eclipse.cdt.arduino.core.Board;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+
+public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
+
+ @Override
+ public String getToolchainId() {
+ return "org.eclipse.cdt.arduino.toolChain.avr"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected String getToolOptions(String languageId) {
+ String opts = super.getToolOptions(languageId);
+
+ try {
+ IConfiguration config = ManagedBuildManager.getConfigurationForDescription(currentCfgDescription);
+ Board board = ArduinoProjectGenerator.getBoard(config);
+ String mcu = board.getMCU();
+ if (mcu != null) {
+ opts += " -mmcu=" + mcu; //$NON-NLS-1$
+ }
+ } catch (CoreException e) {
+ Activator.getPlugin().getLog().log(e.getStatus());
+ }
+
+ return opts;
+ }
+
+ @Override
+ protected List<String> parseOptions(String line) {
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ if (line.startsWith(" /arduino/")) { //$NON-NLS-1$
+ File full = new File(ArduinoHome.get().getParentFile(), line.trim());
+ return parseOptions(" " + full.getAbsolutePath()); //$NON-NLS-1$
+ }
+ }
+
+ return super.parseOptions(line);
+ }
+
+ @Override
+ public AvrLanguageSettingsProvider cloneShallow() throws CloneNotSupportedException {
+ return (AvrLanguageSettingsProvider) super.cloneShallow();
+ }
+
+ @Override
+ public AvrLanguageSettingsProvider clone() throws CloneNotSupportedException {
+ return (AvrLanguageSettingsProvider) super.clone();
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/EnvVarSupplier.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/EnvVarSupplier.java
new file mode 100644
index 00000000000..a3642b218c8
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/EnvVarSupplier.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
+import org.eclipse.cdt.arduino.core.Board;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
+import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
+import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+
+public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier {
+
+ private EnvVar arduinoHome;
+ private EnvVar path;
+
+ private static final String OUTPUT_DIR = "OUTPUT_DIR"; //$NON-NLS-1$
+ private static final String BOARD = "BOARD"; //$NON-NLS-1$
+ private static final String CYGWIN = "CYGWIN"; //$NON-NLS-1$
+
+ private static final class EnvVar implements IBuildEnvironmentVariable {
+ String name;
+ String value;
+ int operation = IBuildEnvironmentVariable.ENVVAR_REPLACE;
+ String delimiter = null;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+ @Override
+ public String getValue() {
+ return value;
+ }
+ @Override
+ public int getOperation() {
+ return operation;
+ }
+ @Override
+ public String getDelimiter() {
+ return delimiter;
+ }
+ }
+
+ public EnvVarSupplier() {
+ File arduinoPath = ArduinoHome.get();
+
+ if (arduinoPath.isDirectory()) {
+ arduinoHome = new EnvVar();
+ arduinoHome.name = "ARDUINO_HOME"; //$NON-NLS-1$
+ arduinoHome.value = arduinoPath.getAbsolutePath();
+
+ File avrPath = new File(arduinoPath, "hardware/tools/avr/bin"); //$NON-NLS-1$
+ String pathStr = avrPath.getAbsolutePath();
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ // Windows needs the arduino path too to pick up the cygwin dlls
+ pathStr += File.pathSeparator + arduinoPath.getAbsolutePath();
+ }
+
+ path = new EnvVar();
+ path.name = "PATH"; //$NON-NLS-1$
+ path.value = pathStr;
+ path.operation = IBuildEnvironmentVariable.ENVVAR_PREPEND;
+ path.delimiter = File.pathSeparator;
+ }
+ }
+
+ private IBuildEnvironmentVariable getOutputDir(IConfiguration configuration) {
+ EnvVar outputDir = new EnvVar();
+ outputDir.name = OUTPUT_DIR;
+ outputDir.value = "build/" + configuration.getName(); //$NON-NLS-1$
+ return outputDir;
+ }
+
+ private IBuildEnvironmentVariable getBoard(IConfiguration configuration) {
+ try {
+ Board board = ArduinoProjectGenerator.getBoard(configuration);
+ if (board == null)
+ return null;
+
+ EnvVar boardVar = new EnvVar();
+ boardVar.name = BOARD;
+ boardVar.value = board.getId();
+ return boardVar;
+ } catch (CoreException e) {
+ Activator.getPlugin().getLog().log(e.getStatus());
+ return null;
+ }
+ }
+
+ private IBuildEnvironmentVariable getCygwin() {
+ EnvVar var = new EnvVar();
+ var.name = CYGWIN;
+ var.value = "nodosfilewarning"; //$NON-NLS-1$
+ return var;
+ }
+
+ @Override
+ public IBuildEnvironmentVariable getVariable(String variableName,
+ IConfiguration configuration, IEnvironmentVariableProvider provider) {
+ if (path != null && variableName.equals(path.name)) {
+ return path;
+ } else if (arduinoHome != null && variableName.equals(arduinoHome.name)) {
+ return arduinoHome;
+ } else if (variableName.equals(OUTPUT_DIR)) {
+ return getOutputDir(configuration);
+ } else if (variableName.equals(BOARD)) {
+ return getBoard(configuration);
+ } else if (variableName.equals(CYGWIN)) {
+ return getCygwin();
+ }
+ return null;
+ }
+
+ @Override
+ public IBuildEnvironmentVariable[] getVariables(
+ IConfiguration configuration, IEnvironmentVariableProvider provider) {
+ List<IBuildEnvironmentVariable> vars = new ArrayList<>();
+
+ if (path != null)
+ vars.add(path);
+
+ if (arduinoHome != null)
+ vars.add(arduinoHome);
+
+ if (configuration != null) {
+ vars.add(getOutputDir(configuration));
+
+ IBuildEnvironmentVariable boardVar = getBoard(configuration);
+ if (boardVar != null)
+ vars.add(boardVar);
+ }
+
+ if (Platform.getOS().equals(Platform.OS_WIN32))
+ vars.add(getCygwin());
+
+ return vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Messages.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Messages.java
new file mode 100644
index 00000000000..36fc60f1b2d
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Messages.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.arduino.core.internal.messages"; //$NON-NLS-1$
+ public static String ArduinoLaunchConfigurationDelegate_0;
+ public static String ArduinoLaunchConfigurationDelegate_1;
+ public static String ArduinoProjectGenerator_0;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java
new file mode 100644
index 00000000000..425c2a3200d
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal.launch;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.arduino.core.ArduinoLaunchConsoleService;
+import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
+import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
+import org.eclipse.cdt.arduino.core.internal.Activator;
+import org.eclipse.cdt.arduino.core.internal.Messages;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
+
+public class ArduinoLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
+
+ public static ILaunchConfigurationType getLaunchConfigurationType() {
+ return DebugPlugin.getDefault().getLaunchManager()
+ .getLaunchConfigurationType("org.eclipse.cdt.arduino.core.launchConfigurationType"); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ // 1. make sure proper build config is set active
+ IProject project = configuration.getMappedResources()[0].getProject();
+ ICProjectDescription projDesc = CCorePlugin.getDefault().getProjectDescription(project);
+ IRemoteConnection remoteConnection = getActiveRemote(configuration);
+ if (remoteConnection == null) {
+ // TODO default?
+ return false;
+ }
+ ICConfigurationDescription configDesc = getBuildConfiguration(projDesc, remoteConnection);
+ boolean newConfig = false;
+ if (configDesc == null) {
+ IArduinoRemoteConnection arduinoRemote = remoteConnection.getService(IArduinoRemoteConnection.class);
+ configDesc = ArduinoProjectGenerator.createBuildConfiguration(projDesc, arduinoRemote.getBoard());
+ newConfig = true;
+ }
+ if (newConfig || !projDesc.getActiveConfiguration().equals(configDesc)) {
+ projDesc.setActiveConfiguration(configDesc);
+ CCorePlugin.getDefault().setProjectDescription(project, projDesc);
+ }
+
+ // 2. Run the build
+ return super.buildForLaunch(configuration, mode, monitor);
+ }
+
+ @Override
+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
+ // 1. Extract project from configuration
+ IProject project = configuration.getMappedResources()[0].getProject();
+ return new IProject[] { project };
+ }
+
+ @Override
+ public void launch(final ILaunchConfiguration configuration, String mode,
+ final ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ new Job(Messages.ArduinoLaunchConfigurationDelegate_0) {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ ArduinoLaunchConsoleService consoleService = getConsoleService();
+
+ IRemoteConnection connection = getActiveRemote(configuration);
+ if (connection == null) {
+ return new Status(IStatus.ERROR, Activator.getId(), Messages.ArduinoLaunchConfigurationDelegate_1);
+ }
+
+ // The project
+ IProject project = (IProject) configuration.getMappedResources()[0];
+
+ // The build environment
+ ICProjectDescription projDesc = CCorePlugin.getDefault().getProjectDescription(project);
+ ICConfigurationDescription configDesc = getBuildConfiguration(projDesc, connection);
+ IEnvironmentVariable[] envVars = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(configDesc, true);
+ List<String> envVarList = new ArrayList<String>(envVars.length + 1);
+ for (IEnvironmentVariable var : envVars) {
+ envVarList.add(var.getName() + '=' + var.getValue());
+ }
+ // Add in the serial port based on launch config
+ IArduinoRemoteConnection arduinoRemote = connection.getService(IArduinoRemoteConnection.class);
+ envVarList.add("SERIAL_PORT=" + arduinoRemote.getPortName()); //$NON-NLS-1$
+ String[] envp = envVarList.toArray(new String[envVarList.size()]);
+
+ // The project directory to launch from
+ File projectDir = new File(project.getLocationURI());
+
+ // The build command
+ IConfiguration buildConfig = ManagedBuildManager.getConfigurationForDescription(configDesc);
+ String command = buildConfig.getBuilder().getCommand();
+
+ // If opened, temporarily close the connection so we can use it to download the firmware.
+ boolean wasOpened = connection.isOpen();
+ if (wasOpened) {
+ arduinoRemote.pause();
+ }
+
+ // Run the process and capture the results in the console
+ Process process = Runtime.getRuntime().exec(command + " load", envp, projectDir); //$NON-NLS-1$
+ consoleService.monitor(process);
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ }
+
+ // Reopen the connection
+ if (wasOpened) {
+ arduinoRemote.resume();
+ }
+ } catch (CoreException e) {
+ return e.getStatus();
+ } catch (IOException e) {
+ return new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e);
+ } finally {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
+ }
+
+ return Status.OK_STATUS;
+ };
+ }.schedule();
+ }
+
+ private ArduinoLaunchConsoleService getConsoleService() throws CoreException {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.getId(), "consoleService"); //$NON-NLS-1$
+ IExtension extension = point.getExtensions()[0]; // should only be one
+ return (ArduinoLaunchConsoleService) extension.getConfigurationElements()[0].createExecutableExtension("class"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the build configuration for the active target and the launch configuration.
+ *
+ * @param launchConfig
+ * @return
+ */
+ private ICConfigurationDescription getBuildConfiguration(ICProjectDescription projDesc, IRemoteConnection remoteConnection) throws CoreException {
+ IArduinoRemoteConnection arduinoRemote = remoteConnection.getService(IArduinoRemoteConnection.class);
+ String boardId = arduinoRemote.getBoard().getId();
+
+ for (ICConfigurationDescription configDesc : projDesc.getConfigurations()) {
+ IConfiguration config = ManagedBuildManager.getConfigurationForDescription(configDesc);
+ if (ArduinoProjectGenerator.getBoard(config).getId().equals(boardId))
+ return configDesc;
+ }
+
+ return null;
+ }
+
+ private IRemoteConnection getActiveRemote(ILaunchConfiguration configuration) {
+ IRemoteLaunchConfigService remoteLaunchService = Activator.getService(IRemoteLaunchConfigService.class);
+ return remoteLaunchService.getActiveConnection(configuration);
+ }
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java
new file mode 100644
index 00000000000..ac1eba5cd97
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.launchbar.core.ProjectLaunchConfigurationProvider;
+
+public class ArduinoLaunchConfigurationProvider extends ProjectLaunchConfigurationProvider {
+
+ @Override
+ public ILaunchConfigurationType getLaunchConfigurationType() throws CoreException {
+ return ArduinoLaunchConfigurationDelegate.getLaunchConfigurationType();
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchDescriptorType.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchDescriptorType.java
new file mode 100644
index 00000000000..6b7a8076149
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchDescriptorType.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal.launch;
+
+import org.eclipse.cdt.arduino.core.internal.ArduinoProjectNature;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.launchbar.core.ILaunchDescriptor;
+import org.eclipse.launchbar.core.ILaunchDescriptorType;
+import org.eclipse.launchbar.core.ProjectLaunchDescriptor;
+
+public class ArduinoLaunchDescriptorType implements ILaunchDescriptorType {
+
+ @Override
+ public boolean ownsLaunchObject(Object element) throws CoreException {
+ if (element instanceof IProject) {
+ return ArduinoProjectNature.hasNature((IProject) element);
+ }
+
+ return false;
+ }
+
+ @Override
+ public ILaunchDescriptor getDescriptor(Object element) throws CoreException {
+ if (element instanceof IProject) {
+ return new ProjectLaunchDescriptor(this, (IProject) element);
+ }
+
+ return null;
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/messages.properties b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/messages.properties
new file mode 100644
index 00000000000..20b2cca975c
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/messages.properties
@@ -0,0 +1,13 @@
+ArduinoLaunchConfigurationDelegate_1=No active Arduino remote connection.
+################################################################################
+# Copyright (c) 2015 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# QNX Software Systems - Initial API and implementation
+################################################################################
+ArduinoLaunchConfigurationDelegate_0=Arduino Launch
+ArduinoProjectGenerator_0=Write Arduino project file
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoBoardManager.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoBoardManager.java
new file mode 100644
index 00000000000..e1cd81afaf2
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoBoardManager.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal.remote;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.cdt.arduino.core.Board;
+import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
+import org.eclipse.cdt.arduino.core.internal.ArduinoHome;
+
+public class ArduinoBoardManager implements IArduinoBoardManager {
+
+ private Map<String, Board> boards;
+
+ @Override
+ public Board getBoard(String id) {
+ init();
+ return boards.get(id);
+ }
+
+ @Override
+ public Collection<Board> getBoards() {
+ init();
+ List<Board> sortedBoards = new ArrayList<Board>(boards.values());
+ Collections.sort(sortedBoards, new Comparator<Board>() {
+ @Override
+ public int compare(Board arg0, Board arg1) {
+ return arg0.getName().compareTo(arg1.getName());
+ }
+ });
+ return sortedBoards;
+ }
+
+ private void init() {
+ if (boards != null)
+ return;
+ boards = new HashMap<>();
+ File home = ArduinoHome.get();
+ if (!home.isDirectory())
+ return;
+
+ File archRoot = new File(home, "hardware/arduino"); //$NON-NLS-1$
+ for (File archDir : archRoot.listFiles()) {
+ File boardFile = new File(archDir, "boards.txt"); //$NON-NLS-1$
+ loadBoardFile(archDir.getName(), boardFile);
+ }
+ }
+
+ private void loadBoardFile(String arch, File boardFile) {
+ try {
+ Properties boardProps = new Properties();
+ boardProps.load(new FileInputStream(boardFile));
+ Enumeration<?> i = boardProps.propertyNames();
+ while (i.hasMoreElements()) {
+ String propertyName = (String) i.nextElement();
+ String[] names = propertyName.split("\\."); //$NON-NLS-1$
+ if (names.length == 2 && names[1].equals("name")) { //$NON-NLS-1$
+ boards.put(names[0], new Board(names[0], boardProps));
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnection.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnection.java
new file mode 100644
index 00000000000..96532846643
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnection.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal.remote;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.arduino.core.Board;
+import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
+import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
+import org.eclipse.cdt.arduino.core.internal.Activator;
+import org.eclipse.cdt.serial.SerialPort;
+import org.eclipse.remote.core.IRemoteCommandShellService;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionPropertyService;
+import org.eclipse.remote.core.IRemoteProcess;
+import org.eclipse.remote.serial.core.SerialPortCommandShell;
+
+public class ArduinoRemoteConnection implements IRemoteConnectionPropertyService, IRemoteCommandShellService, IArduinoRemoteConnection {
+
+ private final IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
+ private final IRemoteConnection remoteConnection;
+ private SerialPort serialPort;
+ private SerialPortCommandShell commandShell;
+
+ public ArduinoRemoteConnection(IRemoteConnection remoteConnection) {
+ this.remoteConnection = remoteConnection;
+ }
+
+ public static class Factory implements IRemoteConnection.Service.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends IRemoteConnection.Service> T getService(IRemoteConnection remoteConnection, Class<T> service) {
+ if (IArduinoRemoteConnection.class.equals(service)) {
+ return (T) new ArduinoRemoteConnection(remoteConnection);
+ } else if (IRemoteConnectionPropertyService.class.equals(service)
+ || IRemoteCommandShellService.class.equals(service)) {
+ return (T) remoteConnection.getService(IArduinoRemoteConnection.class);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnection getRemoteConnection() {
+ return remoteConnection;
+ }
+
+ @Override
+ public String getProperty(String key) {
+ if (IRemoteConnection.OS_NAME_PROPERTY.equals(key)) {
+ return "arduino"; //$NON-NLS-1$
+ } else if (IRemoteConnection.OS_ARCH_PROPERTY.equals(key)) {
+ return "avr"; // TODO handle arm //$NON-NLS-1$
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Board getBoard() {
+ String boardId = remoteConnection.getAttribute(BOARD_ID);
+ return boardManager.getBoard(boardId);
+ }
+
+ @Override
+ public String getPortName() {
+ return remoteConnection.getAttribute(PORT_NAME);
+ }
+
+
+ @Override
+ public IRemoteProcess getCommandShell(int flags) throws IOException {
+ if (serialPort != null && serialPort.isOpen()) {
+ // can only have one open at a time
+ return null;
+ }
+
+ serialPort = new SerialPort(getPortName());
+ commandShell = new SerialPortCommandShell(remoteConnection, serialPort);
+ return commandShell;
+ }
+
+ @Override
+ public void pause() {
+ if (serialPort != null) {
+ try {
+ if (serialPort.isOpen())
+ serialPort.pause();
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ }
+ }
+
+ @Override
+ public void resume() {
+ if (serialPort != null) {
+ try {
+ if (serialPort.isOpen())
+ serialPort.resume();
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ }
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/templates/Makefile b/toolchains/arduino/org.eclipse.cdt.arduino.core/templates/Makefile
new file mode 100644
index 00000000000..7383bed636a
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/templates/Makefile
@@ -0,0 +1,3 @@
+EXE = ${projectName}
+
+include $(ARDUINO_HOME)/arduino.mk
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/templates/arduino.cpp b/toolchains/arduino/org.eclipse.cdt.arduino.core/templates/arduino.cpp
new file mode 100644
index 00000000000..ddfe4da79b6
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/templates/arduino.cpp
@@ -0,0 +1,9 @@
+#include <Arduino.h>
+
+void setup() {
+
+}
+
+void loop() {
+
+}

Back to the top