blob: d5d88f87f3ea02d66bff4cf4940d3787e33e3232 [file] [log] [blame]
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -05001# Copyright 2016 The Brotli Authors. All rights reserved.
2#
3# Distributed under MIT license.
4# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
6
Alex Nicksay06082532017-08-02 10:59:46 -04007# Default (Build)
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -05008.PHONY: all
9# Build
10.PHONY: build
Cosimo Lupo4f455ca2017-08-23 19:45:13 +010011# Develop
12.PHONY: develop
Alex Nicksay06082532017-08-02 10:59:46 -040013# Install
14.PHONY: install
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -050015# Test
Cosimo Lupo4f455ca2017-08-23 19:45:13 +010016.PHONY: test
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -050017# Clean
18.PHONY: clean
19# Format
20.PHONY: fix
21
22
23PYTHON ?= python
24YAPF ?= yapf
25
26EXT_SUFFIX=$(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')
27EXT_SOURCES=$(shell find . -name '*.cc')
28EXTENSIONS=$(EXT_SOURCES:%.cc=%$(EXT_SUFFIX))
29
30
31all: build
32
33build: $(EXTENSIONS)
34
35$(EXTENSIONS): $(EXT_SOURCES)
Cosimo Lupo4f455ca2017-08-23 19:45:13 +010036 @cd .. && $(PYTHON) setup.py build_ext --inplace
37
38develop:
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -050039 @cd .. && $(PYTHON) setup.py develop
40
Alex Nicksay06082532017-08-02 10:59:46 -040041install:
42 @cd .. && $(PYTHON) setup.py install
43
Cosimo Lupo4f455ca2017-08-23 19:45:13 +010044test: build
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -050045 @echo 'running tests'
Cosimo Lupo4f455ca2017-08-23 19:45:13 +010046 @$(PYTHON) -m unittest discover -v -p '*_test.py'
Alex Nicksay6ab0a5c2016-12-21 04:17:11 -050047
48clean:
49 @cd .. && $(PYTHON) setup.py clean
50 @find .. -name '*.pyc' | xargs rm -v
51 @find .. -name '*.so' | xargs rm -v
52 @find .. -type d -name '__pycache__' | xargs rm -v -r
53 @find .. -type d -name '*.egg-info' | xargs rm -v -r
54
55fix:
56 @echo 'formatting code'
57 -@$(YAPF) --in-place --recursive --verify .