Improved Windows (Cygwin/MSYS) support

Changed RESET_CMD structure under Cygwin
Changed behaviour of get_monitor_port under Windows

DEVICE_PATH always becomes/dev/ttyS[0-9] on Windows
MONITOR_PORT always becomes com[0-9] on Windows
This commit is contained in:
Peter Mosmans 2014-11-23 14:44:22 +10:00
parent 6053817833
commit 5f1a5a2ac0
2 changed files with 29 additions and 16 deletions

View file

@ -691,11 +691,19 @@ ifndef RESET_CMD
ARD_RESET_ARDUINO = $(ARDMK_DIR)/bin/ard-reset-arduino ARD_RESET_ARDUINO = $(ARDMK_DIR)/bin/ard-reset-arduino
endif endif
ifneq ($(CATERINA),) ifneq ($(CATERINA),)
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(DEVICE_PATH)
else
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port) RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port)
endif
else
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH)
else else
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port) RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
endif endif
endif endif
endif
ifneq ($(CATERINA),) ifneq ($(CATERINA),)
ERROR_ON_CATERINA = $(error On $(BOARD_TAG), raw_xxx operation is not supported) ERROR_ON_CATERINA = $(error On $(BOARD_TAG), raw_xxx operation is not supported)
@ -991,6 +999,7 @@ SIZEFLAGS ?= --mcu=$(MCU) -C
# instead of MONITOR_PORT # instead of MONITOR_PORT
MONITOR_PORT ?= $(ARDUINO_PORT) MONITOR_PORT ?= $(ARDUINO_PORT)
ifneq ($(strip $(MONITOR_PORT)),)
ifeq ($(CURRENT_OS), WINDOWS) ifeq ($(CURRENT_OS), WINDOWS)
# Expect MONITOR_PORT to be '1' or 'com1' for COM1 in Windows. Split it up # Expect MONITOR_PORT to be '1' or 'com1' for COM1 in Windows. Split it up
# into the two styles required: /dev/ttyS* for ard-reset-arduino and com* # into the two styles required: /dev/ttyS* for ard-reset-arduino and com*
@ -1000,11 +1009,10 @@ ifeq ($(CURRENT_OS), WINDOWS)
COM_PORT_ID = $(subst com,,$(MONITOR_PORT)) COM_PORT_ID = $(subst com,,$(MONITOR_PORT))
COM_STYLE_MONITOR_PORT = com$(COM_PORT_ID) COM_STYLE_MONITOR_PORT = com$(COM_PORT_ID)
DEVICE_PATH = /dev/ttyS$(shell awk 'BEGIN{ print $(COM_PORT_ID) - 1 }') DEVICE_PATH = /dev/ttyS$(shell awk 'BEGIN{ print $(COM_PORT_ID) - 1 }')
endif else
ifneq ($(strip $(MONITOR_PORT)),)
# set DEVICE_PATH based on user-defined MONITOR_PORT or ARDUINO_PORT # set DEVICE_PATH based on user-defined MONITOR_PORT or ARDUINO_PORT
DEVICE_PATH = $(MONITOR_PORT) DEVICE_PATH = $(MONITOR_PORT)
endif
$(call show_config_variable,DEVICE_PATH,[COMPUTED],(from MONITOR_PORT)) $(call show_config_variable,DEVICE_PATH,[COMPUTED],(from MONITOR_PORT))
else else
# If no port is specified, try to guess it from wildcards. # If no port is specified, try to guess it from wildcards.
@ -1015,7 +1023,11 @@ else
endif endif
# Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. # Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors.
ifeq ($(CURRENT_OS), WINDOWS)
get_monitor_port = $(COM_STYLE_MONITOR_PORT)
else
get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!)) get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!))
endif
# Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors. # Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors.
get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(if $(findstring Xusb,X$(ISP_PORT)),$(ISP_PORT),$(error ISP port $(ISP_PORT) not found!))) get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(if $(findstring Xusb,X$(ISP_PORT)),$(ISP_PORT),$(error ISP port $(ISP_PORT) not found!)))

View file

@ -22,6 +22,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- Tweak: Update travis-ci to test against Arduino 1.0.6. (https://github.com/sej7278) - Tweak: Update travis-ci to test against Arduino 1.0.6. (https://github.com/sej7278)
- Tweak: Updated package instructions for Arch/Fedora/Raspbian. (https://github.com/sej7278) - Tweak: Updated package instructions for Arch/Fedora/Raspbian. (https://github.com/sej7278)
- Fix: Improved Windows (Cygwin/MSYS) support (https://github.com/PeterMosmans)
- Fix: Change "tinyladi" username to "ladislas" in HISTORY.md. (https://github.com/ladislas) - Fix: Change "tinyladi" username to "ladislas" in HISTORY.md. (https://github.com/ladislas)
- Fix: Make avr-g++ use CXXFLAGS instead of CFLAGS. (https://github.com/sej7278) - Fix: Make avr-g++ use CXXFLAGS instead of CFLAGS. (https://github.com/sej7278)
- Fix: Allow the use of CFLAGS_STD and CXXFLAGS_STD and set defaults (Issue #234) (https://github.com/ladislas) - Fix: Allow the use of CFLAGS_STD and CXXFLAGS_STD and set defaults (Issue #234) (https://github.com/ladislas)