forked from owncloud/oauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·136 lines (109 loc) · 3.4 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
SHELL := /bin/bash
#
# Define NPM and check if it is available on the system.
#
NPM := $(shell command -v npm 2> /dev/null)
ifndef NPM
$(error npm is not available on your system, please install npm)
endif
NODE_PREFIX=$(shell pwd)
# bin file definitions
PHPUNIT=php -d zend.enable_gc=0 ../../lib/composer/bin/phpunit
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "../../lib/composer/bin/phpunit"
PHPLINT=php -d zend.enable_gc=0 vendor-bin/php-parallel-lint/vendor/bin/parallel-lint
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
BOWER=$(NODE_PREFIX)/node_modules/bower/bin/bower
JSDOC=$(NODE_PREFIX)/node_modules/.bin/jsdoc
app_name=$(notdir $(CURDIR))
doc_files=COPYING README.md CHANGELOG.md AUTHORS.md
src_dirs=appinfo css img js l10n lib templates
all_src=$(src_dirs) $(doc_files)
build_dir=$(CURDIR)/build
dist_dir=$(build_dir)/dist
COMPOSER_BIN=$(build_dir)/composer.phar
# internal aliases
composer_deps=
composer_dev_deps=
nodejs_deps=
bower_deps=
occ=$(CURDIR)/../../occ
private_key=$(HOME)/.owncloud/certificates/$(app_name).key
certificate=$(HOME)/.owncloud/certificates/$(app_name).crt
sign=$(occ) integrity:sign-app --privateKey="$(private_key)" --certificate="$(certificate)"
sign_skip_msg="Skipping signing, either no key and certificate found in $(private_key) and $(certificate) or occ can not be found at $(occ)"
ifneq (,$(wildcard $(private_key)))
ifneq (,$(wildcard $(certificate)))
ifneq (,$(wildcard $(occ)))
CAN_SIGN=true
endif
endif
endif
#
# Catch-all rules
#
.PHONY: all
all: $(composer_dev_deps) $(bower_deps)
.PHONY: clean
clean: clean-deps clean-dist clean-build
#
# Basic required tools
#
$(COMPOSER_BIN):
mkdir -p $(build_dir)
cd $(build_dir) && curl -sS https://getcomposer.org/installer | php
#
# PHP dependencies
#
$(composer_deps): $(COMPOSER_BIN) composer.json composer.lock
php $(COMPOSER_BIN) install --no-dev
$(composer_dev_deps): $(COMPOSER_BIN) composer.json composer.lock
php $(COMPOSER_BIN) install --dev
.PHONY: clean-composer-deps
clean-composer-deps:
rm -f $(COMPOSER_BIN)
rm -Rf $(composer_deps) $(composer_dev_deps)
.PHONY: update-composer
update-composer: $(COMPOSER_BIN)
rm -f composer.lock
php $(COMPOSER_BIN) install --prefer-dist
#
## Node dependencies
#
$(nodejs_deps): package.json
$(NPM) install --prefix $(NODE_PREFIX) && touch $@
$(BOWER): $(nodejs_deps)
$(JSDOC): $(nodejs_deps)
$(bower_deps): $(BOWER)
$(BOWER) install && touch $@
#
# dist
#
$(dist_dir)/$(app_name): $(composer_deps) $(bower_deps)
rm -Rf $@; mkdir -p $@
cp -R $(all_src) $@
ifdef CAN_SIGN
$(sign) --path="$(dist_dir)/$(app_name)"
else
@echo $(sign_skip_msg)
endif
tar -czf $(dist_dir)/$(app_name).tar.gz -C $(dist_dir) $(app_name)
tar -cjf $(dist_dir)/$(app_name).tar.bz2 -C $(dist_dir) $(app_name)
.PHONY: dist
dist: clean-dist $(dist_dir)/$(app_name)
.PHONY: clean-dist
clean-dist:
rm -Rf $(dist_dir)
.PHONY: clean-build
clean-build:
rm -Rf $(build_dir)
.PHONY: clean-deps
clean-deps: clean-composer-deps
rm -Rf $(nodejs_deps) $(bower_deps)
.PHONY: test-php-unit
test-php-unit: ## Run php unit tests
test-php-unit: ../../lib/composer/bin/phpunit
$(PHPUNIT) --configuration ./phpunit.xml --testsuite testing-unit
.PHONY: test-php-unit-dbg
test-php-unit-dbg: ## Run php unit tests using phpdbg
test-php-unit-dbg: ../../lib/composer/bin/phpunit
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite testing-unit