Last active
October 2, 2024 13:23
-
-
Save sukima/52eacde54bf7861b19ee66a07b864583 to your computer and use it in GitHub Desktop.
Makefile for compiling PlantUML diagrams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile for PlantUML | |
# Author: Devin Weaver (@sukima) <[email protected]> | |
# GistID: 52eacde54bf7861b19ee66a07b864583 | |
# | |
# This handles SVGs PNGs and ASCII outputs. | |
# It handles included files with the .iuml extension: !include foo.iuml | |
# All diagrams have the .uml extension and reside in the diagrams directory | |
# All output is saved to the output directory | |
# | |
# make svg - (default) build all diagrams as SVGs | |
# make png - build all diagrams as PNGs | |
# make ascii - build all diagrams as ACII Art text files (.atxt) | |
# make all - build SVG, PNG, and ASCII files | |
# make depend - build the dependency cache (also done automatically) | |
# make clean - clean up build artifacts and output files | |
# | |
# Diagrams can be built in parrallel with `make -j`. | |
# If you installed plantuml from Homebrew (brew install plantuml) use this: | |
# PLANTUML = plantuml | |
PLANTUML = java -jar bin/plantuml.jar | |
SRC = diagrams | |
OUTPUT = output | |
DEPEND = .depend | |
SRC_FILES := $(wildcard $(SRC)/*.uml) | |
.PHONY: default all depend clean ascii svg png atxt | |
default: svg | |
all: svg png ascii | |
depend: $(DEPEND) | |
clean: | |
rm -rf $(OUTPUT) $(DEPEND) | |
ascii: atxt | |
svg png atxt: $(DEPEND) | |
@$(MAKE) $(patsubst $(SRC)/%.uml,$(OUTPUT)/%.$@,$(shell ls -1t $(SRC_FILES))) | |
$(OUTPUT)/%.svg: $(SRC)/%.uml | |
$(PLANTUML) -tsvg $< -o ../$(OUTPUT) | |
$(OUTPUT)/%.png: $(SRC)/%.uml | |
$(PLANTUML) -tpng $< -o ../$(OUTPUT) | |
$(OUTPUT)/%.atxt: $(SRC)/%.uml | |
$(PLANTUML) -ttxt $< -o ../$(OUTPUT) | |
$(DEPEND): $(SRC_FILES) | |
@find_includes() { \ | |
sed \ | |
-e "s,^[[:space:]]*!include \([^<].*[^>]\)$$,$${1}/\1," \ | |
-e t -e d "$$2" \ | |
| paste -sd " " -; \ | |
}; \ | |
echo "# GENERATED BY make depend" > $@; \ | |
echo "# DO NOT EDIT" >> $@; \ | |
echo >> $@; \ | |
for file in $^; do \ | |
name="$$(basename -s .uml "$$file")"; \ | |
includes="$$(find_includes "$(SRC)" "$$file")"; \ | |
printf "$(OUTPUT)/%s.svg: %s\n" "$$name" "$$includes"; \ | |
printf "$(OUTPUT)/%s.png: %s\n" "$$name" "$$includes"; \ | |
printf "$(OUTPUT)/%s.atxt: %s\n" "$$name" "$$includes"; \ | |
done >> $@ | |
-include $(DEPEND) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment