Skip to content

Commit

Permalink
Makefile: add a cross target 🌵
Browse files Browse the repository at this point in the history
This will allow building for different target (x86_64, arm, arm64,
s390x and ppc64le).

This doesn't mean we support those architecture (especially as `ko`
doesn't really support multi-arch for now). But it is nice to be able
to see if our code compiles and can be package (manually,
*unofficially*, for those target). A check will be added in plumbing
so that we validate that, at least, a PR doesn't break those.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester authored and tekton-robot committed Jul 24, 2020
1 parent 4772854 commit abb677d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ FORCE:
bin/%: cmd/% FORCE
$(GO) build -mod=vendor $(LDFLAGS) -v -o $@ ./$<

.PHONY: cross
cross: amd64 arm arm64 s390x ppc64le ## build cross platform binaries

.PHONY: amd64
amd64:
GOOS=linux GOARCH=amd64 go build -mod=vendor $(LDFLAGS) ./cmd/...

.PHONY: arm
arm:
GOOS=linux GOARCH=arm go build -mod=vendor $(LDFLAGS) ./cmd/...

.PHONY: arm64
arm64:
GOOS=linux GOARCH=arm64 go build -mod=vendor $(LDFLAGS) ./cmd/...

.PHONY: s390x
s390x:
GOOS=linux GOARCH=s390x go build -mod=vendor $(LDFLAGS) ./cmd/...

.PHONY: ppc64le
ppc64le:
GOOS=linux GOARCH=ppc64le go build -mod=vendor $(LDFLAGS) ./cmd/...

KO = $(BIN)/ko
$(BIN)/ko: PACKAGE=github.com/google/ko/cmd/ko

Expand Down Expand Up @@ -173,6 +196,7 @@ fmt: ; $(info $(M) running gofmt…) @ ## Run gofmt on all source files
.PHONY: clean
clean: ; $(info $(M) cleaning…) @ ## Cleanup everything
@rm -rf $(BIN)
@rm -rf bin
@rm -rf test/tests.* test/coverage.*

.PHONY: help
Expand Down

0 comments on commit abb677d

Please sign in to comment.