From d874fec0013f4b3ef4cf33d1cd3dcc3f73f0d53c Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 15 Oct 2024 02:11:04 +0900 Subject: [PATCH 1/3] Build on Windows Signed-off-by: Yasuhiro Matsumoto --- Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e25c4cfb..ca536042 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,8 @@ FISHINSTALLDIR=${PREFIX}/share/fish/vendor_completions.d GO ?= go GOBIN := $(shell $(GO) env GOBIN) -GOOS ?= $(shell go env GOOS) -GOARCH ?= $(shell go env GOARCH) +GOOS ?= $(shell $(GO) env GOOS) +GOARCH ?= $(shell $(GO) env GOARCH) # N/B: This value is managed by Renovate, manual changes are # possible, as long as they don't disturb the formatting @@ -30,7 +30,7 @@ GOARCH ?= $(shell go env GOARCH) GOLANGCI_LINT_VERSION := 1.61.0 ifeq ($(GOBIN),) -GOBIN := $(GOPATH)/bin +GOBIN := $(shell $(GO) env GOPATH | sed -e 's!\\!/!g')/bin endif # Scripts may also use CONTAINER_RUNTIME, so we need to export it. @@ -99,11 +99,16 @@ ifeq ($(DISABLE_CGO), 1) override BUILDTAGS = exclude_graphdriver_btrfs containers_image_openpgp endif +BIN=bin/skopeo +ifeq ($(OS),Windows_NT) +BIN := $(BIN).exe +endif + # make all DEBUG=1 # Note: Uses the -N -l go compiler options to disable compiler optimizations # and inlining. Using these build options allows you to subsequently # use source debugging tools like delve. -all: bin/skopeo docs +all: $(BIN) docs codespell: codespell -S Makefile,build,buildah,buildah.spec,imgtype,copy,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L fpr,uint,iff,od,ERRO -w @@ -129,8 +134,8 @@ binary: cmd/skopeo $(CONTAINER_RUN) make bin/skopeo $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)' # Build w/o using containers -.PHONY: bin/skopeo -bin/skopeo: +.PHONY: $(BIN) +$(BIN): $(GO) build ${GO_DYN_FLAGS} ${SKOPEO_LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo bin/skopeo.%: GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build ${SKOPEO_LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo @@ -138,7 +143,7 @@ local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64 $(MANPAGES): %: %.md ifneq ($(DISABLE_DOCS), 1) - sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@ + sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -out $@ endif docs: $(MANPAGES) From 2f3253ec53ada4f63d82817cc2207170ff55df54 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 15 Oct 2024 21:15:59 +0900 Subject: [PATCH 2/3] use subst Signed-off-by: Yasuhiro Matsumoto --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ca536042..fe56a7c9 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ GOARCH ?= $(shell $(GO) env GOARCH) GOLANGCI_LINT_VERSION := 1.61.0 ifeq ($(GOBIN),) -GOBIN := $(shell $(GO) env GOPATH | sed -e 's!\\!/!g')/bin + GOBIN := $(subst \,/,$(shell $(GO) env GOPATH))/bin endif # Scripts may also use CONTAINER_RUNTIME, so we need to export it. From da1396ffd5ee8f21ead0827f264d9260c8d271aa Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sat, 16 Nov 2024 09:02:15 +0900 Subject: [PATCH 3/3] use SKOPEO_BIN --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fe56a7c9..4279e015 100644 --- a/Makefile +++ b/Makefile @@ -99,16 +99,16 @@ ifeq ($(DISABLE_CGO), 1) override BUILDTAGS = exclude_graphdriver_btrfs containers_image_openpgp endif -BIN=bin/skopeo +SKOPEO_BIN=bin/skopeo ifeq ($(OS),Windows_NT) -BIN := $(BIN).exe +SKOPEO_BIN := $(BIN).exe endif # make all DEBUG=1 # Note: Uses the -N -l go compiler options to disable compiler optimizations # and inlining. Using these build options allows you to subsequently # use source debugging tools like delve. -all: $(BIN) docs +all: $(SKOPEO_BIN) docs codespell: codespell -S Makefile,build,buildah,buildah.spec,imgtype,copy,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L fpr,uint,iff,od,ERRO -w @@ -134,8 +134,8 @@ binary: cmd/skopeo $(CONTAINER_RUN) make bin/skopeo $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)' # Build w/o using containers -.PHONY: $(BIN) -$(BIN): +.PHONY: $(SKOPEO_BIN) +$(SKOPEO_BIN): $(GO) build ${GO_DYN_FLAGS} ${SKOPEO_LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo bin/skopeo.%: GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build ${SKOPEO_LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo