Use Go 1.11 mod support instead of self made Makefile based vendoring

This commit is contained in:
Simon Eisenmann 2018-10-27 15:52:02 +02:00
parent c3a69d62ae
commit ef81def5c5
4 changed files with 29 additions and 33 deletions

View file

@ -3,9 +3,6 @@ PWD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
UPX ?= $(shell command -v upx 2>/dev/null) # Make sure it is uxp 3.94 or higher (https://github.com/upx/upx/releases) UPX ?= $(shell command -v upx 2>/dev/null) # Make sure it is uxp 3.94 or higher (https://github.com/upx/upx/releases)
GOARCH ?= $(shell go env GOARCH) GOARCH ?= $(shell go env GOARCH)
GOPKG = github.com/longsleep/realtimetraffic
GOPATH = "$(CURDIR)/vendor:$(CURDIR)"
SYSTEM_GOPATH = /usr/share/gocode/src/
VERSION = $(shell git describe --tags --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo git) VERSION = $(shell git describe --tags --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo git)
BUILDSTAMP = $(shell date -u '+%Y-%m-%dT%T%z') BUILDSTAMP = $(shell date -u '+%Y-%m-%dT%T%z')
@ -14,35 +11,30 @@ DIST_SRC := $(DIST)/src
FOLDERS = $(shell find -mindepth 1 -maxdepth 1 -type d -not -path "*.git" -not -path "*debian" -not -path "*vendor" -not -path "*doc" -not -path "*bin") FOLDERS = $(shell find -mindepth 1 -maxdepth 1 -type d -not -path "*.git" -not -path "*debian" -not -path "*vendor" -not -path "*doc" -not -path "*bin")
export GO111MODULE=on
all: build all: build
$(DIST_SRC): $(DIST_SRC):
mkdir -p $@ mkdir -p $@
dist_gopath: $(DIST_SRC) generate: mods client/bindata.go
if [ -d "$(SYSTEM_GOPATH)" ]; then find $(SYSTEM_GOPATH) -mindepth 1 -maxdepth 1 -type d \
-exec ln -sf {} $(DIST_SRC) \; ; fi
if [ ! -d "$(SYSTEM_GOPATH)" ]; then find $(CURDIR)/vendor/src -mindepth 1 -maxdepth 1 -type d \
-exec ln -sf {} $(DIST_SRC) \; ; fi
godeps: client/bindata.go: bin/go-bindata
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/rogpeppe/godeps; fi bin/go-bindata -prefix "client/static/" -pkg client -o client/bindata.go client/static/...
goget: godeps generate-dev: bin/go-bindata
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/godeps -u dependencies.tsv; fi bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/...
mkdir -p $(shell dirname "$(CURDIR)/vendor/src/$(GOPKG)")
rm -f $(CURDIR)/vendor/src/$(GOPKG)
ln -sf $(PWD) $(CURDIR)/vendor/src/$(GOPKG)
generate: mods: go.mod go.sum
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/jteeuwen/go-bindata/...; fi go mod download
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi go mod verify
generate-dev: bin/go-bindata:
GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi go build -v -o bin/go-bindata github.com/kevinburke/go-bindata/go-bindata
binary-%: generate binary-%: mods generate client/bindata.go
GOPATH=$(GOPATH) GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 \ GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 \
go build \ go build \
-ldflags="-s -w \ -ldflags="-s -w \
-X main.Version=$(VERSION) \ -X main.Version=$(VERSION) \
@ -53,7 +45,7 @@ binary-%: generate
binary: binary-$(GOARCH) binary: binary-$(GOARCH)
cp -va bin/realtimetrafficd_$(GOARCH) bin/realtimetrafficd cp -va bin/realtimetrafficd_$(GOARCH) bin/realtimetrafficd
build: goget binary build: binary
$(DIST)/realtimetrafficd-$(VERSION)_%: binary-$(GOARCH) $(DIST)/realtimetrafficd-$(VERSION)_%: binary-$(GOARCH)
@mkdir -p $(DIST) @mkdir -p $(DIST)
@ -73,11 +65,4 @@ release: release-amd64 release-armhf release-arm64
format: format:
find $(FOLDERS) \( -name "*.go" ! -name "bindata.go" \) -print0 | xargs -0 -n 1 go fmt find $(FOLDERS) \( -name "*.go" ! -name "bindata.go" \) -print0 | xargs -0 -n 1 go fmt
dependencies.tsv: godeps .PHONY: all client/bindata.go mods generate-dev binary build release
set -e ;\
TMP=$$(mktemp -d) ;\
cp -r $(CURDIR)/vendor $$TMP ;\
GOPATH=$$TMP/vendor:$(CURDIR) $(CURDIR)/vendor/bin/godeps $(GOPKG)/realtimetrafficd > $(CURDIR)/dependencies.tsv ;\
rm -rf $$TMP ;\
.PHONY: all dist_gopath godeps goget generate generate-dev binary dependencies.tsv build release

View file

@ -1,2 +0,0 @@
github.com/elazarl/go-bindata-assetfs git 30f82fa23fd844bd5bb1e5f216db87fd77b5eb43 2017-02-27T21:27:28Z
github.com/gorilla/websocket git 119002ce0495aa7a8f388544d740e1bdc8829513 2014-02-18T05:22:10Z
1 github.com/elazarl/go-bindata-assetfs git 30f82fa23fd844bd5bb1e5f216db87fd77b5eb43 2017-02-27T21:27:28Z
2 github.com/gorilla/websocket git 119002ce0495aa7a8f388544d740e1bdc8829513 2014-02-18T05:22:10Z

7
go.mod Normal file
View file

@ -0,0 +1,7 @@
module github.com/longsleep/realtimetraffic
require (
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/gorilla/websocket v0.0.0-20140218052210-119002ce0495
github.com/kevinburke/go-bindata v3.11.0+incompatible // indirect
)

6
go.sum Normal file
View file

@ -0,0 +1,6 @@
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/gorilla/websocket v0.0.0-20140218052210-119002ce0495 h1:RNs7p7jyGHgTpOAgO0ZdhQRgucB1WO2BHmFGMOhQzyk=
github.com/gorilla/websocket v0.0.0-20140218052210-119002ce0495/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/kevinburke/go-bindata v3.11.0+incompatible h1:GiPs9jxaG2xY1B5Dt/d/yHUOMlTk14uS35VcmHrdo4I=
github.com/kevinburke/go-bindata v3.11.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=