Makefile 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 unit-test-single-ci : Run a single code test from inside the CI"
  15. # @echo "make unit-test-single-local : Run a single code test locally"
  16. # @echo "make unit-test-single-local-docker : Run a single code test locally, using docker-compose"
  17. @echo "make unit-test-all-local : Run all code tests locally"
  18. @echo "make unit-test-all-local-docker : Run all code tests locally, using docker-compose"
  19. @echo "make setup-local-docker : Setup local docker-compose"
  20. @echo ""
  21. @echo "Options for testing:"
  22. @echo " TEST_TARGET Set when running tests-single-*, to select the"
  23. @echo " test. If you set it to ALL it will run all "
  24. @echo " tests, but some of them are broken: use "
  25. @echo " tests-all-* instead to run only the ones that "
  26. @echo " run on GitHub CI"
  27. @echo " ONLY_TEST Limit tests to only those that contain this, or"
  28. @echo " the index of the test (1-based)"
  29. @echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
  30. @echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
  31. @echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
  32. marlin:
  33. ./buildroot/bin/mftest -a
  34. .PHONY: marlin
  35. tests-single-ci:
  36. export GIT_RESET_HARD=true
  37. $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) PLATFORMIO_BUILD_FLAGS=-DGITHUB_ACTION
  38. tests-single-local:
  39. @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
  40. export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
  41. && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
  42. && run_tests . $(TEST_TARGET) "$(ONLY_TEST)"
  43. tests-single-local-docker:
  44. @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
  45. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  46. $(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)"
  47. tests-all-local:
  48. export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
  49. && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
  50. && for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
  51. tests-all-local-docker:
  52. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  53. $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
  54. #unit-test-single-ci:
  55. # export GIT_RESET_HARD=true
  56. # $(MAKE) unit-test-single-local TEST_TARGET=$(TEST_TARGET)
  57. # TODO: How can we limit tests with ONLY_TEST with platformio?
  58. #unit-test-single-local:
  59. # @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local" ; return 1; fi
  60. # platformio run -t marlin_$(TEST_TARGET)
  61. #unit-test-single-local-docker:
  62. # @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local-docker" ; return 1; fi
  63. # @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  64. # $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local TEST_TARGET=$(TEST_TARGET) ONLY_TEST="$(ONLY_TEST)"
  65. unit-test-all-local:
  66. platformio run -t test-marlin -e linux_native_test
  67. unit-test-all-local-docker:
  68. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  69. $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-all-local
  70. setup-local-docker:
  71. $(CONTAINER_RT_BIN) buildx build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
  72. PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')
  73. $(PINS): %:
  74. @echo "Formatting $@" && node $(SCRIPTS_DIR)/pinsformat.js $@
  75. format-pins: $(PINS)