Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. .PHONY: all test validate-dco validate-gofmt validate build
  2. LIBCOMPOSE_ENVS := \
  3. -e OS_PLATFORM_ARG \
  4. -e OS_ARCH_ARG \
  5. -e DOCKER_TEST_HOST \
  6. -e TESTDIRS \
  7. -e TESTFLAGS \
  8. -e TESTVERBOSE
  9. # (default to no bind mount if DOCKER_HOST is set)
  10. BIND_DIR := $(if $(DOCKER_HOST),,bundles)
  11. LIBCOMPOSE_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/libcompose/$(BIND_DIR)")
  12. GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
  13. LIBCOMPOSE_IMAGE := libcompose-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
  14. DAEMON_VERSION := $(if $(DAEMON_VERSION),$(DAEMON_VERSION),"default")
  15. TTY := $(shell [ -t 0 ] && echo "-t")
  16. DOCKER_RUN_LIBCOMPOSE := docker run --rm -i $(TTY) --privileged -e DAEMON_VERSION="$(DAEMON_VERSION)" $(LIBCOMPOSE_ENVS) $(LIBCOMPOSE_MOUNT) "$(LIBCOMPOSE_IMAGE)"
  17. default: binary
  18. all: build ## validate all checks, build linux binary, run all tests\ncross build non-linux binaries
  19. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh
  20. binary: build ## build the linux binary
  21. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh binary
  22. cross-binary: build ## cross build the non linux binaries (windows, darwin)
  23. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh cross-binary
  24. test: build ## run the unit, integration and acceptance tests
  25. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh binary test-unit test-integration test-acceptance
  26. test-unit: build ## run the unit tests
  27. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh test-unit
  28. test-integration: build ## run the integration tests
  29. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh binary test-integration
  30. test-acceptance: build ## run the acceptance tests
  31. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh binary test-acceptance
  32. validate: build ## validate DCO, git conflicts marks, gofmt, golint and go vet
  33. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh validate-dco validate-git-marks validate-gofmt validate-lint validate-vet
  34. shell: build ## start a shell inside the build env
  35. $(DOCKER_RUN_LIBCOMPOSE) bash
  36. # Build the docker image, should be prior almost any other goals
  37. build: bundles
  38. docker build -t "$(LIBCOMPOSE_IMAGE)" .
  39. bundles:
  40. mkdir bundles
  41. clean:
  42. $(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh clean
  43. help: ## this help
  44. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)