From 121f0dd605b5be31df310bf76615299b4e86372c Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 14 Dec 2017 16:13:18 +0100 Subject: Add make task to cross-compile for linux --- Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f32cd684f..7d224948e 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ export GITALY_TEST_RUBY_DIR := $(BUILD_DIR)/ruby BUILDTIME = $(shell date -u +%Y%m%d.%H%M%S) VERSION_PREFIXED = $(shell git describe) VERSION = $(VERSION_PREFIXED:v%=%) -GO_LDFLAGS = -ldflags '-X $(PKG)/internal/version.version=$(VERSION) -X $(PKG)/internal/version.buildtime=$(BUILDTIME)' +GOVERSION = $(shell go version | awk '{print $$3}') +GO_LDFLAGS = -ldflags '-X $(PKG)/internal/version.version=$(VERSION)-$(GOVERSION) -X $(PKG)/internal/version.buildtime=$(BUILDTIME)' unexport GOROOT unexport GOBIN @@ -54,6 +55,17 @@ build: .ruby-bundle $(TARGET_SETUP) go install $(GO_LDFLAGS) $(COMMAND_PACKAGES) cp $(foreach cmd,$(COMMANDS),$(BIN_BUILD_DIR)/$(cmd)) $(BUILD_DIR)/ +# TODO make this less of a hack +CUSTOM_NAME = gitaly-$(VERSION)-$(GOVERSION) +CUSTOM_DIR = opt/$(CUSTOM_NAME) +custom-linux-go-binary: $(TARGET_SETUP) + GOOS=linux GOARCH=amd64 go install $(GO_LDFLAGS) $(COMMAND_PACKAGES) + rm -rf _build/tmp + mkdir -p _build/tmp/$(CUSTOM_DIR) + cp $(BIN_BUILD_DIR)/linux_amd64/gitaly _build/tmp/$(CUSTOM_DIR) + tar -C _build/tmp -czf $(CUSTOM_NAME).tar.gz $(CUSTOM_DIR) + shasum -a256 *.tar.gz + .ruby-bundle: ruby/Gemfile.lock ruby/Gemfile if test -z "${BUNDLE_PATH}" ; then cd ruby && bundle config --local path vendor/bundle; fi cd ruby && bundle install -- cgit v1.2.3