Switch to xgo for cross-compilation

Ref T529
This commit is contained in:
Matt Baer 2018-12-08 18:27:50 -05:00
parent 20c77989ba
commit 9fb7777c33
1 changed files with 15 additions and 6 deletions

View File

@ -16,13 +16,22 @@ build: deps
cd cmd/writefreely; $(GOBUILD) -v
build-linux: deps
cd cmd/writefreely; GOOS=linux GOARCH=amd64 $(GOBUILD) -v
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
fi
xgo --targets=linux/amd64, -dest build/ $(LDFLAGS) -out writefreely ./cmd/writefreely
build-windows: deps
cd cmd/writefreely; GOOS=windows GOARCH=amd64 $(GOBUILD) -v
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
fi
xgo --targets=windows/amd64, -dest build/ $(LDFLAGS) -out writefreely ./cmd/writefreely
build-darwin: deps
cd cmd/writefreely; GOOS=darwin GOARCH=amd64 $(GOBUILD) -v
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
fi
xgo --targets=darwin/amd64, -dest build/ $(LDFLAGS) -out writefreely ./cmd/writefreely
build-docker :
$(DOCKERCMD) build -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(GITREV) .
@ -50,15 +59,15 @@ release : clean ui
cp schema.sql build
cp sqlite.sql build
$(MAKE) build-linux
cp cmd/writefreely/$(BINARY_NAME) build
mv build/$(BINARY_NAME)-linux-amd64 build/$(BINARY_NAME)
cd build; tar -cvzf ../$(BINARY_NAME)_$(GITREV)_linux_amd64.tar.gz *
rm build/$(BINARY_NAME)
$(MAKE) build-darwin
cp cmd/writefreely/$(BINARY_NAME) build
mv build/$(BINARY_NAME)-darwin-10.6-amd64 build/$(BINARY_NAME)
cd build; tar -cvzf ../$(BINARY_NAME)_$(GITREV)_darwin_amd64.tar.gz *
rm build/$(BINARY_NAME)
$(MAKE) build-windows
cp cmd/writefreely/$(BINARY_NAME).exe build
mv build/$(BINARY_NAME)-windows-4.0-amd64.exe build/$(BINARY_NAME).exe
cd build; zip -r ../$(BINARY_NAME)_$(GITREV)_windows_amd64.zip ./*
$(MAKE) build-docker
$(MAKE) release-docker