-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
81 lines (60 loc) · 1.82 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := test
.DELETE_ON_ERROR:
.SUFFIXES:
# ---------------------
# Environment variables
# ---------------------
GOPATH := $(shell go env GOPATH)
# ------------------
# Internal variables
# ------------------
package_name := zbase32
test_args := -v
virtualenv_cmd := $(shell command -v virtualenv)
# -------------
# Files & paths
# -------------
makfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
makefile_dir := $(patsubst %/,%,$(dir $(makfile_path)))
venv_base_path := ${makefile_dir}/virtualenv
venv_check_path := ${venv_base_path}/ok
venv_bin_path := ${venv_base_path}/bin
venv_activation_path := ${venv_bin_path}/activate
venv_pip_path := ${venv_bin_path}/pip
fuzz_pkg_path := ${makefile_dir}/${package_name}-fuzz.zip
fuzz_work_dir := ${makefile_dir}/fuzz
# -------
# Targets
# -------
.PHONY: test
test:
@[[ -f ${venv_check_path} ]] && source ${venv_activation_path}; go test ${test_args} .
.PHONY: test-python
test-python: prepare_python
@[[ -f ${venv_check_path} ]] && source ${venv_activation_path}; go test ${test_args} -test.run=Python .
.PHONY: test-fuzz
test-fuzz: ${fuzz_pkg_path}
go-fuzz -bin=$< -workdir=${fuzz_work_dir}
install: ${GOPATH}/bin/${package_name}
${GOPATH}/bin/${package_name}: **/*.go
go build -i -o "${@}" ./cmd
ifdef virtualenv_cmd
test: prepare_python
endif
.PHONY: prepare_python
prepare_python: ${venv_check_path}
${venv_check_path}:
${virtualenv_cmd} virtualenv
${venv_pip_path} install zbase32
touch $@
${fuzz_pkg_path}: **/*.go
go-fuzz-build gopkg.in/corvus-ch/zbase32.v1
.PHONY: clean
clean:
rm -rf ${venv_base_path}
rm -rf ${fuzz_pkg_path} ${fuzz_work_dir}
# This Makefile tries to follow the principles describe at
# http://clarkgrubb.com/makefile-style-guide