mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
Add GOEXE to support building with different versions of go
Add a variable to the makefile and benchmark scripts to let users change the command used to build. Doesn't impact tools like govendor.
This commit is contained in:
parent
61bb3ccab3
commit
ea5e9e346c
3 changed files with 17 additions and 9 deletions
13
Makefile
13
Makefile
|
@ -6,21 +6,24 @@ BUILD_DATE = `date +%FT%T%z`
|
||||||
LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.CommitHash=${COMMIT_HASH} -X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
|
LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.CommitHash=${COMMIT_HASH} -X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
|
||||||
NOGI_LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
|
NOGI_LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
|
||||||
|
|
||||||
|
# allow user to override go executable by running as GOEXE=xxx make ... on unix-like systems
|
||||||
|
GOEXE ?= go
|
||||||
|
|
||||||
.PHONY: vendor docker check fmt lint test test-race vet test-cover-html help
|
.PHONY: vendor docker check fmt lint test test-race vet test-cover-html help
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
vendor: ## Install govendor and sync Hugo's vendored dependencies
|
vendor: ## Install govendor and sync Hugo's vendored dependencies
|
||||||
go get github.com/kardianos/govendor
|
${GOEXE} get github.com/kardianos/govendor
|
||||||
govendor sync ${PACKAGE}
|
govendor sync ${PACKAGE}
|
||||||
|
|
||||||
hugo: vendor ## Build hugo binary
|
hugo: vendor ## Build hugo binary
|
||||||
go build ${LDFLAGS} ${PACKAGE}
|
${GOEXE} build ${LDFLAGS} ${PACKAGE}
|
||||||
|
|
||||||
hugo-race: vendor ## Build hugo binary with race detector enabled
|
hugo-race: vendor ## Build hugo binary with race detector enabled
|
||||||
go build -race ${LDFLAGS} ${PACKAGE}
|
${GOEXE} build -race ${LDFLAGS} ${PACKAGE}
|
||||||
|
|
||||||
install: vendor ## Install hugo binary
|
install: vendor ## Install hugo binary
|
||||||
go install ${LDFLAGS} ${PACKAGE}
|
${GOEXE} install ${LDFLAGS} ${PACKAGE}
|
||||||
|
|
||||||
hugo-no-gitinfo: LDFLAGS = ${NOGI_LDFLAGS}
|
hugo-no-gitinfo: LDFLAGS = ${NOGI_LDFLAGS}
|
||||||
hugo-no-gitinfo: vendor hugo ## Build hugo without git info
|
hugo-no-gitinfo: vendor hugo ## Build hugo without git info
|
||||||
|
@ -74,7 +77,7 @@ test-cover-html: ## Generate test coverage report
|
||||||
$(foreach pkg,$(PACKAGES),\
|
$(foreach pkg,$(PACKAGES),\
|
||||||
govendor test -coverprofile=coverage.out -covermode=count $(pkg);\
|
govendor test -coverprofile=coverage.out -covermode=count $(pkg);\
|
||||||
tail -n +2 coverage.out >> coverage-all.out;)
|
tail -n +2 coverage.out >> coverage-all.out;)
|
||||||
go tool cover -html=coverage-all.out
|
${GOEXE} tool cover -html=coverage-all.out
|
||||||
|
|
||||||
check-vendor: ## Verify that vendored packages match git HEAD
|
check-vendor: ## Verify that vendored packages match git HEAD
|
||||||
@git diff-index --quiet HEAD vendor/ || (echo "check-vendor target failed: vendored packages out of sync" && echo && git diff vendor/ && exit 1)
|
@git diff-index --quiet HEAD vendor/ || (echo "check-vendor target failed: vendored packages out of sync" && echo && git diff vendor/ && exit 1)
|
||||||
|
|
8
bench.sh
8
bench.sh
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# allow user to override go executable by running as GOEXE=xxx make ...
|
||||||
|
GOEXE="${GOEXE-go}"
|
||||||
|
|
||||||
# Convenience script to
|
# Convenience script to
|
||||||
# - For a given branch
|
# - For a given branch
|
||||||
|
@ -26,10 +28,10 @@ BRANCH=$1
|
||||||
PACKAGE=$2
|
PACKAGE=$2
|
||||||
|
|
||||||
git checkout $BRANCH
|
git checkout $BRANCH
|
||||||
go test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-$BRANCH.txt
|
"${GOEXE}" test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-$BRANCH.txt
|
||||||
|
|
||||||
git checkout master
|
git checkout master
|
||||||
go test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-master.txt
|
"${GOEXE}" test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-master.txt
|
||||||
|
|
||||||
|
|
||||||
benchcmp /tmp/bench-$PACKAGE-master.txt /tmp/bench-$PACKAGE-$BRANCH.txt
|
benchcmp /tmp/bench-$PACKAGE-master.txt /tmp/bench-$PACKAGE-$BRANCH.txt
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# allow user to override go executable by running as GOEXE=xxx make ...
|
||||||
|
GOEXE="${GOEXE-go}"
|
||||||
|
|
||||||
# Send in a regexp mathing the benchmarks you want to run, i.e. './benchSite.sh "YAML"'.
|
# Send in a regexp mathing the benchmarks you want to run, i.e. './benchSite.sh "YAML"'.
|
||||||
# Note the quotes, which will be needed for more complex expressions.
|
# Note the quotes, which will be needed for more complex expressions.
|
||||||
# The above will run all variations, but only for front matter YAML.
|
# The above will run all variations, but only for front matter YAML.
|
||||||
|
|
||||||
echo "Running with BenchmarkSiteBuilding/${1}"
|
echo "Running with BenchmarkSiteBuilding/${1}"
|
||||||
|
|
||||||
go test -run="NONE" -bench="BenchmarkSiteBuilding/${1}$" -test.benchmem=true ./hugolib -memprofile mem.prof -cpuprofile cpu.prof
|
"${GOEXE}" test -run="NONE" -bench="BenchmarkSiteBuilding/${1}$" -test.benchmem=true ./hugolib -memprofile mem.prof -cpuprofile cpu.prof
|
||||||
|
|
Loading…
Reference in a new issue