-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphviz.mk
More file actions
107 lines (88 loc) · 4.34 KB
/
graphviz.mk
File metadata and controls
107 lines (88 loc) · 4.34 KB
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
SHELL := /bin/bash -euo pipefail
define GRAPHVIZ_HELP
REQUIREMENTS:
- graphviz : `graphviz` command must be available.
TARGETS:
- graphviz-help : Show help message.
- graphviz-png : Export png image from graphviz file.
- graphviz-svg : Export svg image from graphviz file.
- graphviz-pdf : Export pdf image from graphviz file.
VARIABLES [default value]:
- GRAPHVIZ_CMD : graphviz command. [dot]
- GRAPHVIZ_TARGET : target files. [all *.dot in docs/]
- GRAPHVIZ_OPTION_PNG : dot command line option for png. [-Gdpi=150]
- GRAPHVIZ_OPTION_SVG : dot command line option for svg. []
- GRAPHVIZ_OPTION_PDF : dot command line option for pdf. []
REFERENCES:
- https://graphviz.org/
- https://dreampuf.github.io/GraphvizOnline/
- https://www.devtoolsdaily.com/graphviz/
IDE INTEGRATIONS:
- VSCode : https://marketplace.visualstudio.com/items?itemName=EFanZh.graphviz-preview
- VSCode : https://marketplace.visualstudio.com/items?itemName=tintinweb.graphviz-interactive-preview
- JetBrains : https://plugins.jetbrains.com/plugin/10312-dot-language
- Web : https://dreampuf.github.io/GraphvizOnline/
- Web : https://magjac.com/graphviz-visual-editor/
- Others? : https://graphviz.org/resources/
PROJECT STRUCTURE:
/ |-- Project
├─ docs/ |
│ └─ *.dot |-- Default targets
├─ _scripts/ |-- Git submodule
│ └─ makefiles/ |
│ └─ graphviz.mk |
└─ Makefile |-- include _scripts/makefiles/graphviz.mk
endef
.PHONY: graphviz-help
graphviz-help:
$(info $(GRAPHVIZ_HELP))
@echo ""
#├─────────────────────────────────────────────────────────────────────────────┤
GRAPHVIZ_CMD ?= graphviz
GRAPHVIZ_TARGET ?= $(shell find ./docs/ -type f -name '*.dot' 2>/dev/null)
GRAPHVIZ_OPTION_PNG ?= -Gdpi=150
GRAPHVIZ_OPTION_SVG ?=
GRAPHVIZ_OPTION_PDF ?=
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: graphviz-png-usage
graphviz-png-usage:
# Usage : make graphviz-png ARGS=""
# Exec : $$(GRAPHVIZ_CMD) $$(GRAPHVIZ_OPTION_PNG) $$(ARGS) -Tpng -o $$@
# Desc : Export *.dot as png image.
# Examples:
# - make graphviz-png
# - make graphviz-png ARGS=""
# - make graphviz-png GRAPHVIZ_TARGET="./foo/*.dot"
.PHONY: graphviz-png
graphviz-png: $(GRAPHVIZ_TARGET:.dot=.png)
%.png: %.dot
cat $< | $(GRAPHVIZ_CMD) $(GRAPHVIZ_OPTION_PNG) $(ARGS) -Tpng -o $@
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: graphviz-svg-usage
graphviz-svg-usage:
# Usage : make graphviz-svg ARGS=""
# Exec : $$(GRAPHVIZ_CMD) $$(GRAPHVIZ_OPTION_SVG) $$(ARGS) -Tsvg -o $$@
# Desc : Export *.dot as svg image.
# Examples:
# - make graphviz-svg
# - make graphviz-svg ARGS=""
# - make graphviz-svg GRAPHVIZ_TARGET="./foo/*.dot"
.PHONY: graphviz-svg
graphviz-svg: $(GRAPHVIZ_TARGET:.dot=.svg)
%.svg: %.dot
cat $< | $(GRAPHVIZ_CMD) $(GRAPHVIZ_OPTION_SVG) $(ARGS) -Tsvg -o $@
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: graphviz-pdf-usage
graphviz-pdf-usage:
# Usage : make graphviz-pdf ARGS=""
# Exec : $$(GRAPHVIZ_CMD) $$(GRAPHVIZ_OPTION_PDF) $$(ARGS) -Tpdf -o $$@
# Desc : Export *.dot as pdf image.
# Examples:
# - make graphviz-pdf
# - make graphviz-pdf ARGS=""
# - make graphviz-pdf GRAPHVIZ_TARGET="./foo/*.dot"
.PHONY: graphviz-pdf
graphviz-pdf: $(GRAPHVIZ_TARGET:.dot=.pdf)
%.pdf: %.dot
cat $< | $(GRAPHVIZ_CMD) $(GRAPHVIZ_OPTION_PDF) $(ARGS) -Tpdf -o $@
#├─────────────────────────────────────────────────────────────────────────────┤