Skip to content

Commit ea5e9e3

Browse files
mdhenderbep
authored andcommitted
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.
1 parent 61bb3cc commit ea5e9e3

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ BUILD_DATE = `date +%FT%T%z`
66
LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.CommitHash=${COMMIT_HASH} -X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
77
NOGI_LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
88

9+
# allow user to override go executable by running as GOEXE=xxx make ... on unix-like systems
10+
GOEXE ?= go
11+
912
.PHONY: vendor docker check fmt lint test test-race vet test-cover-html help
1013
.DEFAULT_GOAL := help
1114

1215
vendor: ## Install govendor and sync Hugo's vendored dependencies
13-
go get github.com/kardianos/govendor
16+
${GOEXE} get github.com/kardianos/govendor
1417
govendor sync ${PACKAGE}
1518

1619
hugo: vendor ## Build hugo binary
17-
go build ${LDFLAGS} ${PACKAGE}
20+
${GOEXE} build ${LDFLAGS} ${PACKAGE}
1821

1922
hugo-race: vendor ## Build hugo binary with race detector enabled
20-
go build -race ${LDFLAGS} ${PACKAGE}
23+
${GOEXE} build -race ${LDFLAGS} ${PACKAGE}
2124

2225
install: vendor ## Install hugo binary
23-
go install ${LDFLAGS} ${PACKAGE}
26+
${GOEXE} install ${LDFLAGS} ${PACKAGE}
2427

2528
hugo-no-gitinfo: LDFLAGS = ${NOGI_LDFLAGS}
2629
hugo-no-gitinfo: vendor hugo ## Build hugo without git info
@@ -74,7 +77,7 @@ test-cover-html: ## Generate test coverage report
7477
$(foreach pkg,$(PACKAGES),\
7578
govendor test -coverprofile=coverage.out -covermode=count $(pkg);\
7679
tail -n +2 coverage.out >> coverage-all.out;)
77-
go tool cover -html=coverage-all.out
80+
${GOEXE} tool cover -html=coverage-all.out
7881

7982
check-vendor: ## Verify that vendored packages match git HEAD
8083
@git diff-index --quiet HEAD vendor/ || (echo "check-vendor target failed: vendored packages out of sync" && echo && git diff vendor/ && exit 1)

bench.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
# allow user to override go executable by running as GOEXE=xxx make ...
4+
GOEXE="${GOEXE-go}"
35

46
# Convenience script to
57
# - For a given branch
@@ -26,10 +28,10 @@ BRANCH=$1
2628
PACKAGE=$2
2729

2830
git checkout $BRANCH
29-
go test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-$BRANCH.txt
31+
"${GOEXE}" test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-$BRANCH.txt
3032

3133
git checkout master
32-
go test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-master.txt
34+
"${GOEXE}" test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-master.txt
3335

3436

35-
benchcmp /tmp/bench-$PACKAGE-master.txt /tmp/bench-$PACKAGE-$BRANCH.txt
37+
benchcmp /tmp/bench-$PACKAGE-master.txt /tmp/bench-$PACKAGE-$BRANCH.txt

benchSite.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
22

3+
# allow user to override go executable by running as GOEXE=xxx make ...
4+
GOEXE="${GOEXE-go}"
5+
36
# Send in a regexp mathing the benchmarks you want to run, i.e. './benchSite.sh "YAML"'.
47
# Note the quotes, which will be needed for more complex expressions.
58
# The above will run all variations, but only for front matter YAML.
69

710
echo "Running with BenchmarkSiteBuilding/${1}"
811

9-
go test -run="NONE" -bench="BenchmarkSiteBuilding/${1}$" -test.benchmem=true ./hugolib -memprofile mem.prof -cpuprofile cpu.prof
12+
"${GOEXE}" test -run="NONE" -bench="BenchmarkSiteBuilding/${1}$" -test.benchmem=true ./hugolib -memprofile mem.prof -cpuprofile cpu.prof

0 commit comments

Comments
 (0)