1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Final Arduino touches for Mars. Preference Page, template cleanup.

Externalized Strings.

Change-Id: I3450fe67fa3f3e3db40955be926b8b62951460f1
This commit is contained in:
Doug Schaefer 2015-05-24 00:08:06 -04:00
parent 409b39b10a
commit 109655d384
19 changed files with 288 additions and 205 deletions

View file

@ -15,7 +15,7 @@
# This file should be translated. # This file should be translated.
# "featureName" property - name of the feature # "featureName" property - name of the feature
featureName=Arduino C++ Tools featureName=Arduino C++ Tools - Preview
# "providerName" property - name of the company that provides the feature # "providerName" property - name of the company that provides the feature
providerName=Eclipse CDT providerName=Eclipse CDT

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.arduino.core.internal; package org.eclipse.cdt.arduino.core;
import java.io.File; import java.io.File;
@ -16,14 +16,26 @@ import org.eclipse.core.runtime.Platform;
public class ArduinoHome { public class ArduinoHome {
public static File getArduinoDir() { public static final String preferenceName = "arduinoHome"; //$NON-NLS-1$
private static final String qualifiedName = "org.eclipse.cdt.arduino.ui"; //$NON-NLS-1$
public static File getArduinoHome() {
String arduinoHome = Platform.getPreferencesService().getString(qualifiedName, preferenceName, getDefault(),
null);
if (Platform.getOS().equals(Platform.OS_MACOSX)) {
arduinoHome += "/Contents/Java"; //$NON-NLS-1$
}
return new File(arduinoHome);
}
public static String getDefault() {
switch (Platform.getOS()) { switch (Platform.getOS()) {
case Platform.OS_MACOSX: case Platform.OS_MACOSX:
return new File("/Applications/Arduino.app/Contents/Java"); //$NON-NLS-1$ return "/Applications/Arduino.app"; //$NON-NLS-1$
case Platform.OS_WIN32: case Platform.OS_WIN32:
return new File("C:\\Program Files (x86)\\Arduino"); //$NON-NLS-1$ return "C:\\Program Files (x86)\\Arduino"; //$NON-NLS-1$
default: default:
return null; return ""; //$NON-NLS-1$
} }
} }

View file

@ -121,6 +121,7 @@ public class ArduinoProjectGenerator {
fmModel.put("projectName", project.getName()); //$NON-NLS-1$ fmModel.put("projectName", project.getName()); //$NON-NLS-1$
generateFile(fmModel, fmConfig.getTemplate("Makefile"), project.getFile("Makefile")); //$NON-NLS-1$ //$NON-NLS-2$ generateFile(fmModel, fmConfig.getTemplate("Makefile"), project.getFile("Makefile")); //$NON-NLS-1$ //$NON-NLS-2$
generateFile(fmModel, fmConfig.getTemplate("arduino.mk"), project.getFile("arduino.mk")); //$NON-NLS-1$ //$NON-NLS-2$
sourceFile = project.getFile(project.getName() + ".cpp"); //$NON-NLS-1$ sourceFile = project.getFile(project.getName() + ".cpp"); //$NON-NLS-1$
generateFile(fmModel, fmConfig.getTemplate("arduino.cpp"), sourceFile); //$NON-NLS-1$ generateFile(fmModel, fmConfig.getTemplate("arduino.cpp"), sourceFile); //$NON-NLS-1$

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.arduino.core.internal;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import org.eclipse.cdt.arduino.core.ArduinoHome;
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator; import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
import org.eclipse.cdt.arduino.core.Board; import org.eclipse.cdt.arduino.core.Board;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -50,7 +51,7 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
protected List<String> parseOptions(String line) { protected List<String> parseOptions(String line) {
if (Platform.getOS().equals(Platform.OS_WIN32)) { if (Platform.getOS().equals(Platform.OS_WIN32)) {
if (line.startsWith(" /arduino/")) { //$NON-NLS-1$ if (line.startsWith(" /arduino/")) { //$NON-NLS-1$
File full = new File(ArduinoHome.getArduinoDir().getParentFile(), line.trim()); File full = new File(ArduinoHome.getArduinoHome().getParentFile(), line.trim());
return parseOptions(" " + full.getAbsolutePath()); //$NON-NLS-1$ return parseOptions(" " + full.getAbsolutePath()); //$NON-NLS-1$
} }
} }

View file

@ -14,6 +14,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.arduino.core.ArduinoHome;
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator; import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
import org.eclipse.cdt.arduino.core.Board; import org.eclipse.cdt.arduino.core.Board;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -66,13 +67,13 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
public EnvVarSupplier() { public EnvVarSupplier() {
arduinoHome = new EnvVar(); arduinoHome = new EnvVar();
arduinoHome.name = "ARDUINO_HOME"; //$NON-NLS-1$ arduinoHome.name = "ARDUINO_HOME"; //$NON-NLS-1$
arduinoHome.value = clean(ArduinoHome.getArduinoDir().getAbsolutePath()); arduinoHome.value = clean(ArduinoHome.getArduinoHome().getAbsolutePath());
arduinoLibs = new EnvVar(); arduinoLibs = new EnvVar();
arduinoLibs.name = "ARDUINO_USER_LIBS"; //$NON-NLS-1$ arduinoLibs.name = "ARDUINO_USER_LIBS"; //$NON-NLS-1$
arduinoLibs.value = clean(System.getProperty("user.home") + "/Documents/Arduino/libraries"); //$NON-NLS-1$ //$NON-NLS-2$ arduinoLibs.value = clean(System.getProperty("user.home") + "/Documents/Arduino/libraries"); //$NON-NLS-1$ //$NON-NLS-2$
String avrDir = ArduinoHome.getArduinoDir().toString() + "/hardware/tools/avr/bin"; //$NON-NLS-1$ String avrDir = ArduinoHome.getArduinoHome().toString() + "/hardware/tools/avr/bin"; //$NON-NLS-1$
String installDir = Platform.getInstallLocation().getURL().getPath(); String installDir = Platform.getInstallLocation().getURL().getPath();
path = new EnvVar(); path = new EnvVar();
path.name = "PATH"; //$NON-NLS-1$ path.name = "PATH"; //$NON-NLS-1$

View file

@ -23,9 +23,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.eclipse.cdt.arduino.core.ArduinoHome;
import org.eclipse.cdt.arduino.core.Board; import org.eclipse.cdt.arduino.core.Board;
import org.eclipse.cdt.arduino.core.IArduinoBoardManager; import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
import org.eclipse.cdt.arduino.core.internal.ArduinoHome;
public class ArduinoBoardManager implements IArduinoBoardManager { public class ArduinoBoardManager implements IArduinoBoardManager {
@ -54,7 +54,7 @@ public class ArduinoBoardManager implements IArduinoBoardManager {
if (boards != null) if (boards != null)
return; return;
boards = new HashMap<>(); boards = new HashMap<>();
File home = ArduinoHome.getArduinoDir(); File home = ArduinoHome.getArduinoHome();
if (!home.isDirectory()) if (!home.isDirectory())
return; return;

View file

@ -3,163 +3,4 @@ LIBS =
BOARD ?= uno BOARD ?= uno
OUTPUT_DIR ?= build/$(BOARD) OUTPUT_DIR ?= build/$(BOARD)
ifeq ($(BOARD),uno) include arduino.mk
ARCH = avr
BUILD_CORE = arduino
BUILD_VARIANT = standard
BUILD_MCU = atmega328p
BUILD_F_CPU = 16000000L
BUILD_BOARD = AVR_UNO
LOADER = avrdude
LOADER_PROTOCOL = arduino
LOADER_SPEED = 115200
LOADER_MAX_SIZE = 32256
LOADER_MAX_DATA = 2048
endif
VERSION = 164
ifeq ($(ARCH),avr)
CXXFLAGS = -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD \
-mmcu=$(BUILD_MCU) -DF_CPU=$(BUILD_F_CPU) -DARDUINO=$(VERSION) -DARDUINO_$(BUILD_BOARD) -DARDUINO_ARCH_AVR $(INCLUDES)
CFLAGS = -g -Os -w -ffunction-sections -fdata-sections -MMD \
-mmcu=$(BUILD_MCU) -DF_CPU=$(BUILD_F_CPU) -DARDUINO=156 -DARDUINO_$(BUILD_BOARD) -DARDUINO_ARCH_AVR $(INCLUDES)
CXX = avr-g++
CC = avr-gcc
AR = avr-ar
OBJCOPY = avr-objcopy
define do_link
$(CC) -Os -Wl,--gc-sections -mmcu=$(BUILD_MCU) -o $(OUTPUT_DIR)/$(EXE).elf $^
avr-objcopy -O ihex -R .eeprom $(OUTPUT_DIR)/$(EXE).elf $(OUTPUT_DIR)/$(EXE).hex
$(do_link_extra)
avr-size $(OUTPUT_DIR)/$(EXE).elf
@echo Max text: $(LOADER_MAX_SIZE)
@echo Max data + bss: $(LOADER_MAX_DATA)
endef
define do_eeprom
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load \
--no-change-warnings --change-section-lma .eeprom=0 \
$(OUTPUT_DIR)/$(EXE).elf $(OUTPUT_DIR)/$(EXE).eep
endef
define do_load_avrdude
avrdude -C"$(ARDUINO_HOME)/hardware/tools/avr/etc/avrdude.conf" -p$(BUILD_MCU) -c$(LOADER_PROTOCOL) \
-P$(SERIAL_PORT) -b$(LOADER_SPEED) -D "-Uflash:w:$(OUTPUT_DIR)/$(EXE).hex:i"
endef
endif # ARCH = avr
space :=
space +=
spacify = $(subst $(space),\$(space),$1)
ifeq ($(OS),Windows_NT)
RMDIR = rmdir /s /q
fixpath = $(subst /,\,$1)
mymkdir = if not exist "$(call fixpath,$1)" mkdir $(call fixpath,$1)
else
RMDIR = rm -fr
fixpath = $1
mymkdir = mkdir -p $1
endif
src_recurse = $(foreach d,$(subst $2/,,$(wildcard $1*)),$(call src_recurse,$3/$d/,$2,$3) $(filter %.c %.cpp,$d))
src = $(foreach lib,$3,$(if $(wildcard $2/$(lib)/src),$(call src_recurse,$2/$(lib)/src/,$1,$2),\
$(subst $1/,,\
$(wildcard $2/$(lib)/*.c)\
$(wildcard $2/$(lib)/*.cpp)\
$(wildcard $2/$(lib)/utility/*.c)\
$(wildcard $2/$(lib)/utility/*.cpp)))))
objs = $(patsubst %.c,$2/%.o,$(filter %.c,$1)) $(patsubst %.cpp,$2/%.o,$(filter %.cpp,$1))
incs = $(foreach lib,$1,$(if $(wildcard $3/$(lib)/src),-I"$2/$(lib)/src",-I"$2/$(lib)" -I"$2/$(lib)/utility"))
PROJECT_OBJS = $(call objs,$(call src_recurse,./,.,.),$(OUTPUT_DIR)/src)
LIB_ROOT = $(ARDUINO_HOME)/hardware/arduino/$(ARCH)/cores/$(BUILD_CORE)
LIB_ROOT_SPC = $(call spacify,$(LIB_ROOT))
LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(LIB_ROOT_SPC)))
LIB_OBJS = $(call objs,$(call src_recurse,$(LIB_ROOT_SPC)/,$(LIB_ROOT),$(LIB_ROOT_SPC)),$(OUTPUT_DIR)/lib)
USER_LIB_ROOT = $(ARDUINO_USER_LIBS)
USER_LIB_ROOT_SPC = $(call spacify,$(USER_LIB_ROOT))
USER_LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(USER_LIB_ROOT_SPC)))
USER_LIBS = $(foreach lib,$(LIBS),$(subst $(USER_LIB_ROOT)/,,$(wildcard $(USER_LIB_ROOT_SPC)/$(lib))))
USER_INCLUDES = $(call incs,$(USER_LIBS),$(USER_LIB_ROOT),$(USER_LIB_ROOT_SPC))
USER_OBJS = $(call objs,$(call src,$(USER_LIB_ROOT),$(USER_LIB_ROOT_SPC),$(USER_LIBS)),$(OUTPUT_DIR)/user)
HW_LIB_ROOT = $(ARDUINO_HOME)/hardware/arduino/$(ARCH)/libraries
HW_LIB_ROOT_SPC = $(call spacify,$(HW_LIB_ROOT))
HW_LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(HW_LIB_ROOT_SPC)))
HW_LIBS = $(foreach lib, $(LIBS), $(subst $(HW_LIB_ROOT)/,,$(wildcard $(HW_LIB_ROOT_SPC)/$(lib))))
HW_INCLUDES = $(call incs,$(HW_LIBS),$(HW_LIB_ROOT),$(HW_LIB_ROOT_SPC))
HW_OBJS = $(call objs,$(call src,$(HW_LIB_ROOT),$(HW_LIB_ROOT_SPC),$(HW_LIBS)),$(OUTPUT_DIR)/hw)
ARDUINO_LIB_ROOT = $(ARDUINO_HOME)/libraries
ARDUINO_LIB_ROOT_SPC = $(call spacify,$(ARDUINO_LIB_ROOT))
ARDUINO_LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(ARDUINO_LIB_ROOT_SPC)))
ARDUINO_LIBS = $(foreach lib, $(LIBS), $(subst $(ARDUINO_LIB_ROOT)/,,$(wildcard $(ARDUINO_LIB_ROOT_SPC)/$(lib))))
ARDUINO_INCLUDES = $(call incs,$(ARDUINO_LIBS),$(ARDUINO_LIB_ROOT),$(ARDUINO_LIB_ROOT_SPC))
ARDUINO_OBJS = $(call objs,$(call src,$(ARDUINO_LIB_ROOT),$(ARDUINO_LIB_ROOT_SPC),$(ARDUINO_LIBS)),$(OUTPUT_DIR)/arduino)
INCLUDES = -I"$(ARDUINO_HOME)/hardware/arduino/$(ARCH)/cores/$(BUILD_CORE)" \
-I"$(ARDUINO_HOME)/hardware/arduino/$(ARCH)/variants/$(BUILD_VARIANT)" \
$(USER_INCLUDES) $(HW_INCLUDES) $(ARDUINO_INCLUDES)
OBJS = $(PROJECT_OBJS) $(USER_OBJS) $(HW_OBJS) $(ARDUINO_OBJS)
all: $(OUTPUT_DIR)/$(EXE).hex
clean:
$(RMDIR) $(call fixpath,$(OUTPUT_DIR))
load: $(OUTPUT_DIR)/$(EXE).hex
$(do_load_$(LOADER))
$(OUTPUT_DIR)/$(EXE).hex: $(OBJS) $(OUTPUT_DIR)/core.a
$(do_link)
$(OUTPUT_DIR)/core.a: $(LIB_OBJS)
$(AR) r $@ $?
$(OUTPUT_DIR)/lib/%.o: $(LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/lib/%.o: $(LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/user/%.o: $(USER_LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/user/%.o: $(USER_LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/hw/%.o: $(HW_LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/hw/%.o: $(HW_LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/arduino/%.o: $(ARDUINO_LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/arduino/%.o: $(ARDUINO_LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/src/%.o: %.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OUTPUT_DIR)/src/%.o: %.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<

View file

@ -0,0 +1,160 @@
ifeq ($(BOARD),uno)
ARCH = avr
BUILD_CORE = arduino
BUILD_VARIANT = standard
BUILD_MCU = atmega328p
BUILD_F_CPU = 16000000L
BUILD_BOARD = AVR_UNO
LOADER = avrdude
LOADER_PROTOCOL = arduino
LOADER_SPEED = 115200
LOADER_MAX_SIZE = 32256
LOADER_MAX_DATA = 2048
endif
VERSION = 164
ifeq ($(ARCH),avr)
CXXFLAGS = -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD \
-mmcu=$(BUILD_MCU) -DF_CPU=$(BUILD_F_CPU) -DARDUINO=$(VERSION) -DARDUINO_$(BUILD_BOARD) -DARDUINO_ARCH_AVR $(INCLUDES)
CFLAGS = -g -Os -w -ffunction-sections -fdata-sections -MMD \
-mmcu=$(BUILD_MCU) -DF_CPU=$(BUILD_F_CPU) -DARDUINO=156 -DARDUINO_$(BUILD_BOARD) -DARDUINO_ARCH_AVR $(INCLUDES)
CXX = avr-g++
CC = avr-gcc
AR = avr-ar
OBJCOPY = avr-objcopy
define do_link
$(CC) -Os -Wl,--gc-sections -mmcu=$(BUILD_MCU) -o $(OUTPUT_DIR)/$(EXE).elf $^
avr-objcopy -O ihex -R .eeprom $(OUTPUT_DIR)/$(EXE).elf $(OUTPUT_DIR)/$(EXE).hex
$(do_link_extra)
avr-size $(OUTPUT_DIR)/$(EXE).elf
@echo Max text: $(LOADER_MAX_SIZE)
@echo Max data + bss: $(LOADER_MAX_DATA)
endef
define do_eeprom
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load \
--no-change-warnings --change-section-lma .eeprom=0 \
$(OUTPUT_DIR)/$(EXE).elf $(OUTPUT_DIR)/$(EXE).eep
endef
define do_load_avrdude
avrdude -C"$(ARDUINO_HOME)/hardware/tools/avr/etc/avrdude.conf" -p$(BUILD_MCU) -c$(LOADER_PROTOCOL) \
-P$(SERIAL_PORT) -b$(LOADER_SPEED) -D "-Uflash:w:$(OUTPUT_DIR)/$(EXE).hex:i"
endef
endif # ARCH = avr
space :=
space +=
spacify = $(subst $(space),\$(space),$1)
ifeq ($(OS),Windows_NT)
RMDIR = rmdir /s /q
fixpath = $(subst /,\,$1)
mymkdir = if not exist "$(call fixpath,$1)" mkdir $(call fixpath,$1)
else
RMDIR = rm -fr
fixpath = $1
mymkdir = mkdir -p $1
endif
src_recurse = $(foreach d,$(subst $2/,,$(wildcard $1*)),$(call src_recurse,$3/$d/,$2,$3) $(filter %.c %.cpp,$d))
src = $(foreach lib,$3,$(if $(wildcard $2/$(lib)/src),$(call src_recurse,$2/$(lib)/src/,$1,$2),\
$(subst $1/,,\
$(wildcard $2/$(lib)/*.c)\
$(wildcard $2/$(lib)/*.cpp)\
$(wildcard $2/$(lib)/utility/*.c)\
$(wildcard $2/$(lib)/utility/*.cpp)))))
objs = $(patsubst %.c,$2/%.o,$(filter %.c,$1)) $(patsubst %.cpp,$2/%.o,$(filter %.cpp,$1))
incs = $(foreach lib,$1,$(if $(wildcard $3/$(lib)/src),-I"$2/$(lib)/src",-I"$2/$(lib)" -I"$2/$(lib)/utility"))
PROJECT_OBJS = $(call objs,$(call src_recurse,./,.,.),$(OUTPUT_DIR)/src)
LIB_ROOT = $(ARDUINO_HOME)/hardware/arduino/$(ARCH)/cores/$(BUILD_CORE)
LIB_ROOT_SPC = $(call spacify,$(LIB_ROOT))
LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(LIB_ROOT_SPC)))
LIB_OBJS = $(call objs,$(call src_recurse,$(LIB_ROOT_SPC)/,$(LIB_ROOT),$(LIB_ROOT_SPC)),$(OUTPUT_DIR)/lib)
USER_LIB_ROOT = $(ARDUINO_USER_LIBS)
USER_LIB_ROOT_SPC = $(call spacify,$(USER_LIB_ROOT))
USER_LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(USER_LIB_ROOT_SPC)))
USER_LIBS = $(foreach lib,$(LIBS),$(subst $(USER_LIB_ROOT)/,,$(wildcard $(USER_LIB_ROOT_SPC)/$(lib))))
USER_INCLUDES = $(call incs,$(USER_LIBS),$(USER_LIB_ROOT),$(USER_LIB_ROOT_SPC))
USER_OBJS = $(call objs,$(call src,$(USER_LIB_ROOT),$(USER_LIB_ROOT_SPC),$(USER_LIBS)),$(OUTPUT_DIR)/user)
HW_LIB_ROOT = $(ARDUINO_HOME)/hardware/arduino/$(ARCH)/libraries
HW_LIB_ROOT_SPC = $(call spacify,$(HW_LIB_ROOT))
HW_LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(HW_LIB_ROOT_SPC)))
HW_LIBS = $(foreach lib, $(LIBS), $(subst $(HW_LIB_ROOT)/,,$(wildcard $(HW_LIB_ROOT_SPC)/$(lib))))
HW_INCLUDES = $(call incs,$(HW_LIBS),$(HW_LIB_ROOT),$(HW_LIB_ROOT_SPC))
HW_OBJS = $(call objs,$(call src,$(HW_LIB_ROOT),$(HW_LIB_ROOT_SPC),$(HW_LIBS)),$(OUTPUT_DIR)/hw)
ARDUINO_LIB_ROOT = $(ARDUINO_HOME)/libraries
ARDUINO_LIB_ROOT_SPC = $(call spacify,$(ARDUINO_LIB_ROOT))
ARDUINO_LIB_ROOT_SPC2 = $(subst :,\:,$(subst \,\\\,$(ARDUINO_LIB_ROOT_SPC)))
ARDUINO_LIBS = $(foreach lib, $(LIBS), $(subst $(ARDUINO_LIB_ROOT)/,,$(wildcard $(ARDUINO_LIB_ROOT_SPC)/$(lib))))
ARDUINO_INCLUDES = $(call incs,$(ARDUINO_LIBS),$(ARDUINO_LIB_ROOT),$(ARDUINO_LIB_ROOT_SPC))
ARDUINO_OBJS = $(call objs,$(call src,$(ARDUINO_LIB_ROOT),$(ARDUINO_LIB_ROOT_SPC),$(ARDUINO_LIBS)),$(OUTPUT_DIR)/arduino)
INCLUDES = -I"$(ARDUINO_HOME)/hardware/arduino/$(ARCH)/cores/$(BUILD_CORE)" \
-I"$(ARDUINO_HOME)/hardware/arduino/$(ARCH)/variants/$(BUILD_VARIANT)" \
$(USER_INCLUDES) $(HW_INCLUDES) $(ARDUINO_INCLUDES)
OBJS = $(PROJECT_OBJS) $(USER_OBJS) $(HW_OBJS) $(ARDUINO_OBJS)
all: $(OUTPUT_DIR)/$(EXE).hex
clean:
$(RMDIR) $(call fixpath,$(OUTPUT_DIR))
load: $(OUTPUT_DIR)/$(EXE).hex
$(do_load_$(LOADER))
$(OUTPUT_DIR)/$(EXE).hex: $(OBJS) $(OUTPUT_DIR)/core.a
$(do_link)
$(OUTPUT_DIR)/core.a: $(LIB_OBJS)
$(AR) r $@ $?
$(OUTPUT_DIR)/lib/%.o: $(LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/lib/%.o: $(LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/user/%.o: $(USER_LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/user/%.o: $(USER_LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/hw/%.o: $(HW_LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/hw/%.o: $(HW_LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/arduino/%.o: $(ARDUINO_LIB_ROOT_SPC2)/%.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/arduino/%.o: $(ARDUINO_LIB_ROOT_SPC2)/%.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ "$<"
$(OUTPUT_DIR)/src/%.o: %.c
@-$(call mymkdir,$(dir $@))
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OUTPUT_DIR)/src/%.o: %.cpp
@-$(call mymkdir,$(dir $@))
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<

View file

@ -10,4 +10,4 @@
############################################################################### ###############################################################################
pluginName=Arduino C++ UI pluginName=Arduino C++ UI
providerName=Eclipse CDT providerName=Eclipse CDT
preferencePage.name=Arduino C++ preferencePage.name=Arduino

View file

@ -5,7 +5,7 @@
point="org.eclipse.debug.ui.launchConfigurationTypeImages"> point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage <launchConfigurationTypeImage
configTypeID="org.eclipse.cdt.arduino.core.launchConfigurationType" configTypeID="org.eclipse.cdt.arduino.core.launchConfigurationType"
icon="icons/logo.png" icon="icons/arduino.png"
id="org.eclipse.cdt.arduino.ui.launchConfigurationTypeImage1"> id="org.eclipse.cdt.arduino.ui.launchConfigurationTypeImage1">
</launchConfigurationTypeImage> </launchConfigurationTypeImage>
</extension> </extension>
@ -45,7 +45,7 @@
selectionFilter="single"> selectionFilter="single">
<enabledWhen> <enabledWhen>
<adapt <adapt
type="org.eclipse.cdt.arduino.core.remote.IArduinoRemoteConnection"> type="org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection">
</adapt> </adapt>
</enabledWhen> </enabledWhen>
</page> </page>
@ -68,9 +68,16 @@
<extension <extension
point="org.eclipse.ui.preferencePages"> point="org.eclipse.ui.preferencePages">
<page <page
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.arduino.ui.internal.ArduinoPreferencePage" class="org.eclipse.cdt.arduino.ui.internal.ArduinoPreferencePage"
id="org.eclipse.cdt.arduino.ui.page1" id="org.eclipse.cdt.arduino.preference.page"
name="%preferencePage.name"> name="%preferencePage.name">
</page> </page>
</extension> </extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.eclipse.cdt.arduino.ui.internal.ArduinoPreferenceInitializer">
</initializer>
</extension>
</plugin> </plugin>

View file

@ -14,7 +14,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceReference;
@ -29,10 +28,10 @@ public class Activator extends AbstractUIPlugin {
public static final String IMG_ARDUINO = PLUGIN_ID + ".arduino"; //$NON-NLS-1$ public static final String IMG_ARDUINO = PLUGIN_ID + ".arduino"; //$NON-NLS-1$
public static final String IMG_CONNECTION_TYPE = PLUGIN_ID + ".connectionType"; //$NON-NLS-1$ public static final String IMG_CONNECTION_TYPE = PLUGIN_ID + ".connectionType"; //$NON-NLS-1$
// The shared instance // The shared instance
private static Activator plugin; private static Activator plugin;
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
super.start(context); super.start(context);
plugin = this; plugin = this;

View file

@ -0,0 +1,15 @@
package org.eclipse.cdt.arduino.ui.internal;
import org.eclipse.cdt.arduino.core.ArduinoHome;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
public class ArduinoPreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(ArduinoHome.preferenceName, ArduinoHome.getDefault());
}
}

View file

@ -10,6 +10,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.arduino.ui.internal; package org.eclipse.cdt.arduino.ui.internal;
import org.eclipse.cdt.arduino.core.ArduinoHome;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.IWorkbenchPreferencePage;
@ -18,25 +20,18 @@ public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
public ArduinoPreferencePage() { public ArduinoPreferencePage() {
super(GRID); super(GRID);
setDescription("Arduino C++ Preferences");
setPreferenceStore(Activator.getDefault().getPreferenceStore());
} }
@Override @Override
protected void createFieldEditors() { protected void createFieldEditors() {
addField(new DirectoryFieldEditor(ArduinoHome.preferenceName, Messages.ArduinoPreferencePage_0,
getFieldEditorParent()));
} }
@Override @Override
public void init(IWorkbench workbench) { public void init(IWorkbench workbench) {
// TODO Auto-generated method stub setDescription(Messages.ArduinoPreferencePage_1);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
}
@Override
public void dispose() {
// TODO Auto-generated method stub
super.dispose();
} }
} }

View file

@ -0,0 +1,31 @@
package org.eclipse.cdt.arduino.ui.internal;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.arduino.ui.internal.messages"; //$NON-NLS-1$
public static String ArduinoLaunchConsole_0;
public static String ArduinoLaunchConsole_1;
public static String ArduinoLaunchConsole_2;
public static String ArduinoLaunchConsole_3;
public static String ArduinoPreferencePage_0;
public static String ArduinoPreferencePage_1;
public static String ArduinoTargetPropertyPage_0;
public static String ArduinoTargetPropertyPage_1;
public static String ArduinoTargetPropertyPage_2;
public static String NewArduinoProjectWizard_0;
public static String NewArduinoTargetWizardPage_0;
public static String NewArduinoTargetWizardPage_1;
public static String NewArduinoTargetWizardPage_2;
public static String NewArduinoTargetWizardPage_3;
public static String NewArduinoTargetWizardPage_4;
public static String NewArduinoTargetWizardPage_5;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -14,6 +14,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.eclipse.cdt.arduino.core.ArduinoLaunchConsoleService; import org.eclipse.cdt.arduino.core.ArduinoLaunchConsoleService;
import org.eclipse.cdt.arduino.ui.internal.Messages;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -31,7 +32,7 @@ public class ArduinoLaunchConsole implements ArduinoLaunchConsoleService {
public ArduinoLaunchConsole() { public ArduinoLaunchConsole() {
if (console == null) { if (console == null) {
console = new MessageConsole("Arduino Launch", null); console = new MessageConsole(Messages.ArduinoLaunchConsole_0, null);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console }); ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
} }
} }
@ -41,12 +42,12 @@ public class ArduinoLaunchConsole implements ArduinoLaunchConsoleService {
console.clearConsole(); console.clearConsole();
console.activate(); console.activate();
new UIJob("Start Arduino Console") { new UIJob(Messages.ArduinoLaunchConsole_1) {
@Override @Override
public IStatus runInUIThread(IProgressMonitor monitor) { public IStatus runInUIThread(IProgressMonitor monitor) {
final IOConsoleOutputStream out = console.newOutputStream(); final IOConsoleOutputStream out = console.newOutputStream();
out.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); out.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
new Thread("Arduino Launch Console Output") { new Thread(Messages.ArduinoLaunchConsole_2) {
public void run() { public void run() {
try (InputStream processOut = process.getInputStream()) { try (InputStream processOut = process.getInputStream()) {
for (int c = processOut.read(); c >= 0; c = processOut.read()) { for (int c = processOut.read(); c >= 0; c = processOut.read()) {
@ -60,7 +61,7 @@ public class ArduinoLaunchConsole implements ArduinoLaunchConsoleService {
final IOConsoleOutputStream err = console.newOutputStream(); final IOConsoleOutputStream err = console.newOutputStream();
err.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED)); err.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
new Thread("Arduino Launch Console Output") { new Thread(Messages.ArduinoLaunchConsole_3) {
public void run() { public void run() {
try (InputStream processErr = process.getErrorStream()) { try (InputStream processErr = process.getErrorStream()) {
for (int c = processErr.read(); c >= 0; c = processErr.read()) { for (int c = processErr.read(); c >= 0; c = processErr.read()) {

View file

@ -0,0 +1,16 @@
ArduinoLaunchConsole_0=Arduino Launch
ArduinoLaunchConsole_1=Start Arduino Console
ArduinoLaunchConsole_2=Arduino Launch Console Output
ArduinoLaunchConsole_3=Arduino Launch Console Output
ArduinoPreferencePage_0=Arduino IDE Install Location
ArduinoPreferencePage_1=Arduino C++ Preferences
ArduinoTargetPropertyPage_0=Serial Port:
ArduinoTargetPropertyPage_1=No serial ports
ArduinoTargetPropertyPage_2=Board type:
NewArduinoProjectWizard_0=Creating Aurdino Project
NewArduinoTargetWizardPage_0=New Arduino Target settings
NewArduinoTargetWizardPage_1=New Arduino Target
NewArduinoTargetWizardPage_2=Target name:
NewArduinoTargetWizardPage_3=
NewArduinoTargetWizardPage_4=Serial port:
NewArduinoTargetWizardPage_5=Board type:

View file

@ -2,6 +2,7 @@ package org.eclipse.cdt.arduino.ui.internal.project;
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator; import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
import org.eclipse.cdt.arduino.ui.internal.Activator; import org.eclipse.cdt.arduino.ui.internal.Activator;
import org.eclipse.cdt.arduino.ui.internal.Messages;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -24,7 +25,7 @@ public class NewArduinoProjectWizard extends BasicNewProjectResourceWizard {
if (!super.performFinish()) if (!super.performFinish())
return false; return false;
new Job("Creating Aurdino Project") { new Job(Messages.NewArduinoProjectWizard_0) {
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
try { try {
final ArduinoProjectGenerator generator = new ArduinoProjectGenerator(getNewProject()); final ArduinoProjectGenerator generator = new ArduinoProjectGenerator(getNewProject());

View file

@ -7,6 +7,7 @@ import org.eclipse.cdt.arduino.core.Board;
import org.eclipse.cdt.arduino.core.IArduinoBoardManager; import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection; import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
import org.eclipse.cdt.arduino.ui.internal.Activator; import org.eclipse.cdt.arduino.ui.internal.Activator;
import org.eclipse.cdt.arduino.ui.internal.Messages;
import org.eclipse.cdt.serial.SerialPort; import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy; import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
@ -37,7 +38,7 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
IArduinoRemoteConnection arduinoRemote = remoteConnection.getService(IArduinoRemoteConnection.class); IArduinoRemoteConnection arduinoRemote = remoteConnection.getService(IArduinoRemoteConnection.class);
Label portLabel = new Label(comp, SWT.NONE); Label portLabel = new Label(comp, SWT.NONE);
portLabel.setText("Serial Port:"); portLabel.setText(Messages.ArduinoTargetPropertyPage_0);
portSelector = new Combo(comp, SWT.READ_ONLY); portSelector = new Combo(comp, SWT.READ_ONLY);
portSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); portSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -60,12 +61,12 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
if (portSel >= 0) { if (portSel >= 0) {
portSelector.select(portSel); portSelector.select(portSel);
} else { } else {
setMessage("No serial ports", ERROR); setMessage(Messages.ArduinoTargetPropertyPage_1, ERROR);
setValid(false); setValid(false);
} }
Label boardLabel = new Label(comp, SWT.NONE); Label boardLabel = new Label(comp, SWT.NONE);
boardLabel.setText("Board type:"); boardLabel.setText(Messages.ArduinoTargetPropertyPage_2);
boardSelector = new Combo(comp, SWT.READ_ONLY); boardSelector = new Combo(comp, SWT.READ_ONLY);
boardSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); boardSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

View file

@ -5,6 +5,7 @@ import java.io.IOException;
import org.eclipse.cdt.arduino.core.Board; import org.eclipse.cdt.arduino.core.Board;
import org.eclipse.cdt.arduino.core.IArduinoBoardManager; import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
import org.eclipse.cdt.arduino.ui.internal.Activator; import org.eclipse.cdt.arduino.ui.internal.Activator;
import org.eclipse.cdt.arduino.ui.internal.Messages;
import org.eclipse.cdt.serial.SerialPort; import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -33,9 +34,9 @@ public class NewArduinoTargetWizardPage extends WizardPage {
private Combo boardCombo; private Combo boardCombo;
public NewArduinoTargetWizardPage() { public NewArduinoTargetWizardPage() {
super("NewArduinoTargetPage"); super("NewArduinoTargetPage"); //$NON-NLS-1$
setDescription("New Arduino Target settings"); setDescription(Messages.NewArduinoTargetWizardPage_0);
setTitle("New Arduino Target"); setTitle(Messages.NewArduinoTargetWizardPage_1);
} }
@Override @Override
@ -44,11 +45,11 @@ public class NewArduinoTargetWizardPage extends WizardPage {
comp.setLayout(new GridLayout(2, false)); comp.setLayout(new GridLayout(2, false));
Label nameLabel = new Label(comp, SWT.NONE); Label nameLabel = new Label(comp, SWT.NONE);
nameLabel.setText("Target name:"); nameLabel.setText(Messages.NewArduinoTargetWizardPage_2);
nameText = new Text(comp, SWT.BORDER | SWT.SINGLE); nameText = new Text(comp, SWT.BORDER | SWT.SINGLE);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
nameText.setText(""); nameText.setText(Messages.NewArduinoTargetWizardPage_3);
nameText.addKeyListener(new KeyListener() { nameText.addKeyListener(new KeyListener() {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
@ -61,7 +62,7 @@ public class NewArduinoTargetWizardPage extends WizardPage {
}); });
Label portLabel = new Label(comp, SWT.NONE); Label portLabel = new Label(comp, SWT.NONE);
portLabel.setText("Serial port:"); portLabel.setText(Messages.NewArduinoTargetWizardPage_4);
portCombo = new Combo(comp, SWT.READ_ONLY); portCombo = new Combo(comp, SWT.READ_ONLY);
portCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); portCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -83,9 +84,9 @@ public class NewArduinoTargetWizardPage extends WizardPage {
}); });
IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class); IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
Label boardLabel = new Label(comp, SWT.NONE); Label boardLabel = new Label(comp, SWT.NONE);
boardLabel.setText("Board type:"); boardLabel.setText(Messages.NewArduinoTargetWizardPage_5);
boardCombo = new Combo(comp, SWT.READ_ONLY); boardCombo = new Combo(comp, SWT.READ_ONLY);
boardCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); boardCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));