Skip to content

Commit 952ebbf

Browse files
committed
add new build environment for cross compile
1 parent 63b1e54 commit 952ebbf

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dockerfile for cross-platform Pomo builds
2+
FROM golang:1.12-stretch
3+
4+
ENV OSXCROSS_REPO="https://github.com/tpoechtrager/osxcross.git"
5+
ENV OSX_SDK_TARBALL="https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz"
6+
7+
RUN \
8+
apt-get update -yyq \
9+
&& apt-get install -yyq \
10+
clang \
11+
libxml2 \
12+
patch \
13+
xz-utils
14+
15+
RUN \
16+
mkdir /build \
17+
&& cd /build \
18+
&& git clone --depth=1 "$OSXCROSS_REPO" \
19+
&& cd osxcross/tarballs \
20+
&& wget "$OSX_SDK_TARBALL" \
21+
&& cd .. \
22+
&& UNATTENDED=1 ./build.sh
23+
24+
ENV PATH="$PATH:/build/osxcross/target/bin"

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
1+
DOCKER_CMD=docker run --rm -ti --user 1000 -w /build/pomo -v $$PWD:/build/pomo
2+
DOCKER_IMAGE=pomo-build
13
VERSION ?= $(shell git describe --tags 2>/dev/null)
24
ifeq "$(VERSION)" ""
35
VERSION := UNKNOWN
46
endif
57

68
.PHONY: \
7-
all \
89
test \
910
docs \
11+
pomo-build \
1012
readme \
1113
release \
1214
release-linux \
1315
release-darwin
1416

15-
all: bin/pomo
16-
1717
bin/pomo: test
1818
go build -o $@
1919

20-
clean:
21-
-rm -rfv bin/* docs/*
22-
2320
bindata.go: tomato-icon.png
2421
go-bindata -pkg main -o $@ $^
2522

2623
test:
2724
go test ./...
2825
go vet ./...
2926

27+
pomo-build:
28+
docker build -t $(DOCKER_IMAGE) .
29+
30+
bin/pomo-linux: bin/pomo-$(VERSION)-linux-amd64
31+
32+
bin/pomo-darwin: bin/pomo-$(VERSION)-darwin-amd64
33+
3034
bin/pomo-$(VERSION)-linux-amd64: bin bindata.go
31-
go build -ldflags "-X main.Version=$(VERSION)" -o $@
35+
$(DOCKER_CMD) --env GOOS=linux --env GOARCH=amd64 $(DOCKER_IMAGE) go build -ldflags "-X main.Version=$(VERSION)" -o $@
3236

3337
bin/pomo-$(VERSION)-linux-amd64.md5:
3438
md5sum bin/pomo-$(VERSION)-linux-amd64 | sed -e 's/bin\///' > $@
3539

3640
bin/pomo-$(VERSION)-darwin-amd64: bin bindata.go
37-
# This is used to cross-compile a Darwin compatible Mach-O executable
41+
# This is used to cross-compile a Darwin compatible Mach-O executable
3842
# on Linux for OSX, you need to install https://github.com/tpoechtrager/osxcross
39-
PATH="$$PATH:/usr/local/osx-ndk-x86/bin" GOOS=darwin GOARCH=amd64 CC=/usr/local/osx-ndk-x86/bin/x86_64-apple-darwin15-cc CGO_ENABLED=1 go build $(FLAGS) -o $@
43+
$(DOCKER_CMD) --env GOOS=darwin --env GOARCH=amd64 --env CC=x86_64-apple-darwin15-cc --env CGO_ENABLED=1 $(DOCKER_IMAGE) go build -ldflags "-X main.Version=$(VERSION)" -o $@
4044

4145

4246
bin/pomo-$(VERSION)-darwin-amd64.md5:

0 commit comments

Comments
 (0)