-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
69 lines (51 loc) · 2.24 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
SHELL = /bin/bash
PROJECT_NAME = autofd
PROJECT_FOLDER = autofd
PYTHON_FILES = $(shell find . -type f -name "*.py")
CPP_FILES = $(shell find . -type f -name "*.h" -o -name "*.cc")
BAZEL_FILES = $(shell find . -type f -name "*BUILD" -o -name "*.bzl")
COMMIT_HASH = $(shell git log -1 --format=%h)
COPYRIGHT = "Garena Online Private Limited"
BAZELOPT =
PATH := $(HOME)/go/bin:$(PATH)
ADDLICENSE_IGNORE =
# installation
check_install = python3 -c "import $(1)" || (cd && pip3 install $(1) --upgrade && cd -)
check_install_extra = python3 -c "import $(1)" || (cd && pip3 install $(2) --upgrade && cd -)
flake8-install:
$(call check_install, flake8)
$(call check_install_extra, bugbear, flake8_bugbear)
py-format-install:
$(call check_install, yapf) && pip install 2to3 --upgrade
cpplint-install:
$(call check_install, cpplint)
clang-format-install:
command -v clang-format-11 || sudo apt-get install -y clang-format-11
go-install:
# requires go >= 1.16
command -v go || (sudo apt-get install -y golang-1.16 && sudo ln -sf /usr/lib/go-1.16/bin/go /usr/bin/go)
bazel-install: go-install
command -v bazel || (go install github.com/bazelbuild/bazelisk@latest && ln -sf $(HOME)/go/bin/bazelisk $(HOME)/go/bin/bazel)
buildifier-install: go-install
command -v buildifier || go install github.com/bazelbuild/buildtools/buildifier@latest
addlicense-install: go-install
command -v addlicense || go install github.com/google/addlicense@latest
doc-install:
$(call check_install, pydocstyle)
$(call check_install_extra, doc8, "doc8<1")
$(call check_install, sphinx)
$(call check_install, sphinx_rtd_theme)
$(call check_install_extra, sphinxcontrib.spelling, sphinxcontrib.spelling pyenchant)
auditwheel-install:
$(call check_install_extra, auditwheel, auditwheel typed-ast)
# python linter
flake8: flake8-install
flake8 $(PYTHON_FILES) --count --show-source --statistics
py-format: py-format-install
yapf -r -d $(PYTHON_FILES)
addlicense: addlicense-install
addlicense -c $(COPYRIGHT) -l apache -y 2023 $(ADDLICENSE_IGNORE) -check $(PROJECT_FOLDER)
lint: flake8 py-format
format: py-format-install addlicense-install
yapf -ir $(PYTHON_FILES)
addlicense -c $(COPYRIGHT) -l apache -y 2023 $(ADDLICENSE_IGNORE) $(PROJECT_FOLDER)