Skip to content

Instantly share code, notes, and snippets.

Created March 2, 2017 16:26
Show Gist options
  • Save anonymous/287a5a027d78563b06def3feb1b933de to your computer and use it in GitHub Desktop.
Save anonymous/287a5a027d78563b06def3feb1b933de to your computer and use it in GitHub Desktop.
# build result
/bin
# bootstrap result
/bin/gb
/bin/gb-vendor
# build result
/bin/BINARY_NAME
# wrapper
/scripts/gb.sh
/src # golang source code
# golang source of executables
/src/cmd
# source code BINARY_NAME
# import ("libname")
# import ("github.com/A/B")
/src/cmd/BINARY_NAME/main.go
# source code of libname
src/libname
# vendor dependencies
/vendor/
# ./scipts/gb vendor fetch github.com/A/B
/vendor/src/github.com/A/B
# gb itself
/vendor/src/github.com/constabulary/gb
#!/bin/bash
export ROOT=$(dirname $(dirname ${BASH_SOURCE[0]}))
export PATH=${PATH}:${ROOT}/bin
cd ${ROOT}
make bin/gb
gb "$@"
GB := $(CURDIR)/scripts/gb.sh
GO_ENV := GOPATH=$(CURDIR):$(CURDIR)/vendor
# gb
vendor/bin/gb:
@echo "[bootstrap] $(@F)"
@mkdir -p "$(@D)"
@(cd $(CURDIR)/vendor/src/github.com/constabulary/gb && GOPATH=$(CURDIR)/vendor go install ./cmd/...)
bin/gb: vendor/bin/gb
@mkdir -p "$(@D)"
@cp $(CURDIR)/vendor/bin/gb $(CURDIR)/bin/gb
@cp $(CURDIR)/vendor/bin/gb-vendor $(CURDIR)/bin/gb-vendor
fmt:
@echo "[go] fmt"
@gofmt -l -s -w -- src
vet:
@echo "[go] vet"
@(cd $(CURDIR) && $(GO_ENV) go vet ./src/cmd/... ./src/lib/...)
build: bin/gb fmt vet
@echo "[build] golang"
@(cd $(CURDIR) && $(GB) build ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment