github.com/docker/containerd@v0.2.9-0.20170509230648-8ef7df579710/Makefile (about)

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