-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
137 lines (121 loc) · 4.71 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
VERSION ?= v$(patsubst "%",%, $(word 3, $(shell grep version Cargo.toml)))
REPOSITORY := $(patsubst "%",%, $(word 3, $(shell grep repository Cargo.toml)))
GIT_REVISION := $(shell git rev-parse --short=8 HEAD)
DATE_ISO8601 := $(shell date +"%Y-%m-%d")
TIME_ISO8601 := $(shell date +"%H:%M:%S")
DATETIME_ISO8601 := ${DATE_ISO8601}T${TIME_ISO8601}
RUST_VERSION := $(word 2, $(shell rustc -V))
LONG_VERSION := ${VERSION} rev:${GIT_REVISION} rustc:${RUST_VERSION} built:${DATETIME_ISO8601}
BIN_NAME := svlint
export LONG_VERSION
.PHONY: all test clean release_lnx release_win release_mac
all: test
test:
cargo test
watch:
cargo watch test
clean:
cargo clean
# Flags used by both development and release versions of PDF.
# NOTE: If you change these, be sure to reflect the changes in the release and
# mdgen workflow files too.
PANDOC_FLAGS := -f markdown+lists_without_preceding_blankline
PANDOC_FLAGS += --template=md/MANUAL_template.tex
PANDOC_FLAGS += --metadata "title=Svlint Manual"
PANDOC_FLAGS += --metadata "author=${REPOSITORY}"
PANDOC_FLAGS += --metadata "keywords=SystemVerilog"
PANDOC_FLAGS += --metadata "keywords=Verilog"
PANDOC_FLAGS += --metadata "keywords=IEEE1800-2017"
PANDOC_FLAGS += --metadata "keywords=lint"
PANDOC_FLAGS += --metadata "keywords=svlint"
PANDOC_FLAGS += --metadata "keywords=sv-parser"
PANDOC_FLAGS += --metadata "keywords=svls"
PANDOC_FLAGS += --toc
PANDOC_FLAGS += --toc-depth=2
PANDOC_FLAGS += --variable=colorlinks
PANDOC_FLAGS += --variable=papersize:a4
# Minor tweaks for nicer formatting of PDF.
# - Begin each rule,ruleset description on a new page.
# - Compact form for rule's hint and reason.
MANUAL.intermediateTex.md:
sed \
-e 's/^## Syntax Rule: /\\clearpage\n## Syntax Rule: /' \
-e 's/^## Ruleset: /\\clearpage\n## Ruleset: /' \
-e '/^### Hint$$/{$$!{N;N;s/### Hint\n\n/Hint\n: /;t;P;D}}' \
-e '/^### Reason$$/{$$!{N;N;s/### Reason\n\n/Reason\n: /;t;P;D}}' \
MANUAL.md > $@
# Convenience recipe for building development version of PDF manual.
# This is normally handled by the GitHub Action `.github/workflows/mdgen.yml`
# which runs on pushes and pull requests, and does NOT use this recipe.
.PHONY: MANUAL-dev
MANUAL-dev: MANUAL.intermediateTex.md
@pandoc --version
pandoc -i MANUAL.intermediateTex.md \
${PANDOC_FLAGS} \
--metadata "subtitle=DEVELOPMENT ${GIT_REVISION}" \
--metadata "date=${DATETIME_ISO8601}" \
-o MANUAL-dev.pdf
rm -f *.intermediate*.*
# Convenience recipe for building release version of PDF manual.
# This is normally handled by the GitHub Action `.github/workflows/release.yml`
# which runs when a new tag `v*.*.*` is pushed, and does NOT use this recipe.
.PHONY: MANUAL-release
MANUAL-release: MANUAL.intermediateTex.md
pandoc -i MANUAL.intermediateTex.md \
${PANDOC_FLAGS} \
--metadata "subtitle=${VERSION}" \
--metadata "date=${DATE_ISO8601}" \
-o MANUAL-release.pdf
rm -f *.intermediate*.*
# The `release` action should create a file of this name and upload it as an
# artifact in a prerequisite job before the parallel jobs (Linux, Windows,
# MacOS) download the artifact, build executables, and create GitHub releases.
RELEASE_MANUAL := pdf/svlint_MANUAL_${VERSION}.pdf
release_lnx:
cargo build --release --target=x86_64-unknown-linux-musl
rm -rf tmp
mkdir -p tmp/bin/ tmp/doc/
cp ${RELEASE_MANUAL} tmp/doc/
cp rulesets/*.toml tmp/bin/
cp $$(find rulesets/ -type f -perm -u+x) tmp/bin/
cp target/x86_64-unknown-linux-musl/release/${BIN_NAME} tmp/bin/
cd tmp/ && \
zip ${BIN_NAME}-${VERSION}-x86_64-lnx.zip -r *
mv tmp/${BIN_NAME}-${VERSION}-x86_64-lnx.zip ./
rm -rf tmp/
release_win:
cargo build --release --target=x86_64-pc-windows-msvc
rm -rf tmp
mkdir -p tmp/bin/ tmp/doc/
cp ${RELEASE_MANUAL} tmp/doc/
cp rulesets/*.toml tmp/bin/
cp rulesets/*.cmd tmp/bin/
cp target/x86_64-pc-windows-msvc/release/${BIN_NAME}.exe tmp/bin/
cd tmp && \
7z a ${BIN_NAME}-${VERSION}-x86_64-win.zip *
mv tmp/${BIN_NAME}-${VERSION}-x86_64-win.zip ./
rm -rf tmp/
release_mac_x86_64:
cargo build --release --target=x86_64-apple-darwin
rm -rf tmp
mkdir -p tmp/bin/ tmp/doc/
cp ${RELEASE_MANUAL} tmp/doc/
cp rulesets/*.toml tmp/bin/
cp $$(find rulesets/ -type f -perm -u+x) tmp/bin/
cp target/x86_64-apple-darwin/release/${BIN_NAME} tmp/bin/
cd tmp/ && \
zip ${BIN_NAME}-${VERSION}-x86_64-mac.zip -r *
mv tmp/${BIN_NAME}-${VERSION}-x86_64-mac.zip ./
rm -rf tmp/
release_mac_aarch64:
cargo build --release --target=aarch64-apple-darwin
rm -rf tmp
mkdir -p tmp/bin/ tmp/doc/
cp ${RELEASE_MANUAL} tmp/doc/
cp rulesets/*.toml tmp/bin/
cp $$(find rulesets/ -type f -perm -u+x) tmp/bin/
cp target/aarch64-apple-darwin/release/${BIN_NAME} tmp/bin/
cd tmp/ && \
zip ${BIN_NAME}-${VERSION}-aarch64-mac.zip -r *
mv tmp/${BIN_NAME}-${VERSION}-aarch64-mac.zip ./
rm -rf tmp/