Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. BUILDTAGS=
  2. PROJECT=github.com/docker/containerd
  3. GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)
  4. GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null)
  5. LDFLAGS := -X github.com/docker/containerd.GitCommit=${GIT_COMMIT} ${LDFLAGS}
  6. TEST_TIMEOUT ?= 5m
  7. TEST_SUITE_TIMEOUT ?= 10m
  8. # if this session isn't interactive, then we don't want to allocate a
  9. # TTY, which would fail, but if it is interactive, we do want to attach
  10. # so that the user can send e.g. ^C through.
  11. INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
  12. ifeq ($(INTERACTIVE), 1)
  13. DOCKER_FLAGS += -t
  14. endif
  15. TESTBENCH_ARTIFACTS_DIR := output/test-artifacts
  16. TESTBENCH_BUNDLE_DIR := $(TESTBENCH_ARTIFACTS_DIR)/archives
  17. DOCKER_IMAGE := containerd-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
  18. DOCKER_RUN := docker run --privileged --rm -i $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
  19. export GOPATH:=$(CURDIR)/vendor:$(GOPATH)
  20. all: client daemon shim
  21. static: client-static daemon-static shim-static
  22. bin:
  23. mkdir -p bin/
  24. clean:
  25. rm -rf bin && rm -rf output
  26. client: bin
  27. cd ctr && go build -ldflags "${LDFLAGS}" -o ../bin/ctr
  28. client-static:
  29. cd ctr && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/ctr
  30. daemon: bin
  31. cd containerd && go build -ldflags "${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd
  32. daemon-static:
  33. cd containerd && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd
  34. shim: bin
  35. cd containerd-shim && go build -tags "$(BUILDTAGS)" -ldflags "-w" -o ../bin/containerd-shim
  36. shim-static:
  37. cd containerd-shim && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd-shim
  38. $(TESTBENCH_BUNDLE_DIR)/busybox.tar:
  39. mkdir -p $(TESTBENCH_BUNDLE_DIR)
  40. curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' -o $(TESTBENCH_BUNDLE_DIR)/busybox.tar
  41. bundles-rootfs: $(TESTBENCH_BUNDLE_DIR)/busybox.tar
  42. dbuild: $(TESTBENCH_BUNDLE_DIR)/busybox.tar
  43. @docker build --rm --force-rm -t "$(DOCKER_IMAGE)" .
  44. dtest: dbuild
  45. $(DOCKER_RUN) make test
  46. dbench: dbuild
  47. $(DOCKER_RUN) make bench
  48. install:
  49. cp bin/* /usr/local/bin/
  50. protoc:
  51. protoc -I ./api/grpc/types ./api/grpc/types/api.proto --go_out=plugins=grpc:api/grpc/types
  52. fmt:
  53. @gofmt -s -l . | grep -v vendor | grep -v .pb. | tee /dev/stderr
  54. lint:
  55. @golint ./... | grep -v vendor | grep -v .pb. | tee /dev/stderr
  56. shell: dbuild
  57. $(DOCKER_RUN) bash
  58. test: validate install bundles-rootfs
  59. go test -bench=. -v $(shell go list ./... | grep -v /vendor | grep -v /integration-test)
  60. ifneq ($(wildcard /.dockerenv), )
  61. cd integration-test ; \
  62. go test -check.v -check.timeout=$(TEST_TIMEOUT) -timeout=$(TEST_SUITE_TIMEOUT) $(TESTFLAGS) github.com/docker/containerd/integration-test && \
  63. go test -containerd.shim="" -check.v -check.timeout=$(TEST_TIMEOUT) -timeout=$(TEST_SUITE_TIMEOUT) $(TESTFLAGS) github.com/docker/containerd/integration-test
  64. endif
  65. bench: shim validate install bundles-rootfs
  66. go test -bench=. -v $(shell go list ./... | grep -v /vendor | grep -v /integration-test)
  67. validate: fmt
  68. uninstall:
  69. $(foreach file,containerd containerd-shim ctr,rm /usr/local/bin/$(file);)