Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: 952ebbf1fcd14ec8f8279b20ed3dbf12dd00f30c
Timestamp: Sun, 17 Mar 2019 19:10:28 +0000 (5 years ago)

+38 -9 +/-3 browse
add new build environment for cross compile
1diff --git a/.dockerignore b/.dockerignore
2new file mode 100644
3index 0000000..72e8ffc
4--- /dev/null
5+++ b/.dockerignore
6 @@ -0,0 +1 @@
7+ *
8 diff --git a/Dockerfile b/Dockerfile
9new file mode 100644
10index 0000000..1137f14
11--- /dev/null
12+++ b/Dockerfile
13 @@ -0,0 +1,24 @@
14+ # Dockerfile for cross-platform Pomo builds
15+ FROM golang:1.12-stretch
16+
17+ ENV OSXCROSS_REPO="https://github.com/tpoechtrager/osxcross.git"
18+ ENV OSX_SDK_TARBALL="https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz"
19+
20+ RUN \
21+ apt-get update -yyq \
22+ && apt-get install -yyq \
23+ clang \
24+ libxml2 \
25+ patch \
26+ xz-utils
27+
28+ RUN \
29+ mkdir /build \
30+ && cd /build \
31+ && git clone --depth=1 "$OSXCROSS_REPO" \
32+ && cd osxcross/tarballs \
33+ && wget "$OSX_SDK_TARBALL" \
34+ && cd .. \
35+ && UNATTENDED=1 ./build.sh
36+
37+ ENV PATH="$PATH:/build/osxcross/target/bin"
38 diff --git a/Makefile b/Makefile
39index 329b10a..a0046eb 100644
40--- a/Makefile
41+++ b/Makefile
42 @@ -1,25 +1,22 @@
43+ DOCKER_CMD=docker run --rm -ti --user 1000 -w /build/pomo -v $$PWD:/build/pomo
44+ DOCKER_IMAGE=pomo-build
45 VERSION ?= $(shell git describe --tags 2>/dev/null)
46 ifeq "$(VERSION)" ""
47 VERSION := UNKNOWN
48 endif
49
50 .PHONY: \
51- all \
52 test \
53 docs \
54+ pomo-build \
55 readme \
56 release \
57 release-linux \
58 release-darwin
59
60- all: bin/pomo
61-
62 bin/pomo: test
63 go build -o $@
64
65- clean:
66- -rm -rfv bin/* docs/*
67-
68 bindata.go: tomato-icon.png
69 go-bindata -pkg main -o $@ $^
70
71 @@ -27,16 +24,23 @@ test:
72 go test ./...
73 go vet ./...
74
75+ pomo-build:
76+ docker build -t $(DOCKER_IMAGE) .
77+
78+ bin/pomo-linux: bin/pomo-$(VERSION)-linux-amd64
79+
80+ bin/pomo-darwin: bin/pomo-$(VERSION)-darwin-amd64
81+
82 bin/pomo-$(VERSION)-linux-amd64: bin bindata.go
83- go build -ldflags "-X main.Version=$(VERSION)" -o $@
84+ $(DOCKER_CMD) --env GOOS=linux --env GOARCH=amd64 $(DOCKER_IMAGE) go build -ldflags "-X main.Version=$(VERSION)" -o $@
85
86 bin/pomo-$(VERSION)-linux-amd64.md5:
87 md5sum bin/pomo-$(VERSION)-linux-amd64 | sed -e 's/bin\///' > $@
88
89 bin/pomo-$(VERSION)-darwin-amd64: bin bindata.go
90- # This is used to cross-compile a Darwin compatible Mach-O executable
91+ # This is used to cross-compile a Darwin compatible Mach-O executable
92 # on Linux for OSX, you need to install https://github.com/tpoechtrager/osxcross
93- 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 $@
94+ $(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 $@
95
96
97 bin/pomo-$(VERSION)-darwin-amd64.md5: