diff --git a/Makefile b/Makefile index a6fbd94570e..90c9a95208f 100644 --- a/Makefile +++ b/Makefile @@ -50,15 +50,32 @@ else stack install --pedantic --test --bench --no-run-benchmarks --local-bin-path=dist endif -.PHONY: delete-cache-on-linker-errors -delete-cache-on-linker-errors: +# Clean +.PHONY: full-clean +full-clean: clean rm -rf ~/.cache/hie-bios ifdef CABAL_DIR rm -rf $(CABAL_DIR)/store else rm -rf ~/.cabal/store endif + +.PHONY: clean +clean: +ifeq ($(WIRE_BUILD_WITH_CABAL), 1) cabal clean +else + stack clean +endif + $(MAKE) -C services/nginz clean + -rm -rf dist + -rm -f .metadata + +.PHONY: clean-hint +clean-hint: + @echo -e "\n\n\n>>> PSA: if you get errors that are hard to explain," + @echo -e ">>> try 'make full-clean' and run your command again." + @echo -e ">>> see https://github.com/wireapp/wire-server/blob/develop/docs/developer/building.md#linker-errors-while-compiling\n\n\n" .PHONY: cabal.project.local cabal.project.local: @@ -77,7 +94,7 @@ endif # Usage: make c package=brig test=1 .PHONY: c c: cabal-fmt - cabal build $(WIRE_CABAL_BUILD_OPTIONS) $(package) + cabal build $(WIRE_CABAL_BUILD_OPTIONS) $(package) || ( make clean-hint; false ) ifeq ($(test), 1) ./hack/bin/cabal-run-tests.sh $(package) $(testargs) endif @@ -156,18 +173,6 @@ add-license: shellcheck: ./hack/bin/shellcheck.sh -# Clean -.PHONY: clean -clean: -ifeq ($(WIRE_BUILD_WITH_CABAL), 1) - cabal clean -else - stack clean -endif - $(MAKE) -C services/nginz clean - -rm -rf dist - -rm -f .metadata - ################################# ## running integration tests diff --git a/changelog.d/5-internal/tweak-makefile b/changelog.d/5-internal/tweak-makefile new file mode 100644 index 00000000000..8011fe468a3 --- /dev/null +++ b/changelog.d/5-internal/tweak-makefile @@ -0,0 +1 @@ +Improve cleaning rules in Makefile. diff --git a/docs/developer/building.md b/docs/developer/building.md index 9ed0d365b7f..edcbe91b78b 100644 --- a/docs/developer/building.md +++ b/docs/developer/building.md @@ -43,10 +43,10 @@ Linker errors can occur if the nix-provided build environment (see `nix/` direct Haskell Language Server stores its build artifacts in `~/.cache/hie-bios` (equivalent to the `./dist-newstyle` directory) which become invalid for the same reason. -The easiest course of action is to to remove these directories via: +The easiest course of action is to to remove these directories via: ``` -make delete-cache-on-linker-errors +make full-clean ``` # How to run integration tests @@ -77,7 +77,7 @@ After all containers are up you can use these Makefile targets to run the tests ``` # build and run galley's integration tests -make ci package=galley +make ci package=galley # run galley's integration tests that match a pattern TASTY_PATTERN="/MLS/" make ci package=galley