|
1 | 1 | # This makefile does nothing but delegating the actual building to cmake. |
2 | | -PYTHON = python3 |
3 | | -PIP = $(PYTHON) -m pip |
| 2 | + |
| 3 | +SHELL = /bin/bash |
| 4 | +.SHELLFLAGS := -eu -o pipefail -c |
| 5 | +PYTHON ?= $(shell command -v python3 || command -v python) |
| 6 | +PIP = $(PYTHON) -m pip |
4 | 7 | NIGHTLY_TOOL_OPTS := pull |
5 | 8 |
|
| 9 | +.PHONY: all |
6 | 10 | all: |
7 | | - @mkdir -p build && cd build && cmake .. $(shell $(PYTHON) ./scripts/get_python_cmake_flags.py) && $(MAKE) |
| 11 | + @cmake -S . -B build $(shell $(PYTHON) ./scripts/get_python_cmake_flags.py) && \ |
| 12 | + cmake --build build --parallel -- |
8 | 13 |
|
| 14 | +.PHONY: local |
9 | 15 | local: |
10 | 16 | @./scripts/build_local.sh |
11 | 17 |
|
| 18 | +.PHONY: android |
12 | 19 | android: |
13 | 20 | @./scripts/build_android.sh |
14 | 21 |
|
| 22 | +.PHONY: ios |
15 | 23 | ios: |
16 | 24 | @./scripts/build_ios.sh |
17 | 25 |
|
| 26 | +.PHONY: triton |
| 27 | +triton: |
| 28 | + $(PIP) uninstall -y triton |
| 29 | + @./scripts/install_triton_wheel.sh |
| 30 | + |
| 31 | +.PHONY: clean |
18 | 32 | clean: # This will remove ALL build folders. |
19 | | - @rm -r build*/ |
| 33 | + @rm -r build*/ || true |
20 | 34 |
|
| 35 | +.PHONY: linecount |
21 | 36 | linecount: |
22 | 37 | @cloc --read-lang-def=caffe.cloc caffe2 || \ |
23 | 38 | echo "Cloc is not available on the machine. You can install cloc with " && \ |
24 | 39 | echo " sudo apt-get install cloc" |
25 | 40 |
|
| 41 | +.PHONY: ensure-branch-clean |
26 | 42 | ensure-branch-clean: |
27 | 43 | @if [ -n "$(shell git status --porcelain)" ]; then \ |
28 | 44 | echo "Please commit or stash all changes before running this script"; \ |
29 | 45 | exit 1; \ |
30 | 46 | fi |
31 | 47 |
|
| 48 | +.PHONY: setup-env |
32 | 49 | setup-env: ensure-branch-clean |
33 | 50 | $(PYTHON) tools/nightly.py $(NIGHTLY_TOOL_OPTS) |
34 | 51 |
|
| 52 | +.PHONY: setup-env-cuda |
35 | 53 | setup-env-cuda: |
36 | 54 | $(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --cuda" |
37 | 55 |
|
| 56 | +.PHONY: setup-env-rocm |
38 | 57 | setup-env-rocm: |
39 | 58 | $(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --rocm" |
40 | 59 |
|
41 | | -setup_env: setup-env |
42 | | -setup_env_cuda: setup-env-cuda |
43 | | -setup_env_rocm: setup-env-rocm |
44 | | - |
| 60 | +.PHONY: setup-lint |
45 | 61 | setup-lint: |
46 | 62 | $(PIP) install lintrunner |
47 | 63 | lintrunner init |
48 | 64 |
|
49 | | -setup_lint: setup-lint |
50 | | - |
| 65 | +.PHONY: lint |
51 | 66 | lint: |
52 | 67 | lintrunner |
53 | 68 |
|
| 69 | +.PHONY: quicklint |
54 | 70 | quicklint: |
55 | 71 | lintrunner |
56 | 72 |
|
57 | | -triton: |
58 | | - $(PIP) uninstall -y triton |
59 | | - @./scripts/install_triton_wheel.sh |
| 73 | +# Deprecated target aliases |
| 74 | +.PHONY: setup_env setup_env_cuda setup_env_rocm setup_lint |
| 75 | +setup_env: setup-env |
| 76 | +setup_env_cuda: setup-env-cuda |
| 77 | +setup_env_rocm: setup-env-rocm |
| 78 | +setup_lint: setup-lint |
0 commit comments