-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
67 lines (54 loc) · 2.13 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
.PHONY: clean build test test_new list all
.ONESHELL:
# Inject into binary via linker:
# ...in github actions comes from make -e version=git_ref
version=$(shell cat VERSION)
commit=$(shell git show --no-patch --format=format:%H HEAD)
buildVersionVar=github.com/CLIP-HPC/SlurmCommander/internal/version.BuildVersion
buildCommitVar=github.com/CLIP-HPC/SlurmCommander/internal/version.BuildCommit
# various directories
bindirs=$(wildcard ./cmd/*)
installdir=build/slurmcommander-$(version)
# list of files to include in build
bins=$(notdir $(bindirs))
readme=README.md
templates=
config=./cmd/scom/scom.conf
# can be replaced with go test ./... construct
testdirs=$(sort $(dir $(shell find ./ -name *_test.go)))
all: list test build install
list:
@echo "================================================================================"
@echo "bindirs found: $(bindirs)"
@echo "bins found: $(bins)"
@echo "testdirs found: $(testdirs)"
@echo "================================================================================"
build:
@echo "********************************************************************************"
@echo Building $(bindirs)
@echo Variables:
@echo buildVersionVar: $(buildVersionVar)
@echo version: $(version)
@echo buildCommitVar: $(buildCommitVar)
@echo commit: $(commit)
@echo "********************************************************************************"
for i in $(bindirs);
do
echo "................................................................................"
echo "--> Now building: $$i"
echo "................................................................................"
go build -v -ldflags '-X $(buildVersionVar)=$(version) -X $(buildCommitVar)=$(commit)' $$i;
done;
install:
mkdir -p $(installdir)
cp $(bins) $(readme) $(config) $(installdir)
test_new:
$(foreach dir, $(testdirs), go test -v -count=1 $(dir) || exit $$?;)
test:
@echo "********************************************************************************"
@echo Testing
@echo "********************************************************************************"
go test -v -cover -count=1 ./...
clean:
rm $(bins)
rm -rf $(installdir)