Makefile 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. SCRIPTS_DIR := buildroot/share/scripts
  2. CONTAINER_RT_BIN := docker
  3. CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
  4. CONTAINER_IMAGE := marlin-dev
  5. help:
  6. @echo "Tasks for local development:"
  7. @echo "make marlin : Build marlin for the configured board"
  8. @echo "make format-pins : Reformat all pins files"
  9. @echo "make tests-single-ci : Run a single test from inside the CI"
  10. @echo "make tests-single-local : Run a single test locally"
  11. @echo "make tests-single-local-docker : Run a single test locally, using docker"
  12. @echo "make tests-all-local : Run all tests locally"
  13. @echo "make tests-all-local-docker : Run all tests locally, using docker"
  14. @echo "make setup-local-docker : Build the local docker image"
  15. @echo ""
  16. @echo "Options for testing:"
  17. @echo " TEST_TARGET Set when running tests-single-*, to select the"
  18. @echo " test. If you set it to ALL it will run all "
  19. @echo " tests, but some of them are broken: use "
  20. @echo " tests-all-* instead to run only the ones that "
  21. @echo " run on GitHub CI"
  22. @echo " ONLY_TEST Limit tests to only those that contain this, or"
  23. @echo " the index of the test (1-based)"
  24. @echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
  25. @echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
  26. @echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
  27. marlin:
  28. ./buildroot/bin/mftest -a
  29. .PHONY: marlin
  30. tests-single-ci:
  31. export GIT_RESET_HARD=true
  32. $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) PLATFORMIO_BUILD_FLAGS=-DGITHUB_ACTION
  33. tests-single-local:
  34. @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
  35. export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
  36. && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
  37. && run_tests . $(TEST_TARGET) "$(ONLY_TEST)"
  38. tests-single-local-docker:
  39. @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
  40. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  41. $(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)"
  42. tests-all-local:
  43. export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
  44. && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
  45. && for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
  46. tests-all-local-docker:
  47. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  48. $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
  49. setup-local-docker:
  50. $(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
  51. PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')
  52. $(PINS): %:
  53. @echo "Formatting $@" && node $(SCRIPTS_DIR)/pinsformat.js $@
  54. format-pins: $(PINS)