8000 Makefile: refactor build, setup and lint rules · pytorch/pytorch@c48ea9a · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit c48ea9a

Browse files
committed
Makefile: refactor build, setup and lint rules
build rules, `setup_env_*` and `setup-env-*` differ by one flag; `quicklint` and `lint` call the same command. Refactor by using pattern rules. Link: https://www.gnu.org/software/make/manual/html_node/Pattern-Examples.html Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
1 parent 6f6acb4 commit c48ea9a

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

Makefile

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
PYTHON = python3
33
PIP = $(PYTHON) -m pip
44
NIGHTLY_TOOL_OPTS := pull
5+
BUILD_TARGETS := android ios local
6+
PLATFORMS := cuda rocm
7+
SETUP_ENVS := $(PLATFORMS:%=setup-env-%)
8+
SETUP_ENV_PLATFORMS := $(PLATFORMS:%=setup_env_%)
59

610
all:
711
@mkdir -p build && cd build && cmake .. $(shell $(PYTHON) ./scripts/get_python_cmake_flags.py) && $(MAKE)
812

9-
local:
10-
@./scripts/build_local.sh
11-
12-
android:
13-
@./scripts/build_android.sh
14-
15-
ios:
16-
@./scripts/build_ios.sh
13+
$(BUILD_TARGETS): %:
14+
@./scripts/build_$*.sh
1715

1816
clean: # This will remove ALL build folders.
1917
@rm -r build*/
@@ -32,26 +30,19 @@ ensure-branch-clean:
3230
setup-env: ensure-branch-clean
3331
$(PYTHON) tools/nightly.py $(NIGHTLY_TOOL_OPTS)
3432

35-
setup-env-cuda:
36-
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --cuda"
37-
38-
setup-env-rocm:
39-
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --rocm"
33+
$(SETUP_ENVS): setup-env-%:
34+
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --$*"
4035

4136
setup_env: setup-env
42-
setup_env_cuda: setup-env-cuda
43-
setup_env_rocm: setup-env-rocm
37+
$(SETUP_ENV_PLATFORMS): setup_env_%: setup-env-%
4438

4539
setup-lint:
4640
$(PIP) install lintrunner
4741
lintrunner init
4842

4943
setup_lint: setup-lint
5044

51-
lint:
52-
lintrunner
53-
54-
quicklint:
45+
lint quicklint:
5546
lintrunner
5647

5748
triton:

0 commit comments

Comments
 (0)
0