hack: mutualize build opts in Makefile and Dockerfile
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>pull/1433/head
							parent
							
								
									eba49fdefd
								
							
						
					
					
						commit
						23b217af24
					
				@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					: "${DESTDIR=./bin/build}"
 | 
				
			||||||
 | 
					: "${PACKAGE=github.com/docker/buildx}"
 | 
				
			||||||
 | 
					: "${VERSION=$(./hack/git-meta version)}"
 | 
				
			||||||
 | 
					: "${REVISION=$(./hack/git-meta revision)}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					: "${CGO_ENABLED=0}"
 | 
				
			||||||
 | 
					: "${GO_PKG=github.com/docker/buildx}"
 | 
				
			||||||
 | 
					: "${GO_LDFLAGS=-X ${GO_PKG}/version.Version=${VERSION} -X ${GO_PKG}/version.Revision=${REVISION} -X ${GO_PKG}/version.Package=${PACKAGE}}"
 | 
				
			||||||
 | 
					: "${GO_EXTRA_LDFLAGS=}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set -x
 | 
				
			||||||
 | 
					CGO_ENABLED=$CGO_ENABLED go build -mod vendor -trimpath -ldflags "${GO_LDFLAGS} ${GO_EXTRA_LDFLAGS}" -o "${DESTDIR}/docker-buildx" ./cmd/buildx
 | 
				
			||||||
@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					case $1 in
 | 
				
			||||||
 | 
					  "version")
 | 
				
			||||||
 | 
					    git describe --match 'v[0-9]*' --dirty='.m' --always --tags
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "revision")
 | 
				
			||||||
 | 
					    echo "$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  *)
 | 
				
			||||||
 | 
					    echo "usage: ./hack/git-meta <version|revision>"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
					Loading…
					
					
				
		Reference in New Issue