-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (53 loc) · 1.74 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
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
SED = sed
endif
ifeq ($(UNAME_S),Darwin)
SED = gsed
endif
PREV:=$(shell grep version= setup.py | $(SED) -E -e "s/\s*version='([0-9]*.[0-9]*)',/\1/")
NEXT:=$(shell echo $(PREV)+0.1 | /usr/bin/bc | $(SED) -E -e "s/^\./0\./")
#DEPLOYURL=--repository-url https://test.pypi.org/legacy/
DEPLOYURL=
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CWD := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
DOCKER_IMG := pytm
ifeq ($(USE_DOCKER),true)
SHELL=docker
.SHELLFLAGS=run -u $$(id -u) -v $(CWD):/usr/src/app --rm $(DOCKER_IMG):latest -c
endif
ifndef PLANTUML_PATH
export PLANTUML_PATH = ./plantuml.jar
endif
models := tm.py
libs := $(wildcard pytm/*.py) $(wildcard pytm/threatlib/*.json) $(wildcard pytm/images/*)
all: clean build
all: $(models:.py=/report.html) $(models:.py=/dfd.png) $(models:.py=/seq.png)
clean:
rm -rf dist/* build/* $(models:.py=/*)
tm:
mkdir -p tm
%/dfd.png: %.py tm $(libs)
./$< --dfd | dot -Tpng -o $@
%/seq.png: %.py tm $(libs)
./$< --seq | java -Djava.awt.headless=true -jar $$PLANTUML_PATH -tpng -pipe > $@
%/report.html: %.py tm $(libs) docs/template.md docs/Stylesheet.css
./$< --report docs/template.md | pandoc -f markdown -t html > $@
dfd: $(models:.py=/dfd.png)
seq: $(models:.py=/seq.png)
report: $(models:.py=/report.html) seq dfd
build: setup.py
#cat setup.py | sed -e "s/'$(PREV)'/'$(NEXT)'/" > newver.py
#mv newver.py setup.py
rm -rf dist build
python3 setup.py sdist bdist_wheel
twine upload $(DEPLOYURL) dist/*
.PHONY: test
test:
python3 -m unittest
.PHONY: describe
describe:
./tm.py --describe "TM Element Boundary ExternalEntity Actor Lambda Server Process SetOfProcesses Datastore Dataflow"
.PHONY: image
image:
docker build -t $(DOCKER_IMG) .