github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/libnetwork/Makefile (about) 1 .PHONY: all all-local build build-local clean cross cross-local check check-code check-format run-tests integration-tests check-local coveralls circle-ci-cross circle-ci-build circle-ci-check circle-ci 2 SHELL=/bin/bash 3 build_image=libnetworkbuild 4 dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork 5 container_env = -e "INSIDECONTAINER=-incontainer=true" 6 docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image} 7 ciargs = -e CIRCLECI -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true" 8 cidocker = docker run ${dockerargs} ${ciargs} $$EXTRA_ARGS ${container_env} ${build_image} 9 CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64 10 export PATH := $(CURDIR)/bin:$(PATH) 11 hostOS = ${shell go env GOHOSTOS} 12 ifeq (${hostOS}, solaris) 13 gnufind=gfind 14 gnutail=gtail 15 else 16 gnufind=find 17 gnutail=tail 18 endif 19 20 all: ${build_image}.created build check integration-tests clean 21 22 all-local: build-local check-local integration-tests-local clean 23 24 ${build_image}.created: 25 docker build -f Dockerfile.build -t ${build_image} . 26 touch ${build_image}.created 27 28 build: ${build_image}.created 29 @echo "Building code... " 30 @${docker} ./wrapmake.sh build-local 31 @echo "Done building code" 32 33 build-local: 34 @mkdir -p "bin" 35 $(shell which godep) go build -tags experimental -o "bin/dnet" ./cmd/dnet 36 $(shell which godep) go build -o "bin/docker-proxy" ./cmd/proxy 37 38 clean: 39 @if [ -d bin ]; then \ 40 echo "Removing dnet and proxy binaries"; \ 41 rm -rf bin; \ 42 fi 43 44 cross: ${build_image}.created 45 @mkdir -p "bin" 46 @for platform in ${CROSS_PLATFORMS}; do \ 47 EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \ 48 echo "$${platform}..." ; \ 49 ${docker} make cross-local ; \ 50 done 51 52 cross-local: 53 $(shell which godep) go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet 54 $(shell which godep) go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy 55 56 check: ${build_image}.created 57 @${docker} ./wrapmake.sh check-local 58 59 check-code: 60 @echo "Checking code... " 61 test -z "$$(golint ./... | grep -v .pb.go: | tee /dev/stderr)" 62 go vet ./... 63 @echo "Done checking code" 64 65 check-format: 66 @echo "Checking format... " 67 test -z "$$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" 68 @echo "Done checking format" 69 70 run-tests: 71 @echo "Running tests... " 72 @echo "mode: count" > coverage.coverprofile 73 @for dir in $$( ${gnufind} . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d); do \ 74 if [ ${hostOS} == solaris ]; then \ 75 case "$$dir" in \ 76 "./cmd/dnet" ) \ 77 ;& \ 78 "./cmd/ovrouter" ) \ 79 ;& \ 80 "./ns" ) \ 81 ;& \ 82 "./iptables" ) \ 83 ;& \ 84 "./ipvs" ) \ 85 ;& \ 86 "./drivers/bridge" ) \ 87 ;& \ 88 "./drivers/host" ) \ 89 ;& \ 90 "./drivers/ipvlan" ) \ 91 ;& \ 92 "./drivers/macvlan" ) \ 93 ;& \ 94 "./drivers/overlay" ) \ 95 ;& \ 96 "./drivers/remote" ) \ 97 ;& \ 98 "./drivers/windows" ) \ 99 echo "Skipping $$dir on solaris host... "; \ 100 continue; \ 101 ;; \ 102 * )\ 103 echo "Entering $$dir ... "; \ 104 ;; \ 105 esac; \ 106 fi; \ 107 if ls $$dir/*.go &> /dev/null; then \ 108 pushd . &> /dev/null ; \ 109 cd $$dir ; \ 110 $(shell which godep) go test ${INSIDECONTAINER} -test.parallel 5 -test.v -covermode=count -coverprofile=./profile.tmp ; \ 111 ret=$$? ;\ 112 if [ $$ret -ne 0 ]; then exit $$ret; fi ;\ 113 popd &> /dev/null; \ 114 if [ -f $$dir/profile.tmp ]; then \ 115 cat $$dir/profile.tmp | ${gnutail} -n +2 >> coverage.coverprofile ; \ 116 rm $$dir/profile.tmp ; \ 117 fi ; \ 118 fi ; \ 119 done 120 @echo "Done running tests" 121 122 check-local: check-format check-code run-tests 123 124 integration-tests: ./bin/dnet 125 @./test/integration/dnet/run-integration-tests.sh 126 127 ./bin/dnet: 128 make build 129 130 coveralls: 131 -@goveralls -service circleci -coverprofile=coverage.coverprofile -repotoken $$COVERALLS_TOKEN 132 133 # CircleCI's Docker fails when cleaning up using the --rm flag 134 # The following targets are a workaround for this 135 circle-ci-cross: ${build_image}.created 136 @mkdir -p "bin" 137 @for platform in ${CROSS_PLATFORMS}; do \ 138 EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \ 139 echo "$${platform}..." ; \ 140 ${cidocker} make cross-local ; \ 141 done 142 143 circle-ci-check: ${build_image}.created 144 @${cidocker} make check-local coveralls 145 146 circle-ci-build: ${build_image}.created 147 @${cidocker} make build-local 148 149 circle-ci: circle-ci-build circle-ci-check circle-ci-cross integration-tests