Skip to content

Commit

Permalink
test 9, with flash and monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafFilies committed Oct 31, 2024
1 parent 36b73ae commit 6096717
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions tests/Unity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,46 @@ test: unity_corelibs flash
EXAMPLES= CANReceiver CANReceiverCallback CANSender CANLoopBack

clean:
-rm -rf build/*
-rm -rf build/*

arduino: clean
mkdir -p build
mkdir -p build
# copy library files (not needed for bundled libraries)
# cp -r src/* build
# find src -name '*.[hc]*' -a \( \! -name '*mtb*' \) -print -exec cp {} build \;
.PHONY: CANReceiver CANReceiverCallback CANSender CANLoopBack
CANReceiver: arduino
cp examples/CANReceiver/CANReceiver.ino build/build.ino
cp examples/CANReceiver/CANReceiver.ino build/build.ino

CANReceiverCallback: arduino
cp examples/CANReceiverCallback/CANReceiverCallback.ino build/build.ino
cp examples/CANReceiverCallback/CANReceiverCallback.ino build/build.ino

CANSender: arduino
cp examples/CANSender/CANSender.ino build/build.ino
cp examples/CANSender/CANSender.ino build/build.ino

CANLoopBack: arduino
cp examples/CANLoopBack/CANLoopBack.ino build/build.ino
cp examples/CANLoopBack/CANLoopBack.ino build/build.ino


# install Unity from https://www.throwtheswitch.org/unity or git
unity_corelibs: arduino
ifeq ($(UNITY_PATH),)
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
else
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \;
cp src/corelibs/Test_main.ino build/build.ino
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \;
cp src/corelibs/Test_main.ino build/build.ino
endif

unity_corelibs_can: arduino
ifeq ($(UNITY_PATH),)
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
else
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src/corelibs/CAN -name '*.[hc]*' -exec \cp {} build \;
find src/utils -name '*.[hc]*' -exec \cp {} build \;
find src -maxdepth 1 -name '*.[hc]*' -exec \cp {} build \;
cp src/Test_main.ino build/build.ino
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src/corelibs/CAN -name '*.[hc]*' -exec \cp {} build \;
find src/utils -name '*.[hc]*' -exec \cp {} build \;
find src -maxdepth 1 -name '*.[hc]*' -exec \cp {} build \;
cp src/Test_main.ino build/build.ino
endif


Expand All @@ -79,55 +79,55 @@ endif
# download arduino-cli.exe from : https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip
compile:
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
else
# CAUTION : only use '=' when assigning values to vars, not '+='
arduino-cli.exe compile \
--clean \
--log \
--warnings all \
--fqbn $(FQBN) \
--build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \
--build-property compiler.cpp.extra_flags="$(TESTS)" \
--export-binaries \
build
arduino-cli.exe compile \
--clean \
--log \
--warnings all \
--fqbn $(FQBN) \
--build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \
--build-property compiler.cpp.extra_flags="$(TESTS)" \
--export-binaries \
build
endif


compileLTO:
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
else
# compiler.c.extra_flags : switch to -std=c23 whenever XMCLib is conforming; currently neither c99 nor c11 work !
# CAUTION : only use '=' when assigning values to vars, not '+='
arduino-cli.exe compile \
--clean \
--log \
--warnings all \
--fqbn $(FQBN) \
--build-property compiler.c.extra_flags="\"-DUNITY_INCLUDE_CONFIG_H=1\" -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c20 " \
--build-property compiler.cpp.extra_flags="$(TESTS) -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c++20 " \
--build-property compiler.ar.cmd=arm-none-eabi-gcc-ar \
--build-property compiler.libraries.ldflags=-lstdc++ \
--build-property compiler.arm.cmsis.path="-isystem{compiler.xmclib_include.path}/XMCLib/inc -isystem{compiler.dsp_include.path} -isystem{compiler.nn_include.path} -isystem{compiler.cmsis_include.path} -isystem{compiler.xmclib_include.path}/LIBS -isystem{build.variant.path} -isystem{build.variant.config_path}" \
--build-property compiler.usb.path="-isystem{runtime.platform.path}/cores/usblib -isystem{runtime.platform.path}/cores/usblib/Common -isystem{runtime.platform.path}/cores/usblib/Class -isystem{runtime.platform.path}/cores/usblib/Class/Common -isystem{runtime.platform.path}/cores/usblib/Class/Device -isystem{runtime.platform.path}/cores/usblib/Core -isystem{runtime.platform.path}/cores/usblib/Core/XMC4000" \
--export-binaries \
build
arduino-cli.exe compile \
--clean \
--log \
--warnings all \
--fqbn $(FQBN) \
--build-property compiler.c.extra_flags="\"-DUNITY_INCLUDE_CONFIG_H=1\" -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c20 " \
--build-property compiler.cpp.extra_flags="$(TESTS) -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c++20 " \
--build-property compiler.ar.cmd=arm-none-eabi-gcc-ar \
--build-property compiler.libraries.ldflags=-lstdc++ \
--build-property compiler.arm.cmsis.path="-isystem{compiler.xmclib_include.path}/XMCLib/inc -isystem{compiler.dsp_include.path} -isystem{compiler.nn_include.path} -isystem{compiler.cmsis_include.path} -isystem{compiler.xmclib_include.path}/LIBS -isystem{build.variant.path} -isystem{build.variant.config_path}" \
--build-property compiler.usb.path="-isystem{runtime.platform.path}/cores/usblib -isystem{runtime.platform.path}/cores/usblib/Common -isystem{runtime.platform.path}/cores/usblib/Class -isystem{runtime.platform.path}/cores/usblib/Class/Common -isystem{runtime.platform.path}/cores/usblib/Class/Device -isystem{runtime.platform.path}/cores/usblib/Core -isystem{runtime.platform.path}/cores/usblib/Core/XMC4000" \
--export-binaries \
build
endif


upload: compile
ifeq ($(PORT),)
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
endif
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
else
arduino-cli.exe upload \
-p $(PORT) \
--fqbn $(FQBN) \
--verbose \
build
arduino-cli.exe upload \
-p $(PORT) \
--fqbn $(FQBN) \
--verbose \
build
endif


Expand All @@ -136,14 +136,14 @@ flash: compile upload

monitor:
ifeq ($(PORT),)
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
endif
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
else
arduino-cli.exe monitor \
-c baudrate=$(BAUD_RATE) \
-p $(PORT) \
--fqbn $(FQBN)
arduino-cli.exe monitor \
-c baudrate=$(BAUD_RATE) \
-p $(PORT) \
--fqbn $(FQBN)
endif

0 comments on commit 6096717

Please sign in to comment.