2023-04-01 07:16:48 +00:00
SCRIPTS_DIR := buildroot/share/scripts
2023-03-29 04:23:27 +00:00
CONTAINER_RT_BIN := docker
CONTAINER_RT_OPTS := --rm -v $( PWD) :/code -v platformio-cache:/root/.platformio
CONTAINER_IMAGE := marlin-dev
2024-04-21 06:40:26 +00:00
UNIT_TEST_CONFIG ?= default
2023-03-29 04:23:27 +00:00
2020-11-18 02:04:28 +00:00
help :
@echo "Tasks for local development:"
2024-01-14 00:30:43 +00:00
@echo "make marlin : Build marlin for the configured board"
2024-04-23 02:10:35 +00:00
@echo "make format-pins -j : Reformat all pins files (-j for parallel execution)"
@echo "make validate-pins -j : Validate all pins files, fails if any require reformatting"
2024-01-14 00:30:43 +00:00
@echo "make tests-single-ci : Run a single test from inside the CI"
@echo "make tests-single-local : Run a single test locally"
@echo "make tests-single-local-docker : Run a single test locally, using docker"
@echo "make tests-all-local : Run all tests locally"
@echo "make tests-all-local-docker : Run all tests locally, using docker"
2024-04-21 06:40:26 +00:00
@echo "make unit-test-single-local : Run unit tests for a single config locally"
@echo "make unit-test-single-local-docker : Run unit tests for a single config locally, using docker"
2024-04-13 19:06:08 +00:00
@echo "make unit-test-all-local : Run all code tests locally"
2024-04-21 06:40:26 +00:00
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker"
@echo "make setup-local-docker : Setup local docker using buildx"
2020-11-18 02:04:28 +00:00
@echo ""
@echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@echo " test. If you set it to ALL it will run all "
@echo " tests, but some of them are broken: use "
@echo " tests-all-* instead to run only the ones that "
@echo " run on GitHub CI"
@echo " ONLY_TEST Limit tests to only those that contain this, or"
@echo " the index of the test (1-based)"
2024-04-21 06:40:26 +00:00
@echo " UNIT_TEST_CONFIG Set the name of the config from the test folder, without"
@echo " the leading number. Default is 'default'" . Used with the
@echo " unit-test-single-* tasks"
2020-11-18 02:04:28 +00:00
@echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
@echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
2024-01-14 00:30:43 +00:00
marlin :
./buildroot/bin/mftest -a
.PHONY : marlin
2020-11-18 02:04:28 +00:00
tests-single-ci :
export GIT_RESET_HARD = true
2023-04-26 18:51:33 +00:00
$( MAKE) tests-single-local TEST_TARGET = $( TEST_TARGET) PLATFORMIO_BUILD_FLAGS = -DGITHUB_ACTION
2020-11-18 02:04:28 +00:00
tests-single-local :
@if ! test -n " $( TEST_TARGET) " ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
2022-10-14 23:59:31 +00:00
export PATH = " ./buildroot/bin/:./buildroot/tests/: ${ PATH } " \
2020-11-18 02:04:28 +00:00
&& export VERBOSE_PLATFORMIO = $( VERBOSE_PLATFORMIO) \
&& run_tests . $( TEST_TARGET) " $( ONLY_TEST) "
tests-single-local-docker :
@if ! test -n " $( TEST_TARGET) " ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
2023-03-29 04:23:27 +00:00
@if ! $( CONTAINER_RT_BIN) images -q $( CONTAINER_IMAGE) > /dev/null ; then $( MAKE) setup-local-docker ; fi
2024-04-13 19:06:08 +00:00
$( CONTAINER_RT_BIN) run $( CONTAINER_RT_OPTS) $( CONTAINER_IMAGE) make tests-single-local TEST_TARGET = $( TEST_TARGET) VERBOSE_PLATFORMIO = $( VERBOSE_PLATFORMIO) GIT_RESET_HARD = $( GIT_RESET_HARD) ONLY_TEST = " $( ONLY_TEST) "
2020-11-18 02:04:28 +00:00
tests-all-local :
2024-05-02 13:36:24 +00:00
@python -c "import yaml" 2>/dev/null || ( echo 'pyyaml module is not installed. Install it with "python -m pip install pyyaml"' && exit 1)
2022-10-14 23:59:31 +00:00
export PATH = " ./buildroot/bin/:./buildroot/tests/: ${ PATH } " \
2020-11-18 02:04:28 +00:00
&& export VERBOSE_PLATFORMIO = $( VERBOSE_PLATFORMIO) \
2024-05-02 13:36:24 +00:00
&& for TEST_TARGET in $$ ( python $( SCRIPTS_DIR) /get_test_targets.py) ; do \
if [ " $$ TEST_TARGET " = "linux_native" ] && [ " $$ (uname) " = "Darwin" ] ; then \
echo " Skipping tests for $$ TEST_TARGET on macOS " ; \
continue ; \
fi ; \
echo " Running tests for $$ TEST_TARGET " ; \
run_tests . $$ TEST_TARGET || exit 1 ; \
sleep 5; \
done
2020-11-18 02:04:28 +00:00
tests-all-local-docker :
2023-03-29 04:23:27 +00:00
@if ! $( CONTAINER_RT_BIN) images -q $( CONTAINER_IMAGE) > /dev/null ; then $( MAKE) setup-local-docker ; fi
2024-04-13 19:06:08 +00:00
$( CONTAINER_RT_BIN) run $( CONTAINER_RT_OPTS) $( CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO = $( VERBOSE_PLATFORMIO) GIT_RESET_HARD = $( GIT_RESET_HARD)
2024-04-21 06:40:26 +00:00
unit-test-single-local :
platformio run -t marlin_$( UNIT_TEST_CONFIG) -e linux_native_test
2024-04-13 19:06:08 +00:00
2024-04-21 06:40:26 +00:00
unit-test-single-local-docker :
@if ! $( CONTAINER_RT_BIN) images -q $( CONTAINER_IMAGE) > /dev/null ; then $( MAKE) setup-local-docker ; fi
$( CONTAINER_RT_BIN) run $( CONTAINER_RT_OPTS) $( CONTAINER_IMAGE) make unit-test-single-local UNIT_TEST_CONFIG = $( UNIT_TEST_CONFIG)
2024-04-13 19:06:08 +00:00
unit-test-all-local :
platformio run -t test-marlin -e linux_native_test
unit-test-all-local-docker :
@if ! $( CONTAINER_RT_BIN) images -q $( CONTAINER_IMAGE) > /dev/null ; then $( MAKE) setup-local-docker ; fi
$( CONTAINER_RT_BIN) run $( CONTAINER_RT_OPTS) $( CONTAINER_IMAGE) make unit-test-all-local
2020-11-18 02:04:28 +00:00
setup-local-docker :
2024-04-13 19:06:08 +00:00
$( CONTAINER_RT_BIN) buildx build -t $( CONTAINER_IMAGE) -f docker/Dockerfile .
2023-11-21 09:42:44 +00:00
PINS := $( shell find Marlin/src/pins -mindepth 2 -name '*.h' )
2024-04-23 02:10:35 +00:00
.PHONY : $( PINS ) format -pins validate -pins
2023-11-21 09:42:44 +00:00
$(PINS) : %:
2024-04-23 02:10:35 +00:00
@echo " Formatting $@ "
@python $( SCRIPTS_DIR) /pinsformat.py $< $@
2023-11-21 09:42:44 +00:00
format-pins : $( PINS )
2024-04-23 02:10:35 +00:00
validate-pins : format -pins
@echo "Validating pins files"
@git diff --exit-code || ( git status && echo "\nError: Pins files are not formatted correctly. Run \"make format-pins\" to fix.\n" && exit 1)