mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Start work to build against the Arduino IDE.
This commit is contained in:
parent
27f92db644
commit
992e691e10
10 changed files with 99 additions and 45 deletions
|
@ -69,7 +69,7 @@ LIB_SRCS = $(call rwildcard, $(LIB_ROOT)/, *.c *.cpp)
|
|||
LIB_OBJS = $(patsubst $(LIB_ROOT)/%.c, $(OUTPUT_DIR)/arduino/%.o, $(filter %.c, $(LIB_SRCS))) \
|
||||
$(patsubst $(LIB_ROOT)/%.cpp, $(OUTPUT_DIR)/arduino/%.o, $(filter %.cpp, $(LIB_SRCS)))
|
||||
|
||||
LIBS_ROOTS = $(HOME)/Documents/Arduino/libraries $(ARDUINO_HOME)/hardware/arduino/$(ARCH)/libraries $(ARDUINO_HOME)/libraries
|
||||
LIBS_ROOTS = $(ARDUINO_LIBS) $(ARDUINO_HOME)/hardware/arduino/$(ARCH)/libraries $(ARDUINO_HOME)/libraries
|
||||
|
||||
LIBS_DIRS = $(foreach lib, $(LIBS), $(firstword $(realpath $(foreach lib_root, $(LIBS_ROOTS), $(lib_root)/$(lib)))))
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ArduinoHome {
|
|||
|
||||
private static File home;
|
||||
|
||||
public static File get() {
|
||||
public static File getRootfileDir() {
|
||||
if (home == null) {
|
||||
String arduinoPathStr = System.getProperty("org.eclipse.cdt.arduino.home"); //$NON-NLS-1$
|
||||
if (arduinoPathStr != null) {
|
||||
|
@ -37,4 +37,13 @@ public class ArduinoHome {
|
|||
return home;
|
||||
}
|
||||
|
||||
public static File getArduinoDir() {
|
||||
return new File("/Applications/Arduino.app/Contents/Java"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static File getArduinoLibsDir() {
|
||||
File home = new File(System.getProperty("user.home")); //$NON-NLS-1$
|
||||
return new File(home, "/Documents/Arduino/libraries"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
|
|||
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());
|
||||
File full = new File(ArduinoHome.getArduinoDir().getParentFile(), line.trim());
|
||||
return parseOptions(" " + full.getAbsolutePath()); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,16 +21,16 @@ 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 arduinoRoot;
|
||||
private EnvVar arduinoHome;
|
||||
private EnvVar arduinoLibs;
|
||||
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;
|
||||
|
@ -57,26 +57,26 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
}
|
||||
|
||||
public EnvVarSupplier() {
|
||||
File arduinoPath = ArduinoHome.get();
|
||||
arduinoRoot = new EnvVar();
|
||||
arduinoRoot.name = "ARDUINO_ROOT"; //$NON-NLS-1$
|
||||
arduinoRoot.value = ArduinoHome.getRootfileDir().getAbsolutePath();
|
||||
|
||||
if (arduinoPath.isDirectory()) {
|
||||
arduinoHome = new EnvVar();
|
||||
arduinoHome.name = "ARDUINO_HOME"; //$NON-NLS-1$
|
||||
arduinoHome.value = arduinoPath.getAbsolutePath();
|
||||
arduinoHome = new EnvVar();
|
||||
arduinoHome.name = "ARDUINO_HOME"; //$NON-NLS-1$
|
||||
arduinoHome.value = ArduinoHome.getArduinoDir().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();
|
||||
}
|
||||
arduinoLibs = new EnvVar();
|
||||
arduinoLibs.name = "ARDUINO_LIBS"; //$NON-NLS-1$
|
||||
arduinoLibs.value = ArduinoHome.getArduinoLibsDir().getAbsolutePath();
|
||||
|
||||
path = new EnvVar();
|
||||
path.name = "PATH"; //$NON-NLS-1$
|
||||
path.value = pathStr;
|
||||
path.operation = IBuildEnvironmentVariable.ENVVAR_PREPEND;
|
||||
path.delimiter = File.pathSeparator;
|
||||
}
|
||||
File avrPath = new File(ArduinoHome.getArduinoDir(), "hardware/tools/avr/bin"); //$NON-NLS-1$
|
||||
String pathStr = avrPath.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) {
|
||||
|
@ -102,26 +102,21 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
if (variableName.equals(path.name)) {
|
||||
return path;
|
||||
} else if (arduinoHome != null && variableName.equals(arduinoHome.name)) {
|
||||
} else if (variableName.equals(arduinoRoot.name)) {
|
||||
return arduinoRoot;
|
||||
} else if (variableName.equals(arduinoHome.name)) {
|
||||
return arduinoHome;
|
||||
} else if (variableName.equals(arduinoLibs.name)) {
|
||||
return arduinoLibs;
|
||||
} 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;
|
||||
}
|
||||
|
@ -131,11 +126,10 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||
List<IBuildEnvironmentVariable> vars = new ArrayList<>();
|
||||
|
||||
if (path != null)
|
||||
vars.add(path);
|
||||
|
||||
if (arduinoHome != null)
|
||||
vars.add(arduinoHome);
|
||||
vars.add(path);
|
||||
vars.add(arduinoRoot);
|
||||
vars.add(arduinoHome);
|
||||
vars.add(arduinoLibs);
|
||||
|
||||
if (configuration != null) {
|
||||
vars.add(getOutputDir(configuration));
|
||||
|
@ -145,9 +139,6 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
vars.add(boardVar);
|
||||
}
|
||||
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32))
|
||||
vars.add(getCygwin());
|
||||
|
||||
return vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ArduinoBoardManager implements IArduinoBoardManager {
|
|||
if (boards != null)
|
||||
return;
|
||||
boards = new HashMap<>();
|
||||
File home = ArduinoHome.get();
|
||||
File home = ArduinoHome.getArduinoDir();
|
||||
if (!home.isDirectory())
|
||||
return;
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@ public class ArduinoRemoteConnection implements IRemoteConnectionPropertyService
|
|||
@Override
|
||||
public Board getBoard() {
|
||||
String boardId = remoteConnection.getAttribute(BOARD_ID);
|
||||
if (boardId == null) {
|
||||
boardId = "uno"; //$NON-NLS-1$
|
||||
}
|
||||
return boardManager.getBoard(boardId);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
EXE = ${projectName}
|
||||
|
||||
include $(ARDUINO_HOME)/arduino.mk
|
||||
include $(ARDUINO_ROOT)/arduino.mk
|
||||
|
|
|
@ -10,3 +10,4 @@
|
|||
###############################################################################
|
||||
pluginName=Arduino C++ UI
|
||||
providerName=Eclipse CDT
|
||||
preferencePage.name=Arduino C++
|
||||
|
|
|
@ -65,4 +65,12 @@
|
|||
service="org.eclipse.remote.ui.IRemoteUIConnectionService">
|
||||
</connectionTypeService>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
class="org.eclipse.cdt.arduino.ui.internal.ArduinoPreferencePage"
|
||||
id="org.eclipse.cdt.arduino.ui.page1"
|
||||
name="%preferencePage.name">
|
||||
</page>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*******************************************************************************
|
||||
* 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.ui.internal;
|
||||
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
public class ArduinoPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
public ArduinoPreferencePage() {
|
||||
super(GRID);
|
||||
setDescription("Arduino C++ Preferences");
|
||||
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue