Skip to content

Commit

Permalink
Merge pull request #220 from akutz/feature/build-enhancements
Browse files Browse the repository at this point in the history
GOPATH/bin, Gometalinter, Glide Install
  • Loading branch information
akutz authored Jul 8, 2016
2 parents c0d38b0 + 3f6899b commit a658360
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 12 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ before_install:
- git config --global 'url.https://gopkg.in/fsnotify.v1.insteadof' 'https://gopkg.in/fsnotify.v1/'
- git config --global 'url.https://github.com/.insteadof' 'git://github.com/'
- git config --global 'url.https://github.com/.insteadof' '[email protected]:'
install:
- go get github.com/Masterminds/glide
- go get github.com/onsi/gomega
- go get github.com/onsi/ginkgo
- go get golang.org/x/tools/cmd/cover
- make deps
before_script:
- rm -f $GOPATH/bin/libstor-c
- rm -f $GOPATH/bin/libstor-s
- rm -f $GOPATH/bin/lsx-linux
- rm -f $GOPATH/bin/darwin_amd64/lsx-darwin
script:
- make version
- make -j deps
- make gometalinter-all
- make -j build
- make -j test
after_success:
- make -j cover
cache:
directories:
- vendor
- $GOPATH/bin
addons:
apt:
sources:
Expand Down
88 changes: 80 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ all:
$(MAKE) deps
$(MAKE) build


################################################################################
## CONSTANTS ##
################################################################################
Expand Down Expand Up @@ -45,6 +46,22 @@ GO_STDLIB := archive archive/tar archive/zip bufio builtin bytes compress \
unicode/utf16 unicode/utf8 unsafe


################################################################################
## SYSTEM INFO ##
################################################################################

GOPATH := $(shell go env | grep GOPATH | sed 's/GOPATH="\(.*\)"/\1/')
GOHOSTOS := $(shell go env | grep GOHOSTOS | sed 's/GOHOSTOS="\(.*\)"/\1/')
GOHOSTARCH := $(shell go env | grep GOHOSTARCH | sed 's/GOHOSTARCH="\(.*\)"/\1/')


################################################################################
## PATH ##
################################################################################
PATH := $(GOPATH)/bin:$(PATH)
export $(PATH)


################################################################################
## PROJECT INFO ##
################################################################################
Expand All @@ -64,6 +81,7 @@ ifneq (,$(strip $(findstring vendor,$(ROOT_IMPORT_PATH))))
VENDORED := 1
endif


################################################################################
## OS/ARCH INFO ##
################################################################################
Expand All @@ -86,12 +104,6 @@ endif
export OS
export ARCH

ifeq ($(OS),Linux)
NUMPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS),Darwin)
NUMPROCS := $(shell sysctl hw.logicalcpu | awk '{print $$2}')
endif # $(OS)


################################################################################
## MAKE FLAGS ##
Expand Down Expand Up @@ -209,6 +221,7 @@ $(foreach i,\
$(IMPORT_PATH_INFO),\
$(eval $(call IMPORT_PATH_PREPROCS_DEF,$(subst $(ROOT_DIR),.,$(word 3,$(subst ;, ,$(i)))),$(i))))


################################################################################
## INFO ##
################################################################################
Expand All @@ -217,6 +230,9 @@ info:
$(info Project Name................$(ROOT_IMPORT_NAME))
$(info OS / Arch...................$(GOOS)_$(GOARCH))
$(info Vendored....................$(VENDORED))
$(info GOPATH......................$(GOPATH))
$(info GOHOSTOS....................$(GOHOSTOS))
$(info GOHOSTARCH..................$(GOHOSTARCH))
ifneq (,$(strip $(SRCS)))
$(info Sources.....................$(patsubst ./%,%,$(firstword $(SRCS))))
$(foreach s,$(patsubst ./%,%,$(wordlist 2,$(words $(SRCS)),$(SRCS))),\
Expand All @@ -238,12 +254,14 @@ ifneq (,$(strip $(TEST_EXT_DEPS_SRCS)))
$(info $(5S)$(5S)$(5S)$(5S)$(5S)$(SPACE)$(SPACE)$(SPACE)$(s)))
endif


################################################################################
## DEPENDENCIES ##
################################################################################
GO_BINDATA := $(GOPATH)/bin/go-bindata
go-bindata: $(GO_BINDATA)

GLIDE := $(GOPATH)/bin/glide
GOGET_LOCK := goget.lock
GLIDE_LOCK := glide.lock
GLIDE_YAML := glide.yaml
Expand All @@ -257,11 +275,16 @@ ALL_EXT_DEPS := $(sort $(EXT_DEPS) $(TEST_EXT_DEPS))
ALL_EXT_DEPS_SRCS := $(sort $(EXT_DEPS_SRCS) $(TEST_EXT_DEPS_SRCS))

ifneq (1,$(VENDORED))
$(GLIDE):
go get -u github.com/Masterminds/glide
glide: $(GLIDE)
GO_DEPS += $(GLIDE)

GO_DEPS += $(GLIDE_LOCK_D)
$(ALL_EXT_DEPS_SRCS): $(GLIDE_LOCK_D)

$(GLIDE_LOCK_D): $(GLIDE_LOCK)
glide up && touch $@
$(GLIDE_LOCK_D): $(GLIDE_LOCK) | $(GLIDE)
$(GLIDE) install && touch $@

$(GLIDE_LOCK): $(GLIDE_YAML)
touch $@
Expand All @@ -287,6 +310,50 @@ $(GO_BINDATA):
@touch $@
GO_DEPS += $(GO_BINDATA)


################################################################################
## GOMETALINTER ##
################################################################################
GOMETALINTER := $(GOPATH)/bin/gometalinter

$(GOMETALINTER): | $(GOMETALINTER_TOOLS)
go get -u github.com/alecthomas/gometalinter
gometalinter: $(GOMETALINTER)
GO_DEPS += $(GOMETALINTER)

GOMETALINTER_TOOLS_D := .gometalinter.tools.d
$(GOMETALINTER_TOOLS_D): $(GOMETALINTER)
$(GOMETALINTER) --install --update && touch $@
GO_DEPS += $(GOMETALINTER_TOOLS_D)

GOMETALINTER_ARGS := --vendor \
--fast \
--tests \
--cyclo-over=16 \
--deadline=30s \
--enable=gofmt \
--enable=goimports \
--enable=misspell \
--enable=lll \
--disable=gotype \
--severity=gofmt:error \
--severity=goimports:error \
--exclude=_generated.go \
--linter='gofmt:gofmt -l ./*.go:^(?P<path>[^\n]+)$''

gometalinter-warn: | $(GOMETALINTER_TOOLS_D) $(GLIDE)
-$(GOMETALINTER) $(GOMETALINTER_ARGS) $(shell $(GLIDE) nv)

gometalinter-error: | $(GOMETALINTER_TOOLS_D) $(GLIDE)
$(GOMETALINTER) $(GOMETALINTER_ARGS) --errors $(shell $(GLIDE) nv)

gometalinter-all:
ifeq (1,$(GOMETALINTER_WARN_ENABLED))
$(MAKE) gometalinter-warn
endif
$(MAKE) gometalinter-error


################################################################################
## VERSION ##
################################################################################
Expand Down Expand Up @@ -418,6 +485,7 @@ version:

GO_PHONY += version


################################################################################
## PROJECT BUILD ##
################################################################################
Expand Down Expand Up @@ -454,6 +522,7 @@ GO_CLEAN += $$(PKG_A_$1)-clean
endif
endif


################################################################################
## PROJECT TESTS ##
################################################################################
Expand Down Expand Up @@ -508,6 +577,7 @@ $(foreach i,\
$(IMPORT_PATH_INFO),\
$(eval $(call IMPORT_PATH_BUILD_DEF,$(subst $(ROOT_DIR),.,$(word 3,$(subst ;, ,$(i)))),$(i))))


################################################################################
## SCHEMA ##
################################################################################
Expand All @@ -524,6 +594,7 @@ $(LIBSTORAGE_SCHEMA_GENERATED): $(LIBSTORAGE_JSON)
sed -e 's/^//' $< >>$@; \
printf "\`\n)\n" >>$@;


################################################################################
## EXECUTORS ##
################################################################################
Expand Down Expand Up @@ -570,6 +641,7 @@ GO_CLEAN += $(EXECUTORS_GENERATED)-clean

$(API_SERVER_EXECUTORS_A): $(EXECUTORS_GENERATED)


################################################################################
## C ##
################################################################################
Expand Down

0 comments on commit a658360

Please sign in to comment.