-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
114 lines (103 loc) · 3.87 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
# -*- Makefile -*-
#
# Tasmania
#
# Copyright (c) 2018-2024, ETH Zurich
# All rights reserved.
#
# This file is part of the Tasmania project. Tasmania is free software:
# you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
PYSRC := $(shell find $(shell pwd) -name '*.py')
BUILD_FOLDERS = build .eggs tasmania/tasmania.egg-info
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(dir $(MKFILE_PATH))
SRC_DIR := $(ROOT_DIR)/tasmania
DOC_DIR := $(ROOT_DIR)/docs
DOC_SRC := $(DOC_DIR)/source/conf.py $(DOC_DIR)/source/api.rst
PARSER_DIR := $(SRC_DIR)/cpp/parser
UML_DIR := $(DOC_DIR)/uml
TEST_DIR := $(ROOT_DIR)/tests
HYPOTHESIS_DIR := $(TEST_DIR)/.hypothesis
DOCKER_DIR := $(ROOT_DIR)/docker
.PHONY: docker-build-cpu docker-build-gpu docker-run-cpu docker-run-gpu docs uml prepare-tests tests clean distclean
docker-build-cpu:
@mkdir -p $(DOCKER_DIR)/images
@cd $(DOCKER_DIR) && ./build_cpu.sh
docker-build-gpu:
@mkdir -p $(DOCKER_DIR)/images
@cd $(DOCKER_DIR) && ./build_gpu.sh
docker-run-cpu:
@if [[ "$(shell echo $$OSTYPE)" == "linux-gnu" ]]; then\
cd $(DOCKER_DIR) && ./run_cpu.sh;\
elif [[ "$(shell echo $$OSTYPE)" == "darwin"* ]]; then\
cd $(DOCKER_DIR) && ./run_cpu_mac.sh;\
else\
echo "Unsupported host OS.";\
fi
docker-run-gpu:
@if [[ "$(shell echo $$OSTYPE)" == "linux-gnu" ]]; then\
cd $(DOCKER_DIR) && ./run_gpu.sh;\
elif [[ "$(shell echo $$OSTYPE)" == "darwin"* ]]; then\
cd $(DOCKER_DIR) && ./run_gpu_mac.sh;\
else\
echo "Unsupported host OS.";\
fi
docs:
@echo -n "Building HTML documentation ... "
@cd $(DOC_DIR) && $(MAKE) html > /dev/null 2>&1
@echo "OK."
@echo -n "Building LaTeX documentation ... "
@cd $(DOC_DIR) && $(MAKE) latex > /dev/null 2>&1
@echo "OK."
@echo -n "Building LaTeX-pdf documentation ... "
@cd $(DOC_DIR) && $(MAKE) latexpdf > /dev/null
@echo "OK."
uml:
@echo -n "Building UML diagrams ... "
@pyreverse -p grids -o eps grids/ > /dev/null
@pyreverse -p dycore -f OTHER -o eps dycore/ > /dev/null
@pyreverse -p storages -o eps storages/ > /dev/null
@mv classes_*.eps $(UML_DIR) > /dev/null
@mv packages_*.eps $(UML_DIR) > /dev/null
@echo "OK."
tests:
@cd $(TEST_DIR) && make
clean:
@find . -name "*.pyc" -delete
@find . -name "__pycache__" -delete
@find . -name ".pytest_cache" -delete
@find . -name ".idea" -delete
@find . -name ".cache" -delete
@$(RM) -r $(HYPOTHESIS_DIR)
@find . -type f -name "*.sw[klmnop]" -delete
@$(CD) $(TEST_DIR) && make clean
distclean: clean
@find . -name ".gt_cache" -delete
@cd $(PARSER_DIR) && $(MAKE) clean > /dev/null
@cd $(PARSER_DIR)/tests && $(MAKE) clean > /dev/null
@$(RM) -r $(BUILD_FOLDERS) > /dev/null
gitignore:
@sed -n '/# AUTOMATICALLY GENERATED TEXT/q;p' .gitignore | cat > .gitignore_tmp
@cp .gitignore_tmp .gitignore
@$(RM) .gitignore_tmp
@echo '# AUTOMATICALLY GENERATED TEXT' >> .gitignore
@echo '# The text after this comment and up to the end of file' >> .gitignore
@echo '# has been automatically generated by the gitignore target' >> .gitignore
@echo '# of the makefile. To prevent this target from failing,' >> .gitignore
@echo '# no modifications should be applied by non-expert users.\n' >> .gitignore
@echo '# Files which exceed maximum size allowed by GitHub' >> .gitignore
@find . -size +50M | cat >> .gitignore
@echo '\n# END OF AUTOMATICALLY GENERATED TEXT' >> .gitignore