Makefile 720 B

123456789101112131415161718192021222324252627282930
  1. DIRS := \
  2. . \
  3. nl
  4. DEPS = \
  5. github.com/vishvananda/netns
  6. uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
  7. testdirs = $(call uniq,$(foreach d,$(1),$(dir $(wildcard $(d)/*_test.go))))
  8. goroot = $(addprefix ../../../,$(1))
  9. unroot = $(subst ../../../,,$(1))
  10. fmt = $(addprefix fmt-,$(1))
  11. all: test
  12. $(call goroot,$(DEPS)):
  13. go get $(call unroot,$@)
  14. .PHONY: $(call testdirs,$(DIRS))
  15. $(call testdirs,$(DIRS)):
  16. sudo -E go test -test.parallel 4 -timeout 60s -v github.com/vishvananda/netlink/$@
  17. $(call fmt,$(call testdirs,$(DIRS))):
  18. ! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .
  19. .PHONY: fmt
  20. fmt: $(call fmt,$(call testdirs,$(DIRS)))
  21. test: fmt $(call goroot,$(DEPS)) $(call testdirs,$(DIRS))