Skip to content

Commit 49888e6

Browse files
XuehaiPanpytorchmergebot
authored andcommitted
[BE] Polish Makefile (pytorch#155425)
Pull Request resolved: pytorch#155425 Approved by: https://github.com/ezyang
1 parent b981fb6 commit 49888e6

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

Makefile

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,78 @@
11
# 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
47
NIGHTLY_TOOL_OPTS := pull
58

9+
.PHONY: all
610
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 --
813

14+
.PHONY: local
915
local:
1016
@./scripts/build_local.sh
1117

18+
.PHONY: android
1219
android:
1320
@./scripts/build_android.sh
1421

22+
.PHONY: ios
1523
ios:
1624
@./scripts/build_ios.sh
1725

26+
.PHONY: triton
27+
triton:
28+
$(PIP) uninstall -y triton
29+
@./scripts/install_triton_wheel.sh
30+
31+
.PHONY: clean
1832
clean: # This will remove ALL build folders.
19-
@rm -r build*/
33+
@rm -r build*/ || true
2034

35+
.PHONY: linecount
2136
linecount:
2237
@cloc --read-lang-def=caffe.cloc caffe2 || \
2338
echo "Cloc is not available on the machine. You can install cloc with " && \
2439
echo " sudo apt-get install cloc"
2540

41+
.PHONY: ensure-branch-clean
2642
ensure-branch-clean:
2743
@if [ -n "$(shell git status --porcelain)" ]; then \
2844
echo "Please commit or stash all changes before running this script"; \
2945
exit 1; \
3046
fi
3147

48+
.PHONY: setup-env
3249
setup-env: ensure-branch-clean
3350
$(PYTHON) tools/nightly.py $(NIGHTLY_TOOL_OPTS)
3451

52+
.PHONY: setup-env-cuda
3553
setup-env-cuda:
3654
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --cuda"
3755

56+
.PHONY: setup-env-rocm
3857
setup-env-rocm:
3958
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --rocm"
4059

41-
setup_env: setup-env
42-
setup_env_cuda: setup-env-cuda
43-
setup_env_rocm: setup-env-rocm
44-
60+
.PHONY: setup-lint
4561
setup-lint:
4662
$(PIP) install lintrunner
4763
lintrunner init
4864

49-
setup_lint: setup-lint
50-
65+
.PHONY: lint
5166
lint:
5267
lintrunner
5368

69+
.PHONY: quicklint
5470
quicklint:
5571
lintrunner
5672

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

Comments
 (0)