/vendor/github.com/containers/storage/Makefile

https://gitlab.com/unofficial-mirrors/openshift-source-to-image · Makefile · 142 lines · 108 code · 33 blank · 1 comment · 4 complexity · 928436313806337b58c613260f759e25 MD5 · raw file

  1. export GO111MODULE=off
  2. export GOPROXY=https://proxy.golang.org
  3. .PHONY: \
  4. all \
  5. binary \
  6. clean \
  7. cross \
  8. default \
  9. docs \
  10. gccgo \
  11. help \
  12. install.tools \
  13. local-binary \
  14. local-cross \
  15. local-gccgo \
  16. local-test-integration \
  17. local-test-unit \
  18. local-validate \
  19. lint \
  20. test \
  21. test-integration \
  22. test-unit \
  23. validate \
  24. vendor
  25. PACKAGE := github.com/containers/storage
  26. GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
  27. GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
  28. EPOCH_TEST_COMMIT := 0418ebf59f9e1f564831c0ba9378b7f8e40a1c73
  29. NATIVETAGS :=
  30. AUTOTAGS := $(shell ./hack/btrfs_tag.sh) $(shell ./hack/libdm_tag.sh)
  31. BUILDFLAGS := -tags "$(AUTOTAGS) $(TAGS)" $(FLAGS)
  32. GO ?= go
  33. GO_BUILD=$(GO) build
  34. GO_TEST=$(GO) test
  35. # Go module support: set `-mod=vendor` to use the vendored sources
  36. ifeq ($(shell $(GO) help mod >/dev/null 2>&1 && echo true), true)
  37. GO_BUILD=GO111MODULE=on $(GO) build -mod=vendor
  38. GO_TEST=GO111MODULE=on $(GO) test -mod=vendor
  39. endif
  40. RUNINVM := vagrant/runinvm.sh
  41. FFJSON := tests/tools/build/ffjson
  42. default all: local-binary docs local-validate local-cross local-gccgo test-unit test-integration ## validate all checks, build and cross-build\nbinaries and docs, run tests in a VM
  43. clean: ## remove all built files
  44. $(RM) -f containers-storage containers-storage.* docs/*.1 docs/*.5
  45. sources := $(wildcard *.go cmd/containers-storage/*.go drivers/*.go drivers/*/*.go pkg/*/*.go pkg/*/*/*.go) layers_ffjson.go images_ffjson.go containers_ffjson.go pkg/archive/archive_ffjson.go
  46. containers-storage: $(sources) ## build using gc on the host
  47. $(GO_BUILD) -compiler gc $(BUILDFLAGS) ./cmd/containers-storage
  48. layers_ffjson.go: $(FFJSON) layers.go
  49. $(RM) $@
  50. $(FFJSON) layers.go
  51. images_ffjson.go: $(FFJSON) images.go
  52. $(RM) $@
  53. $(FFJSON) images.go
  54. containers_ffjson.go: $(FFJSON) containers.go
  55. $(RM) $@
  56. $(FFJSON) containers.go
  57. pkg/archive/archive_ffjson.go: $(FFJSON) pkg/archive/archive.go
  58. $(RM) $@
  59. $(FFJSON) pkg/archive/archive.go
  60. binary local-binary: containers-storage
  61. local-gccgo: ## build using gccgo on the host
  62. GCCGO=$(PWD)/hack/gccgo-wrapper.sh $(GO_BUILD) -compiler gccgo $(BUILDFLAGS) -o containers-storage.gccgo ./cmd/containers-storage
  63. local-cross: ## cross build the binaries for arm, darwin, and\nfreebsd
  64. @for target in linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64 linux/ppc64le darwin/amd64 windows/amd64 ; do \
  65. os=`echo $${target} | cut -f1 -d/` ; \
  66. arch=`echo $${target} | cut -f2 -d/` ; \
  67. suffix=$${os}.$${arch} ; \
  68. echo env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $(GO_BUILD) -compiler gc -tags \"$(NATIVETAGS) $(TAGS)\" $(FLAGS) -o containers-storage.$${suffix} ./cmd/containers-storage ; \
  69. env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $(GO_BUILD) -compiler gc -tags "$(NATIVETAGS) $(TAGS)" $(FLAGS) -o containers-storage.$${suffix} ./cmd/containers-storage || exit 1 ; \
  70. done
  71. cross: ## cross build the binaries for arm, darwin, and\nfreebsd using VMs
  72. $(RUNINVM) make local-$@
  73. docs: install.tools ## build the docs on the host
  74. $(MAKE) -C docs docs
  75. gccgo: ## build using gccgo using VMs
  76. $(RUNINVM) make local-$@
  77. test: local-binary ## build the binaries and run the tests using VMs
  78. $(RUNINVM) make local-binary local-cross local-test-unit local-test-integration
  79. local-test-unit: local-binary ## run the unit tests on the host (requires\nsuperuser privileges)
  80. @$(GO_TEST) $(BUILDFLAGS) $(shell $(GO) list ./... | grep -v ^$(PACKAGE)/vendor)
  81. test-unit: local-binary ## run the unit tests using VMs
  82. $(RUNINVM) make local-$@
  83. local-test-integration: local-binary ## run the integration tests on the host (requires\nsuperuser privileges)
  84. @cd tests; ./test_runner.bash
  85. test-integration: local-binary ## run the integration tests using VMs
  86. $(RUNINVM) make local-$@
  87. local-validate: ## validate DCO and gofmt on the host
  88. @./hack/git-validation.sh
  89. @./hack/gofmt.sh
  90. validate: ## validate DCO, gofmt, ./pkg/ isolation, golint,\ngo vet and vendor using VMs
  91. $(RUNINVM) make local-$@
  92. install.tools:
  93. make -C tests/tools
  94. $(FFJSON):
  95. make -C tests/tools build/ffjson
  96. install.docs: docs
  97. make -C docs install
  98. install: install.docs
  99. lint: install.tools
  100. tests/tools/build/golangci-lint run
  101. help: ## this help
  102. @awk 'BEGIN {FS = ":.*?## "} /^[a-z A-Z_-]+:.*?## / {gsub(" ",",",$$1);gsub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-21s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
  103. vendor-in-container:
  104. podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src golang make vendor
  105. vendor:
  106. export GO111MODULE=on \
  107. $(GO) mod tidy && \
  108. $(GO) mod vendor && \
  109. $(GO) mod verify