-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMakefile
55 lines (42 loc) · 1.41 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
BATS_GIT := https://github.com/sstephenson/bats.git
BATS_TMP := /tmp/bats
COMPOSER_COMMAND ?= composer
COMPOSER_OPTIONS ?= --prefer-source
GIT ?= git
PHP ?= php
COMPOSER_EXECUTABLE := $(shell command -v $(COMPOSER_COMMAND) 2> /dev/null)
COMPOSER_CMD := $(PHP) $(COMPOSER_EXECUTABLE)
export COMPOSER_VENDOR_DIR := vendor-$(PHP).cache
export COMPOSER := composer-$(PHP).cache.json
export PATH := $(PWD)/bin:$(dir $(BATS_TMP))local/bin:$(PWD)/tests/fixtures:$(PATH)
.PHONY : all
all : install test
.PHONY : test
test : $(dir $(BATS_TMP))local/bin/bats vendor
bats tests
.PHONY : install
install : $(dir $(BATS_TMP))local/bin/bats vendor
@$(PHP) --version | head -1
@$(COMPOSER_CMD) --version
@bats --version
$(dir $(BATS_TMP))local/libexec/bats $(dir $(BATS_TMP))local/bin/bats : $(BATS_TMP)/.git/HEAD
mkdir -p $(dir $(BATS_TMP))local
bash $(BATS_TMP)/install.sh $(dir $(BATS_TMP))local
bats --version
touch $(@)
$(BATS_TMP)/.git/HEAD :
$(GIT) clone $(BATS_GIT) $(BATS_TMP)
.PHONY : vendor
vendor : $(COMPOSER) $(COMPOSER_VENDOR_DIR)/composer/installed.json
composer-%.cache.json : composer.json
rm -f $@
cp $< $@
composer.lock : $(COMPOSER_VENDOR_DIR)/composer/installed.json
touch $@
$(COMPOSER_VENDOR_DIR)/composer/installed.json : composer.json
$(COMPOSER_CMD) update $(COMPOSER_OPTIONS)
touch $@
.PHONY : clean
clean :
rm -rf -- $(BATS_TMP) $(dir $(BATS_TMP))local
git clean -ffx vendor-*.cache* composer-*.cache*