Skip to content

Commit

Permalink
platform neutral examples and manual cherry-pick merge of https://git…
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Aug 6, 2020
1 parent 185a1e9 commit bf319c4
Show file tree
Hide file tree
Showing 27 changed files with 90 additions and 51 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
@@ -1,4 +1,5 @@
sudo: required
os: linux
dist: xenial
language: c
compiler:
- gcc
Expand All @@ -9,3 +10,6 @@ addons:
packages:
- "python3"
- "python3-pip"
env:
global:
- ARDMK_DIR=$TRAVIS_BUILD_DIR
18 changes: 11 additions & 7 deletions Common.mk
Expand Up @@ -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
Expand All @@ -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),)
Expand Down
2 changes: 1 addition & 1 deletion Sam.mk
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/ATtinyBlink/Makefile
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion examples/AnalogInOutSerial/Makefile
@@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion 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



Expand Down
2 changes: 1 addition & 1 deletion examples/Blink3rdPartyLib/Makefile
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/Blink3rdPartyLib/Toggle/Makefile
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion examples/BlinkChipKIT/Makefile
@@ -1,5 +1,5 @@
BOARD_TAG = mega_pic32
ARDUINO_LIBS =

include ../../chipKIT.mk
include $(ARDMK_DIR)/chipKIT.mk

2 changes: 1 addition & 1 deletion examples/BlinkInAVRC/Makefile
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/BlinkNetworkRPi/Makefile
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/BlinkOpenCM/Makefile
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/BlinkOpenCR/Makefile
Expand Up @@ -5,4 +5,4 @@ ARDUINO_LIBS =

#MONITOR_PORT = /dev/ttyACM0

include ../../OpenCR.mk
include $(ARDMK_DIR)/OpenCR.mk
2 changes: 1 addition & 1 deletion examples/BlinkTeensy/Makefile
@@ -1,4 +1,4 @@
BOARD_TAG = teensy31
ARDUINO_LIBS =

include ../../Teensy.mk
include $(ARDMK_DIR)/Teensy.mk
2 changes: 1 addition & 1 deletion examples/BlinkWithoutDelay/Makefile
@@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/DueBlink/Makefile
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/Fade/Makefile
@@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/HelloWorld/Makefile
@@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS = LiquidCrystal

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/MZeroBlink/Makefile
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/SerialPrint/Makefile
Expand Up @@ -2,4 +2,4 @@

BOARD_TAG = uno

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/TinySoftWareSerial/Makefile
Expand Up @@ -17,4 +17,4 @@ F_CPU = 16000000L

ARDUINO_LIBS = SoftwareSerial

include /usr/share/arduino/Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/WebServer/Makefile
Expand Up @@ -3,4 +3,4 @@
BOARD_TAG = uno
ARDUINO_LIBS = Ethernet SPI

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/ZeroBlink/Makefile
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/master_reader/Makefile
Expand Up @@ -3,4 +3,4 @@
BOARD_TAG = uno
ARDUINO_LIBS = Wire

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 1 addition & 1 deletion examples/toneMelody/Makefile
@@ -1,4 +1,4 @@
BOARD_TAG = uno
ARDUINO_LIBS =

include ../../Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
2 changes: 0 additions & 2 deletions tests/script/bootstrap/common.sh
Expand Up @@ -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=
Expand Down
69 changes: 51 additions & 18 deletions 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.
Expand All @@ -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

0 comments on commit bf319c4

Please sign in to comment.