Skip to content

Commit 53d378d

Browse files
author
Radu M
authored
Merge pull request #6 from radu-matei/cross
Add cross compilation target
2 parents 8883869 + f5e59e9 commit 53d378d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
run: |
1919
export GOPATH=$HOME/go && export GOBIN=$(go env GOPATH)/bin && export PATH=$PATH:$GOPATH&& export PATH=$PATH:$GOBIN && mkdir -p $GOBIN
2020
21-
make bootstrap build test
21+
make bootstrap build test lint build-cross

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ ORG := engineerd
33
BINDIR := $(CURDIR)/bin
44
GOFLAGS :=
55
LDFLAGS := -w -s
6+
TARGETS := darwin/amd64 linux/amd64 windows/amd64
7+
TAGS :=
8+
9+
GOX = $(GOPATH)/bin/gox
610

711
ifeq ($(OS),Windows_NT)
812
TARGET = $(PROJECT).exe
@@ -22,6 +26,14 @@ build:
2226
test:
2327
go test $(TESTFLAGS) ./...
2428

29+
$(GOX):
30+
(cd /; GO111MODULE=on go get -u github.com/mitchellh/gox)
31+
32+
.PHONY: build-cross
33+
build-cross: LDFLAGS += -extldflags "-static"
34+
build-cross: $(GOX)
35+
GO111MODULE=on CGO_ENABLED=0 $(GOX) -parallel=3 -output="bin/{{.OS}}-{{.Arch}}/$(PROJECT)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/$(ORG)/$(PROJECT)/cmd/...
36+
2537
.PHONY: lint
2638
lint:
2739
golangci-lint run --config ./golangci.yml

0 commit comments

Comments
 (0)