Fix cross-compiling with go 1.15.x

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
Antonio Navarro Perez 2020-10-18 20:14:32 +02:00
parent f5038291b8
commit d72d77092b
4 changed files with 47 additions and 5 deletions

View file

@ -38,16 +38,16 @@ go-generate:
go-compile:
@echo " > Compiling for several platforms..."
go get src.techknowlogick.com/xgo
docker pull billziss/xgo-cgofuse
docker build ./build_tools/ -t distribyted/xgo-cgofuse
mkdir -p $(ORGPATH)
ln -sfrnT . $(REPOPATH)
@echo " > Compiling for windows..."
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=billziss/xgo-cgofuse -ldflags='-extldflags "-static" $(LDFLAGS)' -tags="release" -targets=windows/* $(REPOPATH)/cmd/distribyted/
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='-extldflags "-static" $(LDFLAGS)' -tags="release" -targets=windows/amd64 $(REPOPATH)/cmd/distribyted/
@echo " > Compiling for linux..."
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=billziss/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=linux/arm-7,linux/amd64,linux/386 $(REPOPATH)/cmd/distribyted/
@echo " > Compiling for darwin..."
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=billziss/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=darwin/* $(REPOPATH)/cmd/distribyted/
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=linux/arm-7,linux/amd64 $(REPOPATH)/cmd/distribyted/
# @echo " > Compiling for darwin..."
# GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=darwin/* $(REPOPATH)/cmd/distribyted/
.PHONY: help
all: help

36
build_tools/Dockerfile Normal file
View file

@ -0,0 +1,36 @@
FROM techknowlogick/xgo:go-1.15.x
# add 32-bit and 64-bit architectures and install 7zip
RUN \
dpkg --add-architecture i386 && \
dpkg --add-architecture amd64 && \
apt-get update && \
apt-get install -y --no-install-recommends p7zip-full
# install OSXFUSE
# (TODO) not compatible anymore. Find a new way to install osxfuse
# RUN wget -q -O osxfuse.dmg https://github.com/osxfuse/osxfuse/releases/download/osxfuse-3.8.3/osxfuse-3.8.3.dmg
# RUN 7z e osxfuse.dmg 0.hfs
# RUN 7z e 0.hfs "FUSE for macOS/Extras/FUSE for macOS 3.8.3.pkg"
# RUN 7z e "FUSE for macOS 3.8.3.pkg" Core.pkg/Payload
# RUN 7z e Payload
# RUN 7z x Payload~ -o/tmp
# RUN cp -R /tmp/usr/local/include/osxfuse /usr/local/include
# RUN cp /tmp/usr/local/lib/libosxfuse_i64.2.dylib /usr/local/lib/libosxfuse.dylib
# install LIBFUSE
RUN \
apt-get update && \
apt-get install -y --no-install-recommends libfuse-dev:i386 && \
apt-get install -y --no-install-recommends libfuse-dev:amd64 && \
apt-get download libfuse-dev:i386 && \
dpkg -x libfuse-dev*i386*.deb /
# install WinFsp-FUSE
RUN \
wget -q -O winfsp.zip \
https://github.com/billziss-gh/winfsp/archive/release/1.4.zip && \
7z e winfsp.zip 'winfsp-release-1.4/inc/fuse/*' -o/usr/local/include/winfsp
ENV \
OSXCROSS_NO_INCLUDE_PATH_WARNINGS 1

2
go.mod
View file

@ -26,6 +26,7 @@ require (
github.com/pion/srtp v1.5.2 // indirect
github.com/pion/webrtc/v2 v2.2.26 // indirect
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect
github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.6.1
github.com/willf/bitset v1.1.11 // indirect
@ -36,4 +37,5 @@ require (
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
src.techknowlogick.com/xgo v1.1.1-0.20201014223913-54d7d44a2ff6 // indirect
)

4
go.sum
View file

@ -531,6 +531,8 @@ github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5J
github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk=
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU=
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
@ -808,3 +810,5 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck=
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
src.techknowlogick.com/xgo v1.1.1-0.20201014223913-54d7d44a2ff6 h1:/ah7Ft+/8S8mrgkXgaSZdG1ocoV6QzjEgMhiXLCWj3s=
src.techknowlogick.com/xgo v1.1.1-0.20201014223913-54d7d44a2ff6/go.mod h1:31CE1YKtDOrKTk9PSnjTpe6YbO6W/0LTYZ1VskL09oU=