-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (105 loc) · 3.47 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
SHELL := /bin/bash
# Disable built-in rules and variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
NETWORK := local
###########################################################################
# OS we're running on
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
endif
ifeq ($(detected_OS),Darwin) # Mac OS X (Intel)
OS += macos
DIDC += didc-macos
endif
ifeq ($(detected_OS),Linux) # Ubuntu
OS += linux
DIDC += didc-linux64
endif
ifeq ($(detected_OS),Windows_NT) # Windows (icpp supports it but you cannot run this Makefile)
OS += windows_cannot_run_make
endif
ifeq ($(detected_OS),Unknown) # Unknown
OS += unknown
endif
###########################################################################
# latest release of didc
VERSION_DIDC := $(shell curl --silent "https://api.github.com/repos/dfinity/candid/releases/latest" | grep -e '"tag_name"' | cut -c 16-25)
# version to install for clang
VERSION_CLANG := $(shell cat version_clang.txt)
###########################################################################
# Use some clang tools that come with wasi-sdk
WASI_SDK_COMPILER_ROOT := $(HOME)/.icpp/wasi-sdk/wasi-sdk-22.0
CLANG_FORMAT = $(WASI_SDK_COMPILER_ROOT)/bin/clang-format
CLANG_TIDY = $(WASI_SDK_COMPILER_ROOT)/bin/clang-tidy
.PHONY: summary
summary:
@echo "-------------------------------------------------------------"
@echo OS=$(OS)
@echo VERSION_DIDC=$(VERSION_DIDC)
@echo VERSION_CLANG=$(VERSION_CLANG)
@echo WASI_SDK_COMPILER_VERSION=$(WASI_SDK_COMPILER_VERSION)
@echo WASI_SDK_COMPILER_ROOT=$(WASI_SDK_COMPILER_ROOT)
@echo CLANG_FORMAT=$(CLANG_FORMAT)
@echo CLANG_TIDY=$(CLANG_TIDY)
@echo "-------------------------------------------------------------"
###########################################################################
# CI/CD - Phony Makefile targets
#
.PHONY: all-tests
all-tests: all-static all-canister-native all-canister-deploy-local-pytest
.PHONY: all-canister-deploy-local-pytest
all-canister-deploy-local-pytest:
dfx identity use default
@python -m scripts.all_canister_deploy_local_pytest
.PHONY: all-canister-native
all-canister-native:
@python -m scripts.all_canister_native
.PHONY: all-static
all-static: \
cpp-format cpp-lint \
python-format python-lint python-type
CPP_AND_H_FILES = $(shell ls \
canisters/*/src/*.cpp canisters/*/src/*.h \
canisters/*/native/*.cpp canisters/*/native/*.h)
.PHONY: cpp-format
cpp-format:
@echo "---"
@echo "cpp-format"
$(CLANG_FORMAT) --style=file --verbose -i $(CPP_AND_H_FILES)
.PHONY: cpp-lint
cpp-lint:
@echo "---"
@echo "cpp-lint"
@echo "TO IMPLEMENT with clang-tidy"
.PHONY: clean-dfx
clean-dfx:
rm -rf $(shell find . -name '.dfx' -type d)
.PHONY: clean-build
clean-build:
rm -rf build build-native build-native-unit
rm -rf $(shell find ./src -name 'build' -type d)
rm -rf $(shell find ./tests -name 'build' -type d)
.PHONY: python-clean
python-clean:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
PYTHON_DIRS ?= canisters scripts
.PHONY: python-format
python-format:
@echo "---"
@echo "python-format"
python -m black $(PYTHON_DIRS)
.PHONY: python-lint
python-lint:
@echo "---"
@echo "python-lint"
python -m pylint --jobs=0 --rcfile=.pylintrc $(PYTHON_DIRS)
.PHONY: python-type
python-type:
@echo "---"
@echo "python-type"
python -m mypy --config-file .mypy.ini --show-column-numbers --strict --explicit-package-bases $(PYTHON_DIRS)