From 6938f80fea7b4227232f9c2f31826b005ca58f2c Mon Sep 17 00:00:00 2001 From: Oliver Steele Date: Tue, 20 Jun 2017 09:00:04 -0400 Subject: [PATCH] Add a Makefile --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 14 +++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61447da --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +SOURCEDIR=. +SOURCES := $(shell find $(SOURCEDIR) -name '*.go') + +BINARY = gojekyll +PACKAGE = github.com/osteele/gojekyll +COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null` +BUILD_TIME = `date +%FT%T%z` + +VERSION=0.0.0 + +LDFLAGS=-ldflags "-X ${PACKAGE}.Version=${VERSION} -X ${PACKAGE}.BuildTime=${BUILD_TIME}" + +.DEFAULT_GOAL: $(BINARY) +.PHONY: build clean dependencies setup install lint test help + +$(BINARY): $(SOURCES) + go build ${LDFLAGS} -o ${BINARY} ${PACKAGE}/cmd/gojekyll + +build: $(BINARY) ## compile the package + +clean: ## remove binary files + rm -fI ${BINARY} + +dependencies: ## list dependencies + go list -f '{{ join .Imports "\n" }}' \ + | grep -v ${PACKAGE} \ + | grep '\.' + +setup: ## install dependencies and development tools + go get ./... + go get -u github.com/alecthomas/gometalinter + gometalinter --install + +install: ## compile and install the executable + go install ${LDFLAGS} ${PACKAGE}/cmd/gojekyll + +lint: ## lint the package + gometalinter ./... + +test: ## test the package + go test ${LDFLAGS} ./... + +# Source: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/README.md b/README.md index 29fda7f..7d1858d 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,19 @@ This is currently about 10x slower than using the embedded engine, but still 5x Neither the embedded Liquid server nor the Liquid Template Server implements very many Jekyll Liquid filters or tags. I'm adding to these as necessary to support my own sites. -## Development +## Develop + +Install package dependencies and development tools: ```bash +make setup +``` + +Test: + +```bash +make test +make lint gojekyll render index.md # render a file to stdout gojekyll render / # render a URL to stdout gojekyll variables / # print a file or URL's variables @@ -108,6 +118,8 @@ go tool pprof gojekyll gojekyll.prof For rendering Liquid templates: ACS Technologies's fork [acstech/liquid](https://github.com/acstech/liquid) of Karl Seguin's [karlseguin/liquid](https://github.com/karlseguin/liquid) Go implementation; or, Jun Yang's JavaScript implementation [harttle/shopify-liquid](https://github.com/harttle/shopify-liquid/) via JSON-RPC. +Jascha Ephraim's [jaschaephraim/lrserver](https://github.com/jaschaephraim/lrserver) Live Reload server. + The gopher image in the test directory is from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Gophercolor.jpg). It is used under the [Creative Commons Attribution-Share Alike 3.0 Unported license](https://creativecommons.org/licenses/by-sa/3.0/deed.en). ## Related