From bdeaf1576be76beae3f223816692fd0dd6626f09 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Wed, 17 Jul 2019 10:19:03 +0200 Subject: [PATCH 01/13] ARM_TOOL_PATH detection, use latest version of tool if multiple found --- Sam.mk | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Sam.mk b/Sam.mk index a014e63..7f3cd2b 100644 --- a/Sam.mk +++ b/Sam.mk @@ -160,14 +160,6 @@ ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due) SAM_CORE_C_SRCS += $(wildcard $(SAM_SYSTEM_PATH)/source/*.c) endif -# Use arm-toolchain from Arduino install if exists and user has not defined global version -ifndef ARM_TOOLS_DIR - ARM_TOOLS_DIR = $(call dir_if_exists,$(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/*)) - $(call show_config_variable,ARM_TOOLS_DIR,[COMPUTED],(from ARDUINO_PACKAGE_DIR)) -else - $(call show_config_variable,ARM_TOOLS_DIR,[USER]) -endif - # define plaform lib dir from Arduino ARM support ifndef ARDUINO_PLATFORM_LIB_PATH ARDUINO_PLATFORM_LIB_PATH := $(ALTERNATE_CORE_PATH)/libraries @@ -179,6 +171,20 @@ endif TOOL_PREFIX = arm-none-eabi +# Use arm-toolchain from Arduino package install if exists and user has not defined global version +# if undefined, AVR_TOOLS_DIR will resolve in Arduino.mk as a last resort as Arduino now installs with arm-gcc +ifndef ARM_TOOLS_DIR + ifndef ARM_TOOLS_VER + ARM_TOOLS_VER := $(shell basename $(lastword $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/*))) + endif + ARM_TOOLS_DIR = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/$(ARM_TOOLS_VER) + ifdef ARM_TOOLS_DIR + $(call show_config_variable,ARM_TOOLS_DIR,[COMPUTED],(from ARDUINO_PACKAGE_DIR)) + endif +else + $(call show_config_variable,ARM_TOOLS_DIR,[USER]) +endif + ifndef GDB_NAME GDB_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gdb) ifndef GDB_NAME @@ -246,7 +252,9 @@ ifndef OPENOCD BUNDLED_OPENOCD_DIR := $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/openocd) # Try Arduino support package first ifdef BUNDLED_OPENOCD_DIR - OPENOCD_VER := $(shell basename $(wildcard $(BUNDLED_OPENOCD_DIR)/*)) + ifndef OPENOCD_VER + OPENOCD_VER := $(shell basename $(lastword $(wildcard $(BUNDLED_OPENOCD_DIR)/*))) + endif OPENOCD = $(BUNDLED_OPENOCD_DIR)/$(OPENOCD_VER)/bin/openocd -s $(BUNDLED_OPENOCD_DIR)/$(OPENOCD_VER)/share/openocd/scripts/ $(call show_config_variable,OPENOCD,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) else @@ -271,7 +279,9 @@ ifndef BOSSA BUNDLED_BOSSA_DIR := $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/bossac) # Try Arduino support package first ifdef BUNDLED_BOSSA_DIR - BOSSA_VER := $(shell basename $(wildcard $(BUNDLED_BOSSA_DIR)/*)) + ifndef BOSSA_VER + BOSSA_VER := $(shell basename $(lastword $(wildcard $(BUNDLED_BOSSA_DIR)/*))) + endif BOSSA = $(BUNDLED_BOSSA_DIR)/$(BOSSA_VER)/bossac $(call show_config_variable,BOSSA,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) else From 62caf00a157d410b98f93c3d9c4cf543d85b00b0 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Thu, 18 Jul 2019 11:10:42 +0200 Subject: [PATCH 02/13] Add new *_VER variables to documentation --- HISTORY.md | 1 + arduino-mk-vars.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 8f228fe..4bbe3a7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -18,6 +18,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Tweak: Update Windows usage documentation and allow non-relative paths (issue #519) (https://github.com/tuna-f1sh) - Tweak: Support Cygwin Unix Python and Windows installation on Windows to pass correct port binding. (https://github.com/tuna-f1sh) - Tweak: Update how avr-size is called on Sam, also moved to gnu11 std (issue #602) (https://github.com/tuna-f1sh) +- Tweak: Detect most recent toolchain if multiple found, add `*_VER` variable to override (issue #611) (https://github.com/tuna-f1sh) - New: Added -fdiagnostics-color to \*STD flags (https://github.com/sej7278) - New: Made -fdiagnostics-color take a variiable DIAGNOSTICS_COLOR_WHEN: never, always, auto. (https://github.com/wingunder) - New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 85fbd9f..9ef5b19 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -97,6 +97,25 @@ ARM_TOOLS_DIR = ---- +### ARM_TOOLS_VER + +**Description:** + +Sub-directory where the arm toolchain is installed - usually the tool version. + +Can usually be detected from `$ARDUINO_PACKAGE_DIR` /tools subdirectory when ARM +device support is installed. Will resolve latest version if multiple found. + +**Example:** + +```Makefile +ARM_TOOLS_VER = 7-2017q4 +``` + +**Requirement:** *Optional* + +---- + ### RESET_CMD **Description:** @@ -1798,6 +1817,16 @@ device support is installed. ---- +### BOSSA_VER + +**Description:** + +`bossa` sub-directory - usually the tool version. Will auto-detect to highest version found. + +**Requirement:** *Optional* + +---- + ### BOSSA_OPTS **Description:** @@ -1823,6 +1852,16 @@ device support is installed. ---- +### OPENOCD_VER + +**Description:** + +`openocd` sub-directory - usually the tool version. Will auto-detect to highest version found. + +**Requirement:** *Optional* + +---- + ### OPENOCD_OPTS **Description:** From e6574e3c7217ff5402f00517580a2245de0efd67 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Mon, 24 Feb 2020 09:58:20 +0100 Subject: [PATCH 03/13] switch compliler flags to prevent AR fail on ARM --- Arduino.mk | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Arduino.mk b/Arduino.mk index b9611a0..ea780f2 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -1227,15 +1227,24 @@ CFLAGS += $(CFLAGS_STD) CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD) ASFLAGS += -x assembler-with-cpp DIAGNOSTICS_COLOR_WHEN ?= always -ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) - ASFLAGS += -flto - CXXFLAGS += -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) - CFLAGS += -flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) + +# Flags for AVR +ifeq ($(findstring avr, $(strip $(CC_NAME))), avr) + ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) + ASFLAGS += -flto + CXXFLAGS += -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) + CFLAGS += -flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) + LDFLAGS += -flto -fuse-linker-plugin + endif +# Flags for ARM (most set in Sam.mk) +else + ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) + CXXFLAGS += -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) + CFLAGS += -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) + endif endif + LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL) -ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) - LDFLAGS += -flto -fuse-linker-plugin -endif SIZEFLAGS ?= --mcu=$(MCU) -C # for backwards compatibility, grab ARDUINO_PORT if the user has it set From 26e34cd6f2471f04ba097001a215caed12a8574a Mon Sep 17 00:00:00 2001 From: John Whittington Date: Tue, 4 Aug 2020 11:51:35 +0200 Subject: [PATCH 04/13] detect and use GNU grep on macOS --- Common.mk | 13 +++++++++++-- Sam.mk | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Common.mk b/Common.mk index 0c1f92c..27d2135 100644 --- a/Common.mk +++ b/Common.mk @@ -8,8 +8,8 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # result = $(call READ_BOARD_TXT, 'boardname', 'parameter') PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ then \ - grep -Ev '^\#' $(BOARDS_TXT) | \ - grep -E "^[ \t]*$(1).$(2)=" | \ + $(GREP) -Ev '^\#' $(BOARDS_TXT) | \ + $(GREP) -E "^[ \t]*$(1).$(2)=" | \ cut -d = -f 2- | \ cut -d : -f 2; \ fi) @@ -45,15 +45,24 @@ $(call arduino_output,$(call ardmk_include) Configuration:) ######################################################################## # # Detect OS + ifeq ($(OS),Windows_NT) CURRENT_OS = WINDOWS + GREP := grep else UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) CURRENT_OS = LINUX + GREP := grep endif ifeq ($(UNAME_S),Darwin) CURRENT_OS = MAC + ifeq (, $(shell which ggrep)) + echo $(info Using macOS BSD grep, please install GNU grep to avoid warnings) + GREP := grep + else + GREP := ggrep + endif endif endif $(call show_config_variable,CURRENT_OS,[AUTODETECTED]) diff --git a/Sam.mk b/Sam.mk index 7f3cd2b..f11554f 100644 --- a/Sam.mk +++ b/Sam.mk @@ -404,7 +404,7 @@ CFLAGS_STD += -std=gnu11 CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)' # Get extra define flags from boards.txt -EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | grep -oE '(-D)\w+') +EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP) -oE '(-D)\w+') # Strip only defines from extra flags as boards file appends user {build.usb} CPPFLAGS += $(EXFLAGS) From 207253abc6ec81112abf0a64a8bf68e227528d64 Mon Sep 17 00:00:00 2001 From: Simon John Date: Tue, 4 Aug 2020 23:19:49 +0100 Subject: [PATCH 05/13] Rebased python3 branch with some changes from tuna-f1sh@87d5241 --- Arduino.mk | 6 ++--- Common.mk | 21 +++++++++++++++ HISTORY.md | 1 + README.md | 29 +++++++++------------ arduino-mk-vars.md | 16 ++++++++++++ bin/ard-reset-arduino | 13 +-------- bin/ardmk-init | 4 +-- bin/robotis-loader | 4 +-- packaging/fedora/arduino-mk.spec | 10 ++++--- tests/script/bootstrap/common.sh | 18 ++++++------- tests/script/bootstrap/pip-requirements.txt | 2 +- 11 files changed, 76 insertions(+), 48 deletions(-) diff --git a/Arduino.mk b/Arduino.mk index ff94ffe..2a51a95 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -853,15 +853,15 @@ endif # Reset ifndef RESET_CMD - ARD_RESET_ARDUINO := $(shell which ard-reset-arduino 2> /dev/null) + ARD_RESET_ARDUINO := $(PYTHON_CMD) $(shell which ard-reset-arduino 2> /dev/null) ifndef ARD_RESET_ARDUINO # same level as *.mk in bin directory when checked out from git # or in $PATH when packaged - ARD_RESET_ARDUINO = $(ARDMK_DIR)/bin/ard-reset-arduino + ARD_RESET_ARDUINO = $(PYTHON_CMD) $(ARDMK_DIR)/bin/ard-reset-arduino endif ifneq (,$(findstring CYGWIN,$(shell uname -s))) # confirm user is using default cygwin unix Python (which uses ttySx) and not Windows Python (which uses COMx) - ifeq ($(shell which python),/usr/bin/python) + ifeq ($(PYTHON_CMD),/usr/bin/python) RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH) else RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port) diff --git a/Common.mk b/Common.mk index 0c1f92c..d4fb9c1 100644 --- a/Common.mk +++ b/Common.mk @@ -98,3 +98,24 @@ ifeq ($(CURRENT_OS),WINDOWS) echo $(error On Windows, ARDUINO_DIR and other defines must use forward slash and not contain spaces, special characters or be cygdrive relative) endif endif + +######################################################################## +# System Python + +ifndef PYTHON_CMD + # try for Python 3 first + PYTHON_CMD := $(shell which python3 2> /dev/null) + ifdef PYTHON_CMD + $(call show_config_variable,PYTHON_CMD,[AUTODETECTED]) + else + # fall-back to any Python + PYTHON_CMD := $(shell which python 2> /dev/null) + ifdef PYTHON_CMD + $(call show_config_variable,PYTHON_CMD,[AUTODETECTED]) + else + echo $(error "Unable to find system Python! Utility scipts won't work. Override this error by defining PYTHON_CMD") + endif + endif +else + $(call show_config_variable,PYTHON_CMD,[USER]) +endif diff --git a/HISTORY.md b/HISTORY.md index 459858d..7751bde 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -32,6 +32,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - New: Updated Arch instructions. (https://github.com/Akram-Chehaima) - New: Add support for Robotis OpenCR 1.0 boards. - New: Build the ArduinoCore API +- New: Support for Python 3 and multi-os Python installation using new PYTHON_CMD variable. ### 1.6.0 (2017-07-11) - Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278) diff --git a/README.md b/README.md index cab5d19..68a4ae3 100644 --- a/README.md +++ b/README.md @@ -83,14 +83,14 @@ installer or download the distribution zip file and extract it. The Makefile also delegates resetting the board to a short Python program. You'll need to install [`pySerial`](https://pypi.python.org/pypi/pyserial) to use it though. -On most systems you should be able to install it using either `pip` or `easy_install`. +On most systems you should be able to install it using either `pip3` or `easy_install3`. ```sh -pip install pyserial +pip3 install pyserial # or if you prefer easy_install -easy_install -U pyserial +easy_install3 -U pyserial ``` If you prefer to install it as a package, then you can do that as well. @@ -98,23 +98,19 @@ If you prefer to install it as a package, then you can do that as well. On Debian or Ubuntu: ```sh -apt-get install python-serial +apt-get install python3-serial ``` On Fedora: ```sh -yum install pyserial - -# or on Fedora 22+ - -dnf install pyserial +dnf install python3-pyserial ``` On openSUSE: ```sh -zypper install python-serial +zypper install python3-serial ``` On Arch: @@ -123,15 +119,16 @@ On Arch: sudo pacman -S python-pyserial ``` -On Mac using MacPorts: +On macOS using Homebrew (one can install to System Python but this is not recommend or good practice): ```sh -sudo port install py27-serial +brew install python +pip3 install pyserial ``` On Windows: -You need to install Cygwin and its packages for Make, Perl, Python2 and the following Serial library. +You need to install Cygwin and its packages for Make, Perl, Python3 and the following Serial library. Assuming you included Python in your Cygwin installation: @@ -141,15 +138,15 @@ Assuming you included Python in your Cygwin installation: 4. build and install Python module: ``` -python setup.py build -python setup.py install +python3 setup.py build +python3 setup.py install ``` Alternatively, if you have setup Cygwin to use a Windows Python installation, simply install using pip: ``` -pip install pyserial +pip3 install pyserial ``` Arduino-Makefile should automatically detect the Python installation type and diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index f173ac2..adda523 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -115,6 +115,22 @@ RESET_CMD = $(HOME)/gertduino/reset ---- +### PYTHON_CMD + +**Description:** + +Path to Python binary. Requires pyserial module installed. Makefile will error if unable to auto-find as utility scripts will not work. To override this, give it an empty define. + +**Example:** + +```Makefile +PYTHON_CMD = /usr/bin/python3 +``` + +**Requirement:** *Optional* + +---- + ## Arduino IDE variables ### ARDUINO_DIR diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index d6f974f..f03bf66 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,18 +1,11 @@ #!/usr/bin/env python -from __future__ import print_function import serial import serial.tools.list_ports import os.path import argparse from time import sleep -pyserial_version = None -try: - pyserial_version = int(serial.VERSION[0]) -except: - pyserial_version = 2 # less than 2.3 - parser = argparse.ArgumentParser(description='Reset an Arduino') parser.add_argument('--zero', action='store_true', help='Reset Arduino Zero or similar Native USB to enter bootloader') parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.') @@ -65,11 +58,7 @@ if args.zero: ser = serial.Serial(args.port[0], 57600) ser.close() - - if pyserial_version < 3: - ser.setBaudrate(1200) - else: - ser.baudrate = 1200 + ser.baudrate = 1200 # do the open/close at 1200 BAUD ser.open() diff --git a/bin/ardmk-init b/bin/ardmk-init index 51b12f0..604ba02 100755 --- a/bin/ardmk-init +++ b/bin/ardmk-init @@ -1,4 +1,5 @@ #!/usr/bin/env python + """ Arduino-mk Makefile and project initialiser @@ -17,7 +18,6 @@ Example: See `armk-init --help` for CLI arguments """ -from __future__ import print_function import os import argparse @@ -54,7 +54,7 @@ PARSER.add_argument('--cli', action='store_true', help='run with user prompts (r PARSER.add_argument('-P', '--project', action='store_true', help='create boilerplate project with src, lib and bin folder structure') PARSER.add_argument('-t', '--template', action='store_true', - help='create bare minimum Arduino source file') + help='create bare minimum Arduino source file') PARSER.add_argument('-V', '--version', action='version', version='%(prog)s '+ VERSION) ARGS = PARSER.parse_args() diff --git a/bin/robotis-loader b/bin/robotis-loader index 95d4e71..4ac07d4 100755 --- a/bin/robotis-loader +++ b/bin/robotis-loader @@ -1,8 +1,8 @@ -#!/usr/bin/python +#!/usr/bin/env python # This script sends a program on a robotis board (OpenCM9.04 or CM900) # using the robotis bootloader (used in OpenCM IDE) -# +# # Usage: # python robotis-loader.py # diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index b1f07f1..7d0a4df 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -1,6 +1,6 @@ Name: arduino-mk Version: 1.6.0 -Release: 1%{dist} +Release: 2%{dist} Summary: Program your Arduino from the command line Packager: Simon John URL: https://github.com/sudar/Arduino-Makefile @@ -9,8 +9,7 @@ Group: Development/Tools License: LGPLv2+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch -Requires: arduino-core pyserial -BuildRequires: arduino-core +Requires: arduino-core python3-pyserial %description Arduino is an open-source electronics prototyping platform based on @@ -29,6 +28,7 @@ mkdir -p %{buildroot}/%{_datadir}/arduino mkdir -p %{buildroot}/%{_bindir} mkdir -p %{buildroot}/%{_mandir}/man1 mkdir -p %{buildroot}/%{_docdir}/%{name}/examples +sed -i 's/^#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/' bin/* install -m 755 -d %{buildroot}/%{_docdir}/%{name} install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples for dir in `find examples -type d` ; do install -m 755 -d %{buildroot}/%{_docdir}/%{name}/$dir ; done @@ -60,6 +60,10 @@ rm -rf %{buildroot} %{_docdir}/%{name}/examples %changelog +* Wed Jan 22 2020 Simon John +- Added sed for shebang +* Thu Oct 24 2019 Simon John +- Removed BuildRequires * Thu Oct 05 2017 Simon John - Added ardmk-init binary and manpage * Tue Jul 11 2017 Karl Semich diff --git a/tests/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh index c3cd90e..20c1037 100644 --- a/tests/script/bootstrap/common.sh +++ b/tests/script/bootstrap/common.sh @@ -160,22 +160,22 @@ if [ -z $COMMON_SOURCED ]; then fi fi - if ! command -v python >/dev/null 2>&1; then + if ! command -v python3 >/dev/null 2>&1; then echo "Installing Python..." - _install "python" + _install "python3" fi - if ! command -v pip >/dev/null 2>&1; then + if ! command -v pip3 >/dev/null 2>&1; then echo "Installing Pip..." - if ! command -v easy_install >/dev/null 2>&1; then - _install "python-setuptools" + if ! command -v easy_install3 >/dev/null 2>&1; then + _install "python3-setuptools" fi - if ! command -v easy_install >/dev/null 2>&1; then - die "easy_install not available, can't install pip" + if ! command -v easy_install3 >/dev/null 2>&1; then + die "easy_install3 not available, can't install pip3" fi - $SUDO_CMD easy_install pip + $SUDO_CMD easy_install3 pip3 fi PIP_SUDO_CMD= @@ -184,7 +184,7 @@ if [ -z $COMMON_SOURCED ]; then PIP_SUDO_CMD=$SUDO_CMD fi - $PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt + $PIP_SUDO_CMD pip3 install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt COMMON_SOURCED=1 fi diff --git a/tests/script/bootstrap/pip-requirements.txt b/tests/script/bootstrap/pip-requirements.txt index 8313187..205196f 100644 --- a/tests/script/bootstrap/pip-requirements.txt +++ b/tests/script/bootstrap/pip-requirements.txt @@ -1 +1 @@ -pyserial==2.7 +pyserial==3.4 From dff6492a4b07b4db53da23d7159c81697d12b47e Mon Sep 17 00:00:00 2001 From: Simon John Date: Tue, 4 Aug 2020 23:28:36 +0100 Subject: [PATCH 06/13] Fixed SyntaxWarning: "is" vs "==" --- bin/ard-reset-arduino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index f03bf66..51b4577 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -89,7 +89,7 @@ if args.zero: # check if a new port has attached and return the index if it has port_index = new_port(initial_ports, reset_ports) # return the new port if detected, otherwise return passed port - if port_index is -1: + if port_index == -1: bootloader_port = args.port[0] else: bootloader_port = reset_ports[port_index] From 5f5a68aa315e691f2eec64dcb749558c1132fac5 Mon Sep 17 00:00:00 2001 From: Simon John Date: Tue, 4 Aug 2020 23:49:32 +0100 Subject: [PATCH 07/13] Replaced env with python3 shebang --- bin/ard-reset-arduino | 2 +- bin/ardmk-init | 2 +- bin/robotis-loader | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index 51b4577..69a442e 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 import serial import serial.tools.list_ports diff --git a/bin/ardmk-init b/bin/ardmk-init index 604ba02..11d1126 100755 --- a/bin/ardmk-init +++ b/bin/ardmk-init @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 """ Arduino-mk Makefile and project initialiser diff --git a/bin/robotis-loader b/bin/robotis-loader index 4ac07d4..3f3c21b 100755 --- a/bin/robotis-loader +++ b/bin/robotis-loader @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # This script sends a program on a robotis board (OpenCM9.04 or CM900) # using the robotis bootloader (used in OpenCM IDE) From 88dc641c8d582f28243141052517fe03e92e6687 Mon Sep 17 00:00:00 2001 From: Simon John Date: Wed, 5 Aug 2020 00:04:42 +0100 Subject: [PATCH 08/13] removed shebang sed from specfile --- packaging/fedora/arduino-mk.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/packaging/fedora/arduino-mk.spec b/packaging/fedora/arduino-mk.spec index 7d0a4df..559e229 100644 --- a/packaging/fedora/arduino-mk.spec +++ b/packaging/fedora/arduino-mk.spec @@ -28,7 +28,6 @@ mkdir -p %{buildroot}/%{_datadir}/arduino mkdir -p %{buildroot}/%{_bindir} mkdir -p %{buildroot}/%{_mandir}/man1 mkdir -p %{buildroot}/%{_docdir}/%{name}/examples -sed -i 's/^#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/' bin/* install -m 755 -d %{buildroot}/%{_docdir}/%{name} install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples for dir in `find examples -type d` ; do install -m 755 -d %{buildroot}/%{_docdir}/%{name}/$dir ; done @@ -60,8 +59,6 @@ rm -rf %{buildroot} %{_docdir}/%{name}/examples %changelog -* Wed Jan 22 2020 Simon John -- Added sed for shebang * Thu Oct 24 2019 Simon John - Removed BuildRequires * Thu Oct 05 2017 Simon John From bcce50471e264bcd8376b3c277600af629684083 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Thu, 6 Aug 2020 09:23:39 +0200 Subject: [PATCH 09/13] add python3 and pip3 to travis yml --- .travis.yml | 5 +++++ tests/script/bootstrap/common.sh | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 630965a..dce5451 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,8 @@ compiler: - gcc script: tests/script/runtests.sh before_install: tests/script/bootstrap.sh +addons: + apt: + packages: + - "python3" + - "python3-pip" diff --git a/tests/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh index 20c1037..221dd21 100644 --- a/tests/script/bootstrap/common.sh +++ b/tests/script/bootstrap/common.sh @@ -167,13 +167,7 @@ if [ -z $COMMON_SOURCED ]; then if ! command -v pip3 >/dev/null 2>&1; then echo "Installing Pip..." - if ! command -v easy_install3 >/dev/null 2>&1; then - _install "python3-setuptools" - fi - - if ! command -v easy_install3 >/dev/null 2>&1; then - die "easy_install3 not available, can't install pip3" - fi + _install "python3-pip" $SUDO_CMD easy_install3 pip3 fi From 264f8f604a2c29b7bd66a1e0d11f263db7582702 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Thu, 6 Aug 2020 09:38:07 +0200 Subject: [PATCH 10/13] Arduino IDE upto support version and SAMD builds process uses direct downloads. Might be better to move to distribution Arduino install + arduino-cli to install board support in future. --- Common.mk | 6 +++- HISTORY.md | 1 + Sam.mk | 10 +++++++ tests/script/bootstrap.sh | 1 + tests/script/bootstrap/arduino.sh | 8 ++++-- tests/script/bootstrap/samd.sh | 46 +++++++++++++++++++++++++++++++ tests/script/runtests.sh | 2 +- 7 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 tests/script/bootstrap/samd.sh diff --git a/Common.mk b/Common.mk index 5421b96..65dc126 100644 --- a/Common.mk +++ b/Common.mk @@ -78,7 +78,11 @@ ifneq ($(TEST),) MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR) endif - DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/arduino-1.0.6 + ifndef ARDUINO_IDE_DIR + ARDUINO_IDE_DIR := $(shell basename $(basename $(basename $(lastword $(wildcard $(DEPENDENCIES_DIR)/arduino*))))) + # ARDUINO_IDE_DIR := arduino + endif + DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/$(ARDUINO_IDE_DIR) ifeq ($(ARDUINO_DIR),) ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR) endif diff --git a/HISTORY.md b/HISTORY.md index 8950c7e..0641531 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,6 +12,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: recognize serial monitors with full path in MONITOR_CMD - Fix: Grab USB_PRODUCT and USB_MANUFACTURER from boards.txt for 32u4 boards (issue #594). - Fix: Show the configuration when ARDUINO_QUIET=0 +- Fix: Travis build and bring Arduino IDE upto date - Tweak: Move chip erase flag from set_fuses to ispload to prevent sketch being nuked when setting fuses - Tweak: Set ARDMK_VERSION to 1.6 (https://github.com/sej7278) - Tweak: Move non-standard-related items from CxxFLAGS_STD to CxxFLAGS (issue #523) (https://github.com/sej7278) diff --git a/Sam.mk b/Sam.mk index f11554f..2aa3078 100644 --- a/Sam.mk +++ b/Sam.mk @@ -31,6 +31,16 @@ ifndef COMMON_INCLUDED include $(ARDMK_DIR)/Common.mk endif +ifneq ($(TEST),) + CORE_VER = 1.8.6 + CMSIS_VER = 4.5.0 + CMSIS_ATMEL_VER = 1.2.0 + ALTERNATE_CORE_PATH = $(DEPENDENCIES_DIR)/samd + CMSIS_DIR = $(DEPENDENCIES_DIR)/CMSIS/CMSIS + CMSIS_ATMEL_DIR = $(DEPENDENCIES_DIR)/CMSIS-Atmel/CMSIS + ARM_TOOLS_DIR = $(basename $(basename $(firstword $(wildcard $(DEPENDENCIES_DIR)/gcc-arm-none-eabi*)))) +endif + ifndef ARDUINO_PACKAGE_DIR # attempt to find based on Linux, macOS and Windows default ARDUINO_PACKAGE_DIR := $(firstword \ diff --git a/tests/script/bootstrap.sh b/tests/script/bootstrap.sh index 083bf5d..0dbd7b2 100755 --- a/tests/script/bootstrap.sh +++ b/tests/script/bootstrap.sh @@ -7,3 +7,4 @@ pushd $SCRIPTS_DIR/.. source $SCRIPTS_DIR/bootstrap/chipkit.sh source $SCRIPTS_DIR/bootstrap/arduino.sh +source $SCRIPTS_DIR/bootstrap/samd.sh diff --git a/tests/script/bootstrap/arduino.sh b/tests/script/bootstrap/arduino.sh index 7c2c9ac..371c0ef 100644 --- a/tests/script/bootstrap/arduino.sh +++ b/tests/script/bootstrap/arduino.sh @@ -8,7 +8,8 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then echo "Installing Arduino..." - ARDUINO_BASENAME="arduino-1.0.6" + ARDUINO_BASENAME="arduino-1.8.11" + if [ $OS == "cygwin" ]; then ARDUINO_FILE="$ARDUINO_BASENAME-windows".zip EXTRACT_COMMAND="unzip -q" @@ -16,8 +17,8 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip EXTRACT_COMMAND="unzip -q" else - ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tgz - EXTRACT_COMMAND="tar -xzf" + ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tar.xz + EXTRACT_COMMAND="tar -xf" fi ARDUINO_URL=http://arduino.cc/download.php?f=/$ARDUINO_FILE @@ -33,6 +34,7 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then then echo "Installing Arduino to local folder..." $EXTRACT_COMMAND $ARDUINO_FILE + mv $ARDUINO_BASENAME arduino echo "Arduino installed" fi diff --git a/tests/script/bootstrap/samd.sh b/tests/script/bootstrap/samd.sh new file mode 100644 index 0000000..fdd50f5 --- /dev/null +++ b/tests/script/bootstrap/samd.sh @@ -0,0 +1,46 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the SAMD boards" + +# these extract to dirs without versions... +SAMD_PACKAGE="samd-1.8.6" +CMSIS_PACKAGE="CMSIS-4.5.0" +CMSIS_ATMEL_PACKAGE="CMSIS-Atmel-1.2.0" + +if [ $OS == "mac" ]; then + TOOLCHAIN_PACKAGE="gcc-arm-none-eabi-7-2017-q4-major-mac" +else + TOOLCHAIN_PACKAGE="gcc-arm-none-eabi-7-2017-q4-major-linux" +fi + +ARDUINO_URL=https://downloads.arduino.cc +TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4 + +EXTRACT_COMMAND="tar -xjf" + +_pushd $DEPENDENCIES_FOLDER +if ! test -e $SAMD_PACKAGE +then + echo "Downloading SAMD packages..." + download $ARDUINO_URL/cores/$SAMD_PACKAGE.tar.bz2 $SAMD_PACKAGE.tar.bz2 + download $ARDUINO_URL/$CMSIS_PACKAGE.tar.bz2 $CMSIS_PACKAGE.tar.bz2 + download $ARDUINO_URL/$CMSIS_ATMEL_PACKAGE.tar.bz2 $CMSIS_ATMEL_PACKAGE.tar.bz2 + download $TOOLCHAIN_URL/$TOOLCHAIN_PACKAGE.tar.bz2 $TOOLCHAIN_PACKAGE.tar.bz2 +fi + +if ! test -d $SAMD_PACKAGE +then + echo "Installing packages to local folder..." + $EXTRACT_COMMAND $SAMD_PACKAGE.tar.bz2 + $EXTRACT_COMMAND $CMSIS_PACKAGE.tar.bz2 + $EXTRACT_COMMAND $CMSIS_ATMEL_PACKAGE.tar.bz2 + $EXTRACT_COMMAND $TOOLCHAIN_PACKAGE.tar.bz2 + echo "SAMD support installed" +fi + +_popd + +echo +echo "${bldgreen}SAMD dependencies installed.$txtrst" diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh index fd05c30..ba75fe4 100755 --- a/tests/script/runtests.sh +++ b/tests/script/runtests.sh @@ -7,7 +7,7 @@ failures=() # These examples cannot be tested easily at the moment as they require # alternate cores. The MakefileExample doesn't actually contain any source code # to compile. -NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkOpenCR BlinkTeensy BlinkNetworkRPi BlinkInAVRC MZeroBlink ZeroBlink DueBlink) +NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkOpenCR BlinkTeensy BlinkNetworkRPi BlinkInAVRC DueBlink) for dir in $TESTS_DIR/*/ do From 185a1e9e3527794a49451915009fb48d9e678080 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Thu, 6 Aug 2020 12:38:03 +0200 Subject: [PATCH 11/13] document GREP_CMD --- Common.mk | 12 ++++++------ Sam.mk | 2 +- arduino-mk-vars.md | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Common.mk b/Common.mk index 65dc126..d111336 100644 --- a/Common.mk +++ b/Common.mk @@ -8,8 +8,8 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # result = $(call READ_BOARD_TXT, 'boardname', 'parameter') PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ then \ - $(GREP) -Ev '^\#' $(BOARDS_TXT) | \ - $(GREP) -E "^[ \t]*$(1).$(2)=" | \ + $(GREP_CMD) -Ev '^\#' $(BOARDS_TXT) | \ + $(GREP_CMD) -E "^[ \t]*$(1).$(2)=" | \ cut -d = -f 2- | \ cut -d : -f 2; \ fi) @@ -48,20 +48,20 @@ $(call arduino_output,$(call ardmk_include) Configuration:) ifeq ($(OS),Windows_NT) CURRENT_OS = WINDOWS - GREP := grep + GREP_CMD := grep else UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) CURRENT_OS = LINUX - GREP := grep + GREP_CMD := grep endif ifeq ($(UNAME_S),Darwin) CURRENT_OS = MAC ifeq (, $(shell which ggrep)) echo $(info Using macOS BSD grep, please install GNU grep to avoid warnings) - GREP := grep + GREP_CMD := grep else - GREP := ggrep + GREP_CMD := ggrep endif endif endif diff --git a/Sam.mk b/Sam.mk index 2aa3078..cc588a1 100644 --- a/Sam.mk +++ b/Sam.mk @@ -414,7 +414,7 @@ CFLAGS_STD += -std=gnu11 CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)' # Get extra define flags from boards.txt -EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP) -oE '(-D)\w+') +EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP_CMD) -oE '(-D)\w+') # Strip only defines from extra flags as boards file appends user {build.usb} CPPFLAGS += $(EXFLAGS) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index e0b8618..746066b 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -150,6 +150,22 @@ PYTHON_CMD = /usr/bin/python3 ---- +### GREP_CMD + +**Description:** + +Path to GNU grep binary. Only added for macOS, which has BSD grep by default but results in some parsing warnings. macOS users should install GNU grep using Homebrew. + +**Example:** + +```Makefile +GREP_CMD = /bin/grep +``` + +**Requirement:** *Optional* + +---- + ## Arduino IDE variables ### ARDUINO_DIR From bf319c49b7f7ff17e073422a3ba06a701e12f590 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Thu, 6 Aug 2020 19:21:23 +0200 Subject: [PATCH 12/13] platform neutral examples and manual cherry-pick merge of https://github.com/alissa-huskey/Arduino-Makefile/tree/test_fixes --- .travis.yml | 6 +- Common.mk | 18 +++--- Sam.mk | 2 +- examples/ATtinyBlink/Makefile | 2 +- examples/AnalogInOutSerial/Makefile | 2 +- examples/Blink/Makefile | 2 +- examples/Blink3rdPartyLib/Makefile | 2 +- examples/Blink3rdPartyLib/Toggle/Makefile | 2 +- examples/BlinkChipKIT/Makefile | 2 +- examples/BlinkInAVRC/Makefile | 2 +- examples/BlinkNetworkRPi/Makefile | 2 +- examples/BlinkOpenCM/Makefile | 2 +- examples/BlinkOpenCR/Makefile | 2 +- examples/BlinkTeensy/Makefile | 2 +- examples/BlinkWithoutDelay/Makefile | 2 +- examples/DueBlink/Makefile | 2 +- examples/Fade/Makefile | 2 +- examples/HelloWorld/Makefile | 2 +- examples/MZeroBlink/Makefile | 2 +- examples/SerialPrint/Makefile | 2 +- examples/TinySoftWareSerial/Makefile | 2 +- examples/WebServer/Makefile | 2 +- examples/ZeroBlink/Makefile | 2 +- examples/master_reader/Makefile | 2 +- examples/toneMelody/Makefile | 2 +- tests/script/bootstrap/common.sh | 2 - tests/script/runtests.sh | 69 +++++++++++++++++------ 27 files changed, 90 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index dce5451..a8e0a66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ -sudo: required +os: linux +dist: xenial language: c compiler: - gcc @@ -9,3 +10,6 @@ addons: packages: - "python3" - "python3-pip" +env: + global: + - ARDMK_DIR=$TRAVIS_BUILD_DIR diff --git a/Common.mk b/Common.mk index d111336..501f582 100644 --- a/Common.mk +++ b/Common.mk @@ -48,20 +48,20 @@ $(call arduino_output,$(call ardmk_include) Configuration:) ifeq ($(OS),Windows_NT) CURRENT_OS = WINDOWS - GREP_CMD := grep + GREP_CMD = grep else UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) CURRENT_OS = LINUX - GREP_CMD := grep + GREP_CMD = grep endif ifeq ($(UNAME_S),Darwin) CURRENT_OS = MAC ifeq (, $(shell which ggrep)) echo $(info Using macOS BSD grep, please install GNU grep to avoid warnings) - GREP_CMD := grep + GREP_CMD = grep else - GREP_CMD := ggrep + GREP_CMD = ggrep endif endif endif @@ -73,14 +73,18 @@ $(call show_config_variable,CURRENT_OS,[AUTODETECTED]) ifneq ($(TEST),) DEPENDENCIES_DIR = /var/tmp/Arduino-Makefile-testing-dependencies - DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_DIR)/mpide-0023-linux64-20130817-test + DEPENDENCIES_MPIDE_DIR := $(shell find $(DEPENDENCIES_DIR) -name 'mpide-0023-*' -type d -exec ls -dt {} + | head -n 1) + ifeq ($(MPIDE_DIR),) MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR) endif ifndef ARDUINO_IDE_DIR - ARDUINO_IDE_DIR := $(shell basename $(basename $(basename $(lastword $(wildcard $(DEPENDENCIES_DIR)/arduino*))))) - # ARDUINO_IDE_DIR := arduino + ifeq ($(CURRENT_OS),MAC) + ARDUINO_IDE_DIR = Arduino.app/Contents/Resources/Java + else + ARDUINO_IDE_DIR := $(shell basename $(basename $(basename $(lastword $(wildcard $(DEPENDENCIES_DIR)/arduino*))))) + endif endif DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/$(ARDUINO_IDE_DIR) ifeq ($(ARDUINO_DIR),) diff --git a/Sam.mk b/Sam.mk index cc588a1..2e19730 100644 --- a/Sam.mk +++ b/Sam.mk @@ -38,7 +38,7 @@ ifneq ($(TEST),) ALTERNATE_CORE_PATH = $(DEPENDENCIES_DIR)/samd CMSIS_DIR = $(DEPENDENCIES_DIR)/CMSIS/CMSIS CMSIS_ATMEL_DIR = $(DEPENDENCIES_DIR)/CMSIS-Atmel/CMSIS - ARM_TOOLS_DIR = $(basename $(basename $(firstword $(wildcard $(DEPENDENCIES_DIR)/gcc-arm-none-eabi*)))) + ARM_TOOLS_DIR := $(basename $(basename $(firstword $(wildcard $(DEPENDENCIES_DIR)/gcc-arm-none-eabi*)))) endif ifndef ARDUINO_PACKAGE_DIR diff --git a/examples/ATtinyBlink/Makefile b/examples/ATtinyBlink/Makefile index f73d7a0..76327a8 100644 --- a/examples/ATtinyBlink/Makefile +++ b/examples/ATtinyBlink/Makefile @@ -54,6 +54,6 @@ BOARD_TAG = attiny85 # ------------------------------------------------------------------ # # Path to the Arduino Makefile -include /usr/share/arduino/Arduino.mk +include $(ARDMK_DIR)/Arduino.mk # !!! Important. You have to use 'make ispload' when using an ISP. diff --git a/examples/AnalogInOutSerial/Makefile b/examples/AnalogInOutSerial/Makefile index 3dea6c0..5db75de 100644 --- a/examples/AnalogInOutSerial/Makefile +++ b/examples/AnalogInOutSerial/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/Blink/Makefile b/examples/Blink/Makefile index 7cb3881..51a66bc 100644 --- a/examples/Blink/Makefile +++ b/examples/Blink/Makefile @@ -1,7 +1,7 @@ # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile BOARD_TAG = uno -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/Blink3rdPartyLib/Makefile b/examples/Blink3rdPartyLib/Makefile index f473dbd..4658f50 100644 --- a/examples/Blink3rdPartyLib/Makefile +++ b/examples/Blink3rdPartyLib/Makefile @@ -15,7 +15,7 @@ TOGGLE_ARCHIVE = build-$(BOARD_TAG)/libtoggle.a CXXFLAGS += -IToggle OTHER_OBJS = Toggle/$(TOGGLE_ARCHIVE) -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk Toggle/$(TOGGLE_ARCHIVE): $(MAKE) -C Toggle $(TOGGLE_ARCHIVE) diff --git a/examples/Blink3rdPartyLib/Toggle/Makefile b/examples/Blink3rdPartyLib/Toggle/Makefile index a6234f6..d733171 100644 --- a/examples/Blink3rdPartyLib/Toggle/Makefile +++ b/examples/Blink3rdPartyLib/Toggle/Makefile @@ -8,7 +8,7 @@ # and archived into the build-$(BOARD_TAG)/libtoggle.a target. include ../board.mk -include ../../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk build-$(BOARD_TAG)/libtoggle.a: $(LOCAL_OBJS) $(AR) rcs $@ $(LOCAL_OBJS) diff --git a/examples/BlinkChipKIT/Makefile b/examples/BlinkChipKIT/Makefile index 87a9f7d..440db29 100644 --- a/examples/BlinkChipKIT/Makefile +++ b/examples/BlinkChipKIT/Makefile @@ -1,5 +1,5 @@ BOARD_TAG = mega_pic32 ARDUINO_LIBS = -include ../../chipKIT.mk +include $(ARDMK_DIR)/chipKIT.mk diff --git a/examples/BlinkInAVRC/Makefile b/examples/BlinkInAVRC/Makefile index a4cd2e4..04049bb 100644 --- a/examples/BlinkInAVRC/Makefile +++ b/examples/BlinkInAVRC/Makefile @@ -11,6 +11,6 @@ F_CPU = 8000000L ISP_PROG = stk500v1 AVRDUDE_ISP_BAUDRATE = 19200 -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk # !!! Important. You have to use make ispload to upload when using ISP programmer diff --git a/examples/BlinkNetworkRPi/Makefile b/examples/BlinkNetworkRPi/Makefile index 15e565e..c119b53 100644 --- a/examples/BlinkNetworkRPi/Makefile +++ b/examples/BlinkNetworkRPi/Makefile @@ -16,7 +16,7 @@ AVRDUDE_CONF=/usr/local/etc/avrdude.conf FORCE_MONITOR_PORT=true MONITOR_PORT=/dev/spidev0.0 -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk # Additional rules to use a remote Raspberry Pi programmer diff --git a/examples/BlinkOpenCM/Makefile b/examples/BlinkOpenCM/Makefile index 0f7b285..75f52fb 100644 --- a/examples/BlinkOpenCM/Makefile +++ b/examples/BlinkOpenCM/Makefile @@ -4,4 +4,4 @@ ARDUINO_LIBS = #MONITOR_PORT = /dev/ttyACM0 #OPENCMIDE_DIR = /where/you/installed/robotis_opencm -include ../../OpenCM.mk +include $(ARDMK_DIR)/OpenCM.mk diff --git a/examples/BlinkOpenCR/Makefile b/examples/BlinkOpenCR/Makefile index d4422f4..18bfa8d 100644 --- a/examples/BlinkOpenCR/Makefile +++ b/examples/BlinkOpenCR/Makefile @@ -5,4 +5,4 @@ ARDUINO_LIBS = #MONITOR_PORT = /dev/ttyACM0 -include ../../OpenCR.mk +include $(ARDMK_DIR)/OpenCR.mk diff --git a/examples/BlinkTeensy/Makefile b/examples/BlinkTeensy/Makefile index 1d59ef2..be58660 100644 --- a/examples/BlinkTeensy/Makefile +++ b/examples/BlinkTeensy/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = teensy31 ARDUINO_LIBS = -include ../../Teensy.mk +include $(ARDMK_DIR)/Teensy.mk diff --git a/examples/BlinkWithoutDelay/Makefile b/examples/BlinkWithoutDelay/Makefile index 3dea6c0..5db75de 100644 --- a/examples/BlinkWithoutDelay/Makefile +++ b/examples/BlinkWithoutDelay/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/DueBlink/Makefile b/examples/DueBlink/Makefile index 8a7ad6e..a11248c 100644 --- a/examples/DueBlink/Makefile +++ b/examples/DueBlink/Makefile @@ -16,4 +16,4 @@ ARCHITECTURE = sam # Windows #ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" -include ../../Sam.mk +include $(ARDMK_DIR)/Sam.mk diff --git a/examples/Fade/Makefile b/examples/Fade/Makefile index 3dea6c0..5db75de 100644 --- a/examples/Fade/Makefile +++ b/examples/Fade/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/HelloWorld/Makefile b/examples/HelloWorld/Makefile index fb94fdd..2730c53 100644 --- a/examples/HelloWorld/Makefile +++ b/examples/HelloWorld/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = LiquidCrystal -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/MZeroBlink/Makefile b/examples/MZeroBlink/Makefile index 29cb90b..4771b9c 100644 --- a/examples/MZeroBlink/Makefile +++ b/examples/MZeroBlink/Makefile @@ -21,4 +21,4 @@ BOARD_TAG = mzero_pro_bl_dbg # Windows # ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" -include ../../Sam.mk +include $(ARDMK_DIR)/Sam.mk diff --git a/examples/SerialPrint/Makefile b/examples/SerialPrint/Makefile index f9d5cf4..5050232 100644 --- a/examples/SerialPrint/Makefile +++ b/examples/SerialPrint/Makefile @@ -2,4 +2,4 @@ BOARD_TAG = uno -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/TinySoftWareSerial/Makefile b/examples/TinySoftWareSerial/Makefile index ffe3afc..7c60f3a 100644 --- a/examples/TinySoftWareSerial/Makefile +++ b/examples/TinySoftWareSerial/Makefile @@ -17,4 +17,4 @@ F_CPU = 16000000L ARDUINO_LIBS = SoftwareSerial -include /usr/share/arduino/Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/WebServer/Makefile b/examples/WebServer/Makefile index 51b9ac2..83fbd4e 100644 --- a/examples/WebServer/Makefile +++ b/examples/WebServer/Makefile @@ -3,4 +3,4 @@ BOARD_TAG = uno ARDUINO_LIBS = Ethernet SPI -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/ZeroBlink/Makefile b/examples/ZeroBlink/Makefile index 60c8435..d0c30fb 100644 --- a/examples/ZeroBlink/Makefile +++ b/examples/ZeroBlink/Makefile @@ -27,4 +27,4 @@ BOARD_TAG = arduino_zero_native # Windows #ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" -include ../../Sam.mk +include $(ARDMK_DIR)/Sam.mk diff --git a/examples/master_reader/Makefile b/examples/master_reader/Makefile index 3030deb..c650a04 100644 --- a/examples/master_reader/Makefile +++ b/examples/master_reader/Makefile @@ -3,4 +3,4 @@ BOARD_TAG = uno ARDUINO_LIBS = Wire -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/examples/toneMelody/Makefile b/examples/toneMelody/Makefile index 3dea6c0..5db75de 100644 --- a/examples/toneMelody/Makefile +++ b/examples/toneMelody/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include ../../Arduino.mk +include $(ARDMK_DIR)/Arduino.mk diff --git a/tests/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh index 221dd21..2b879b8 100644 --- a/tests/script/bootstrap/common.sh +++ b/tests/script/bootstrap/common.sh @@ -168,8 +168,6 @@ if [ -z $COMMON_SOURCED ]; then if ! command -v pip3 >/dev/null 2>&1; then echo "Installing Pip..." _install "python3-pip" - - $SUDO_CMD easy_install3 pip3 fi PIP_SUDO_CMD= diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh index ba75fe4..84fa4c5 100755 --- a/tests/script/runtests.sh +++ b/tests/script/runtests.sh @@ -1,9 +1,41 @@ #!/usr/bin/env bash +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" TESTS_DIR=examples +export ARDMK_DIR="${ARDMK_DIR:-$SCRIPTS_DIR/../..}" failures=() +if [[ "$1" == "-q" ]]; then + QUIET=1 +fi + +runtest() { + if [[ $QUIET ]]; then + make $* TEST=1 > /dev/null 2>&1 + else + output=`make $* TEST=1` + fi +} + +run() { + if [[ $QUIET ]]; then + "$@" > /dev/null 2>&1 + else + "$@" + fi +} + +info() { + if [[ $QUIET ]]; then + return + fi + + echo "$@" +} + +run pushd $SCRIPTS_DIR/../.. + # These examples cannot be tested easily at the moment as they require # alternate cores. The MakefileExample doesn't actually contain any source code # to compile. @@ -22,46 +54,47 @@ do done if ! $example_is_testable; then - echo "Skipping non-testable example $example..." + info "Skipping non-testable example $example..." continue fi - pushd $dir - echo "Compiling $example..." - make_output=`make clean TEST=1` - make_output=`make TEST=1` + run pushd $dir + info "Compiling $example..." + runtest clean + runtest + if [[ $? -ne 0 ]]; then failures+=("$example") - echo "Example $example failed" + info "Example $example failed" fi - make_output=`make disasm TEST=1` + runtest disasm if [[ $? -ne 0 ]]; then failures+=("$example disasm") - echo "Example $example disasm failed" + info "Example $example disasm failed" fi - make_output=`make generate_assembly TEST=1` + runtest generate_assembly if [[ $? -ne 0 ]]; then failures+=("$example generate_assembly") - echo "Example $example generate_assembly failed" + info "Example $example generate_assembly failed" fi - make_output=`make symbol_sizes TEST=1` + runtest symbol_sizes if [[ $? -ne 0 ]]; then failures+=("$example symbol_sizes") - echo "Example $example symbol_sizes failed" + info "Example $example symbol_sizes failed" fi - popd -done - -for failure in "${failures[@]}"; do - echo "Example $failure failed" + run popd done if [[ ${#failures[@]} -eq 0 ]]; then echo "All tests passed." else - exit 1 + for failure in "${failures[@]}"; do + echo "Example $failure failed" + done + + exit 1 fi From 2329d19b97a3a3a115b6a414a6235f5d398bae2b Mon Sep 17 00:00:00 2001 From: John Whittington Date: Mon, 10 Aug 2020 16:37:32 +0200 Subject: [PATCH 13/13] remove #630 --- examples/ATtinyBlink/Makefile | 2 +- examples/AnalogInOutSerial/Makefile | 2 +- examples/Blink/Makefile | 2 +- examples/Blink3rdPartyLib/Makefile | 2 +- examples/Blink3rdPartyLib/Toggle/Makefile | 2 +- examples/BlinkChipKIT/Makefile | 2 +- examples/BlinkInAVRC/Makefile | 2 +- examples/BlinkNetworkRPi/Makefile | 2 +- examples/BlinkOpenCM/Makefile | 2 +- examples/BlinkOpenCR/Makefile | 2 +- examples/BlinkTeensy/Makefile | 2 +- examples/BlinkWithoutDelay/Makefile | 2 +- examples/DueBlink/Makefile | 2 +- examples/Fade/Makefile | 2 +- examples/HelloWorld/Makefile | 2 +- examples/MZeroBlink/Makefile | 2 +- examples/SerialPrint/Makefile | 2 +- examples/TinySoftWareSerial/Makefile | 2 +- examples/WebServer/Makefile | 2 +- examples/ZeroBlink/Makefile | 2 +- examples/master_reader/Makefile | 2 +- examples/toneMelody/Makefile | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/ATtinyBlink/Makefile b/examples/ATtinyBlink/Makefile index 76327a8..f73d7a0 100644 --- a/examples/ATtinyBlink/Makefile +++ b/examples/ATtinyBlink/Makefile @@ -54,6 +54,6 @@ BOARD_TAG = attiny85 # ------------------------------------------------------------------ # # Path to the Arduino Makefile -include $(ARDMK_DIR)/Arduino.mk +include /usr/share/arduino/Arduino.mk # !!! Important. You have to use 'make ispload' when using an ISP. diff --git a/examples/AnalogInOutSerial/Makefile b/examples/AnalogInOutSerial/Makefile index 5db75de..3dea6c0 100644 --- a/examples/AnalogInOutSerial/Makefile +++ b/examples/AnalogInOutSerial/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/Blink/Makefile b/examples/Blink/Makefile index 51a66bc..7cb3881 100644 --- a/examples/Blink/Makefile +++ b/examples/Blink/Makefile @@ -1,7 +1,7 @@ # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile BOARD_TAG = uno -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/Blink3rdPartyLib/Makefile b/examples/Blink3rdPartyLib/Makefile index 4658f50..f473dbd 100644 --- a/examples/Blink3rdPartyLib/Makefile +++ b/examples/Blink3rdPartyLib/Makefile @@ -15,7 +15,7 @@ TOGGLE_ARCHIVE = build-$(BOARD_TAG)/libtoggle.a CXXFLAGS += -IToggle OTHER_OBJS = Toggle/$(TOGGLE_ARCHIVE) -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk Toggle/$(TOGGLE_ARCHIVE): $(MAKE) -C Toggle $(TOGGLE_ARCHIVE) diff --git a/examples/Blink3rdPartyLib/Toggle/Makefile b/examples/Blink3rdPartyLib/Toggle/Makefile index d733171..a6234f6 100644 --- a/examples/Blink3rdPartyLib/Toggle/Makefile +++ b/examples/Blink3rdPartyLib/Toggle/Makefile @@ -8,7 +8,7 @@ # and archived into the build-$(BOARD_TAG)/libtoggle.a target. include ../board.mk -include $(ARDMK_DIR)/Arduino.mk +include ../../../Arduino.mk build-$(BOARD_TAG)/libtoggle.a: $(LOCAL_OBJS) $(AR) rcs $@ $(LOCAL_OBJS) diff --git a/examples/BlinkChipKIT/Makefile b/examples/BlinkChipKIT/Makefile index 440db29..87a9f7d 100644 --- a/examples/BlinkChipKIT/Makefile +++ b/examples/BlinkChipKIT/Makefile @@ -1,5 +1,5 @@ BOARD_TAG = mega_pic32 ARDUINO_LIBS = -include $(ARDMK_DIR)/chipKIT.mk +include ../../chipKIT.mk diff --git a/examples/BlinkInAVRC/Makefile b/examples/BlinkInAVRC/Makefile index 04049bb..a4cd2e4 100644 --- a/examples/BlinkInAVRC/Makefile +++ b/examples/BlinkInAVRC/Makefile @@ -11,6 +11,6 @@ F_CPU = 8000000L ISP_PROG = stk500v1 AVRDUDE_ISP_BAUDRATE = 19200 -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk # !!! Important. You have to use make ispload to upload when using ISP programmer diff --git a/examples/BlinkNetworkRPi/Makefile b/examples/BlinkNetworkRPi/Makefile index c119b53..15e565e 100644 --- a/examples/BlinkNetworkRPi/Makefile +++ b/examples/BlinkNetworkRPi/Makefile @@ -16,7 +16,7 @@ AVRDUDE_CONF=/usr/local/etc/avrdude.conf FORCE_MONITOR_PORT=true MONITOR_PORT=/dev/spidev0.0 -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk # Additional rules to use a remote Raspberry Pi programmer diff --git a/examples/BlinkOpenCM/Makefile b/examples/BlinkOpenCM/Makefile index 75f52fb..0f7b285 100644 --- a/examples/BlinkOpenCM/Makefile +++ b/examples/BlinkOpenCM/Makefile @@ -4,4 +4,4 @@ ARDUINO_LIBS = #MONITOR_PORT = /dev/ttyACM0 #OPENCMIDE_DIR = /where/you/installed/robotis_opencm -include $(ARDMK_DIR)/OpenCM.mk +include ../../OpenCM.mk diff --git a/examples/BlinkOpenCR/Makefile b/examples/BlinkOpenCR/Makefile index 18bfa8d..d4422f4 100644 --- a/examples/BlinkOpenCR/Makefile +++ b/examples/BlinkOpenCR/Makefile @@ -5,4 +5,4 @@ ARDUINO_LIBS = #MONITOR_PORT = /dev/ttyACM0 -include $(ARDMK_DIR)/OpenCR.mk +include ../../OpenCR.mk diff --git a/examples/BlinkTeensy/Makefile b/examples/BlinkTeensy/Makefile index be58660..1d59ef2 100644 --- a/examples/BlinkTeensy/Makefile +++ b/examples/BlinkTeensy/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = teensy31 ARDUINO_LIBS = -include $(ARDMK_DIR)/Teensy.mk +include ../../Teensy.mk diff --git a/examples/BlinkWithoutDelay/Makefile b/examples/BlinkWithoutDelay/Makefile index 5db75de..3dea6c0 100644 --- a/examples/BlinkWithoutDelay/Makefile +++ b/examples/BlinkWithoutDelay/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/DueBlink/Makefile b/examples/DueBlink/Makefile index a11248c..8a7ad6e 100644 --- a/examples/DueBlink/Makefile +++ b/examples/DueBlink/Makefile @@ -16,4 +16,4 @@ ARCHITECTURE = sam # Windows #ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" -include $(ARDMK_DIR)/Sam.mk +include ../../Sam.mk diff --git a/examples/Fade/Makefile b/examples/Fade/Makefile index 5db75de..3dea6c0 100644 --- a/examples/Fade/Makefile +++ b/examples/Fade/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/HelloWorld/Makefile b/examples/HelloWorld/Makefile index 2730c53..fb94fdd 100644 --- a/examples/HelloWorld/Makefile +++ b/examples/HelloWorld/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = LiquidCrystal -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/MZeroBlink/Makefile b/examples/MZeroBlink/Makefile index 4771b9c..29cb90b 100644 --- a/examples/MZeroBlink/Makefile +++ b/examples/MZeroBlink/Makefile @@ -21,4 +21,4 @@ BOARD_TAG = mzero_pro_bl_dbg # Windows # ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" -include $(ARDMK_DIR)/Sam.mk +include ../../Sam.mk diff --git a/examples/SerialPrint/Makefile b/examples/SerialPrint/Makefile index 5050232..f9d5cf4 100644 --- a/examples/SerialPrint/Makefile +++ b/examples/SerialPrint/Makefile @@ -2,4 +2,4 @@ BOARD_TAG = uno -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/TinySoftWareSerial/Makefile b/examples/TinySoftWareSerial/Makefile index 7c60f3a..ffe3afc 100644 --- a/examples/TinySoftWareSerial/Makefile +++ b/examples/TinySoftWareSerial/Makefile @@ -17,4 +17,4 @@ F_CPU = 16000000L ARDUINO_LIBS = SoftwareSerial -include $(ARDMK_DIR)/Arduino.mk +include /usr/share/arduino/Arduino.mk diff --git a/examples/WebServer/Makefile b/examples/WebServer/Makefile index 83fbd4e..51b9ac2 100644 --- a/examples/WebServer/Makefile +++ b/examples/WebServer/Makefile @@ -3,4 +3,4 @@ BOARD_TAG = uno ARDUINO_LIBS = Ethernet SPI -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/ZeroBlink/Makefile b/examples/ZeroBlink/Makefile index d0c30fb..60c8435 100644 --- a/examples/ZeroBlink/Makefile +++ b/examples/ZeroBlink/Makefile @@ -27,4 +27,4 @@ BOARD_TAG = arduino_zero_native # Windows #ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" -include $(ARDMK_DIR)/Sam.mk +include ../../Sam.mk diff --git a/examples/master_reader/Makefile b/examples/master_reader/Makefile index c650a04..3030deb 100644 --- a/examples/master_reader/Makefile +++ b/examples/master_reader/Makefile @@ -3,4 +3,4 @@ BOARD_TAG = uno ARDUINO_LIBS = Wire -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk diff --git a/examples/toneMelody/Makefile b/examples/toneMelody/Makefile index 5db75de..3dea6c0 100644 --- a/examples/toneMelody/Makefile +++ b/examples/toneMelody/Makefile @@ -1,4 +1,4 @@ BOARD_TAG = uno ARDUINO_LIBS = -include $(ARDMK_DIR)/Arduino.mk +include ../../Arduino.mk