-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
99 lines (74 loc) · 2.52 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
SHELL=/bin/bash
# DIRECTORIES
BASE_DIR = .
SRC_DIR = $(BASE_DIR)/src
VENDOR_DIR = $(BASE_DIR)/vendor
TESTS_DIR = $(BASE_DIR)/tests
# PHP BINARY
PHP_BIN = php
# COMPOSER STUFF
COMPOSER_BIN = composer
COMPOSER_LOCK = $(BASE_DIR)/composer.lock
# PHP CS FIXER STUFF
PHPCS_FIXER_SCRIPT = $(VENDOR_DIR)/bin/php-cs-fixer
PHPCS_FIXER_LOCK = $(BASE_DIR)/.php_cs.cache
# PHPUNIT STUFF
PHPUNIT_SCRIPT = $(VENDOR_DIR)/bin/phpunit
PHPUNIT_LOCK = $(BASE_DIR)/.phpunit.lock
# PHPSTAN STUFF
PHPSTAN_SCRIPT = $(VENDOR_DIR)/bin/phpstan
PHPSTAN_LOCK = $(BASE_DIR)/.phpstan.lock
# TARGET ALIASES
COMPOSER_TARGET = $(COMPOSER_LOCK)
PHPCS_FIX_TARGET = $(PHPCS_FIXER_LOCK)
PHPCS_CHECK_TARGET = $(PHPCS_FIXER_LOCK)
PHPUNIT_TARGET = $(PHPUNIT_LOCK)
PHPSTAN_TARGET = $(PHPSTAN_LOCK)
BUILD_TARGET = $(COMPOSER_TARGET) $(PHPUNIT_TARGET) $(PHPSTAN_TARGET) $(PHPCS_FIXER_TARGET)
# MACROS
macro_find_phpfiles = $(shell find $(1) -type f -name "*.php")
# SOURCECODE FILESETS
PHP_FILES = $(call macro_find_phpfiles,$(SRC_DIR))
PHP_CORE_FILES = $(call macro_find_phpfiles,$(CORE_DIR))
PHP_CORE_API_FILES = $(call macro_find_phpfiles,$(CORE_API_DIR))
PHP_TEST_FILES = $(call macro_find_phpfiles,$(TESTS_DIR))
PHP_UNITTEST_FILES = $(call macro_find_phpfiles,$(TESTS_DIR))
# TARGETS
.PHONY: all
all: build
init:
git config core.hooksPath .githooks
.PHONY: clean
clean: mostlyclean
@-test ! -d $(VENDOR_DIR) || rm -rfv $(VENDOR_DIR)/*
.PHONY: deps
deps: composer
.PHONY: build
build: $(BUILD_TARGET)
.PHONY: composer
composer: $(COMPOSER_TARGET)
$(COMPOSER_TARGET) $(PHPCS_FIXER_SCRIPT) $(PHPUNIT_SCRIPT) $(PHPSTAN_SCRIPT): $(BASE_DIR)/composer.json
$(COMPOSER_BIN) update
@touch $@
.PHONY: phpcs-check
phpcs-check: $(PHPCS_FIXER_TARGET)
$(PHPCS_CHECK_TARGET): $(PHPCS_FIXER_SCRIPT) $(PHP_FILES) $(COMPOSER_LOCK)
$(PHP_BIN) $(PHPCS_FIXER_SCRIPT) fix --config=.php-cs-fixer.dist.php -v --dry-run --allow-risky --stop-on-violation --using-cache=no
@touch $@
.PHONY: phpcs-fix
phpcs-fix: $(PHPCS_FIXER_TARGET)
$(PHPCS_FIX_TARGET): $(PHPCS_FIXER_SCRIPT) $(PHP_FILES) $(COMPOSER_LOCK)
$(PHP_BIN) $(PHPCS_FIXER_SCRIPT) fix --config=.php-cs-fixer.dist.php -v
@touch $@
.PHONY: test
test: $(PHPUNIT_TARGET)
.PHONY: phpunit
phpunit: $(PHPUNIT_TARGET)
$(PHPUNIT_TARGET): $(PHPUNIT_SCRIPT) $(PHP_FILES) $(PHP_UNITTEST_FILES)
$(PHP_BIN) $(PHPUNIT_SCRIPT) -c phpunit.xml --stderr --debug
@touch $@
.PHONY: phpstan
phpstan: $(PHPSTAN_TARGET)
$(PHPSTAN_TARGET): $(PHPSTAN_SCRIPT) $(PHP_FILES) $(PHP_TEST_FILES)
$(PHP_BIN) $(PHPSTAN_SCRIPT) analyse -c phpstan.neon $(SRC_DIR) $(TESTS_DIR)
@touch $@