Skip to content

Commit

Permalink
[build] Uses glide to manage vendor packages
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyanliu authored and xxx7xxxx committed Oct 10, 2017
1 parent 4fcfbce commit 8f597d5
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ _testmain.go
# Additional
.env
build
_vendor
vendor
glide.lock
src/vendor
rootfs/alpine/opt
rootfs/ubuntu/opt

Expand Down
56 changes: 23 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.PHONY: default build build_client build_server build_inventory \
run fmt vendor_clean vendor_get vendor_update clean \
build_client_alpine build_server_alpine \
build_server_ubuntu
.PHONY: default build build_client build_server build_inventory run fmt clean \
depend vendor_get vendor_update vendor_clean \
build_client_alpine build_server_alpine build_server_ubuntu

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))

GOPATH := ${MKFILE_DIR}_vendor:${MKFILE_DIR}
GOPATH := ${MKFILE_DIR}
export GOPATH

RELEASE?=0.1.0
Expand All @@ -19,6 +18,8 @@ endif

DOCKER?=docker

GLIDE=${MKFILE_DIR}build/bin/glide

GATEWAY_ALL_SRC_FILES = $(shell find ${MKFILE_DIR}src -type f -name "*.go")
GATEWAY_CLIENT_SRC_FILES = $(shell find ${MKFILE_DIR}src/cli ${MKFILE_DIR}src/client -type f -name "*.go")
GATEWAY_SERVER_SRC_FILES = $(filter-out ${GATEWAY_CLIENT_SRC_FILES},${GATEWAY_ALL_SRC_FILES})
Expand Down Expand Up @@ -57,41 +58,30 @@ build_server: ${TARGET_GATEWAY_SERVER}

build_inventory: ${TARGET_INVENTORY}

clean:
@rm -rf ${MKFILE_DIR}build && rm -rf ${MKFILE_DIR}rootfs/alpine/opt && rm -rf ${MKFILE_DIR}rootfs/ubuntu/opt

run: build_server
${TARGET_GATEWAY_SERVER} -host=localhost -certfile=localhost-cert.pem -keyfile=localhost-key.pem

fmt:
cd ${MKFILE_DIR} && go fmt ./src/...

vendor_clean:
rm -dRf ${MKFILE_DIR}_vendor/src

vendor_get:
GOPATH=${MKFILE_DIR}_vendor go get -d -u -v \
github.com/sirupsen/logrus \
github.com/Shopify/sarama \
github.com/bsm/sarama-cluster \
github.com/xeipuuv/gojsonschema \
github.com/ant0ine/go-json-rest/rest \
github.com/rcrowley/go-metrics \
golang.org/x/time/rate \
github.com/urfave/cli \
github.com/hashicorp/memberlist \
github.com/dgraph-io/badger \
github.com/ugorji/go/codec \
github.com/hashicorp/logutils \
github.com/ghodss/yaml \
github.com/hexdecteam/easegateway-types/... \
github.com/hexdecteam/easegateway-go-client/...

vendor_update: vendor_get
cd ${MKFILE_DIR} && rm -rf `find ./_vendor/src -type d -name .git` \
&& rm -rf `find ./_vendor/src -type d -name .hg` \
&& rm -rf `find ./_vendor/src -type d -name .bzr` \
&& rm -rf `find ./_vendor/src -type d -name .svn`
depend:
GOPATH=${MKFILE_DIR}build go get -v github.com/Masterminds/glide

clean:
@rm -rf ${MKFILE_DIR}build && rm -rf ${MKFILE_DIR}rootfs/alpine/opt && rm -rf ${MKFILE_DIR}rootfs/ubuntu/opt
vendor_get: depend
${GLIDE} install
rm -rf ${MKFILE_DIR}src/vendor ${GLIDE} ${MKFILE_DIR}build/pkg ${MKFILE_DIR}build/src
ln -s ${MKFILE_DIR}vendor ${MKFILE_DIR}src/vendor

vendor_update: depend
${GLIDE} update && ${GLIDE} install
rm -rf ${MKFILE_DIR}src/vendor ${GLIDE} ${MKFILE_DIR}build/pkg ${MKFILE_DIR}build/src
ln -s ${MKFILE_DIR}vendor ${MKFILE_DIR}src/vendor

vendor_clean:
rm -dRf ${MKFILE_DIR}src/vendor ${MKFILE_DIR}vendor

build_client_alpine: ${TARGET_GATEWAY_CLIENT} ${TARGET_INVENTORY}
@echo "-------------- building gateway client docker image (from alpine) ---------------"
Expand Down
53 changes: 53 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package: .
ignore:
# https://github.com/Masterminds/glide/issues/662
# https://github.com/Masterminds/glide/issues/862
- cli
- cluster
- common
- config
- engine
- logger
- model
- option
- pipelines
- plugins
- plugins/easemonitor
- plugins/easenight/manifest
- plugins/easenight/common
- plugins/easenight/domain
- rest
- version
import:
- package: github.com/sirupsen/logrus
- package: github.com/Shopify/sarama
- package: github.com/xeipuuv/gojsonschema
- package: github.com/ant0ine/go-json-rest
subpackages:
- rest
- package: github.com/rcrowley/go-metrics
- package: golang.org/x/time/rate
- package: github.com/urfave/cli
- package: github.com/hashicorp/memberlist
- package: github.com/dgraph-io/badger
- package: github.com/ugorji/go
subpackages:
- codec
- package: github.com/hashicorp/logutils
- package: github.com/ghodss/yaml

- package: github.com/hexdecteam/easegateway-go-client
subpackages:
- rest/1.0/admin/v1
- rest/1.0/admin/v1/pdu
- rest/1.0/cluster/admin/v1
- rest/1.0/cluster/admin/v1/pdu
- rest/1.0/cluster/statistics/v1
- rest/1.0/cluster/statistics/v1/pdu
- rest/1.0/health/v1
- rest/1.0/statistics/v1
- package: github.com/hexdecteam/easegateway-types
subpackages:
- pipelines
- plugins
- task

0 comments on commit 8f597d5

Please sign in to comment.