Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 16 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)
BUILDSTAMP = $(shell date -u '+%Y-%m-%dT%T%z')

Expand All @@ -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")

export GO111MODULE=on

all: build

$(DIST_SRC):
mkdir -p $@

dist_gopath: $(DIST_SRC)
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
generate: mods client/bindata.go

godeps:
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/rogpeppe/godeps; fi
client/bindata.go: bin/go-bindata
bin/go-bindata -prefix "client/static/" -pkg client -o client/bindata.go client/static/...

goget: godeps
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/godeps -u dependencies.tsv; fi
mkdir -p $(shell dirname "$(CURDIR)/vendor/src/$(GOPKG)")
rm -f $(CURDIR)/vendor/src/$(GOPKG)
ln -sf $(PWD) $(CURDIR)/vendor/src/$(GOPKG)
generate-dev: bin/go-bindata
bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/...

generate:
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/jteeuwen/go-bindata/...; fi
if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi
mods: go.mod go.sum
go mod download
go mod verify

generate-dev:
GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi
bin/go-bindata:
go build -v -o bin/go-bindata github.com/kevinburke/go-bindata/go-bindata

binary-%: generate
GOPATH=$(GOPATH) GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 \
binary-%: mods generate client/bindata.go
GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 \
go build \
-ldflags="-s -w \
-X main.Version=$(VERSION) \
Expand All @@ -53,7 +45,7 @@ binary-%: generate
binary: binary-$(GOARCH)
cp -va bin/realtimetrafficd_$(GOARCH) bin/realtimetrafficd

build: goget binary
build: binary

$(DIST)/realtimetrafficd-$(VERSION)_%: binary-$(GOARCH)
@mkdir -p $(DIST)
Expand All @@ -73,11 +65,4 @@ release: release-amd64 release-armhf release-arm64
format:
find $(FOLDERS) \( -name "*.go" ! -name "bindata.go" \) -print0 | xargs -0 -n 1 go fmt

dependencies.tsv: godeps
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
.PHONY: all client/bindata.go mods generate-dev binary build release
2 changes: 0 additions & 2 deletions dependencies.tsv

This file was deleted.

7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=