Makefile 4.7 KB
Newer Older
Marc Egger's avatar
Marc Egger committed
1 2
SHELL := /bin/bash

3
PKG_VERSION = $(shell awk '/version/ { print $$3 }' extension/ext_emconf.php  | sed "s/'//g")
4

5
NIGHTLY_DATE = $(shell date '+%Y%m%d')
6
RELEASE_DATE = $(shell date '+%Y%m%d%H%M')
7

8 9
GIT_REVISION_SHORT = $(shell git rev-parse --short HEAD || true)
GIT_REVISION_LONG = $(shell git rev-parse HEAD || true)
10

Marc Egger's avatar
Marc Egger committed
11
EXTENSION_CONTENT = Classes Configuration Resources ext_emconf.php ext_localconf.php ext_tables.php ext_icon.png ext_conf_template.txt config.qfq.example.php RELEASE.txt vendor
12

Rafael Ostertag's avatar
Rafael Ostertag committed
13
DISTDIR=dist
14

15 16 17
# Use by jenkins to separate temp directories used by pip in order to allow concurrent builds
PIP_TMP ?= /tmp

Marc Egger's avatar
Marc Egger committed
18
all: archive
19

20
maintainer-clean:
bbaer's avatar
bbaer committed
21 22
	rm -f .doc_plantuml .npmpackages .phpdocinstall .plantuml_install .support .support_plantuml
	rm -rf doc/jsdoc doc/phpdoc doc/plantuml support node_modules .python_virtualenv build-dist
23

24
archive: clean qfq.zip
25

26
qfq.zip:
27
	cd extension/vendor; rm -rf phpoffice/phpspreadsheet/{C*,bin,c*,d*,m*,p*,sa*,.g*,.p*,.s*,.t*} doctrine myclabs phar-io phpdocumentor phpspec phpunit sebastian theseer webmozart
28
	cd extension; zip -r ../$@ $(EXTENSION_CONTENT)
29
	
30
clean:
31
	cd doc/diagram ; $(MAKE) $@
32

Rafael Ostertag's avatar
Rafael Ostertag committed
33
git-revision: make-dist-dir
Rafael Ostertag's avatar
Rafael Ostertag committed
34
	echo $(GIT_REVISION_LONG) > $(DISTDIR)/revision.git
35

Rafael Ostertag's avatar
Rafael Ostertag committed
36
make-dist-dir:
Rafael Ostertag's avatar
Rafael Ostertag committed
37 38 39 40 41 42
	rm -rf $(DISTDIR)/
	mkdir $(DISTDIR)

dist-copy-extension:
	cd extension ; cp -R $(EXTENSION_CONTENT) ../$(DISTDIR)/

Marc Egger's avatar
Marc Egger committed
43
build-dist: make-dist-dir dist-copy-extension git-revision
Rafael Ostertag's avatar
Rafael Ostertag committed
44 45
	echo "Distribution made in $(DIST)"

bbaer's avatar
bbaer committed
46
nightly: basic build-dist
47
	cd $(DISTDIR); zip -r ../qfq_$(VERSION)_$(RELEASE_DATE).zip  $(EXTENSION_CONTENT) revision.git -x config.ini
48

bbaer's avatar
bbaer committed
49
snapshot: basic build-dist
50
	cd $(DISTDIR) ; zip -r ../qfq_$(VERSION)_$(RELEASE_DATE).zip $(EXTENSION_CONTENT) revision.git -x config.ini
51

bbaer's avatar
bbaer committed
52
release: basic build-dist
Rafael Ostertag's avatar
Rafael Ostertag committed
53
	if [ -z "$(VERSION)" ] ; then  echo "Set VERSION make variable to the release version (fmt: maj.min.micro)" ; exit 1 ; fi
54
	cd $(DISTDIR) ; zip -r "../qfq_$(VERSION)_$(RELEASE_DATE).zip" $(EXTENSION_CONTENT) revision.git -x config.ini
55

56 57
plantuml:
	cd doc/diagram ; $(MAKE)
58

bbaer's avatar
bbaer committed
59
bootstrap: .npmpackages .plantuml_install .virtual_env
60
	npm update
61
	grunt default
62
	# take care that phpOffice is located under 'qfq/Resources/Private/vendor/phpoffice'
63 64
	# cd extension/Resources/Private; composer update
	cd extension; composer update
65

bbaer's avatar
bbaer committed
66
basic: .npmpackages .virtual_env
bbaer's avatar
bbaer committed
67
	grunt default
68 69
	# IMPORTANT: install composer with no-dev flag for deployment!
	cd extension; composer install --no-dev --optimize-autoloader; cd vendor/phpoffice/phpspreadsheet; rm -rf .github bin docs samples .g* .s* .t* C* c* m* p*
70

71
.plantuml_install: .support_plantuml
72
	wget --no-check-certificate -O support/plantuml/plantuml.jar 'https://downloads.sourceforge.net/project/plantuml/plantuml.jar'
73 74
	touch $@

Marc Egger's avatar
Marc Egger committed
75
.npmpackages:
76
	npm ls -g grunt-cli 2>/dev/null || { echo "Please install grunt-cli npm package using 'npm install -g grunt-cli'" 1>&2 ; exit 1; }
Marc Egger's avatar
Marc Egger committed
77 78 79 80 81 82 83

	# update npm at persistent location and copy node_modules (to speed up process)
	mkdir -p /var/tmp/qfq/npm
	/bin/cp package.json /var/tmp/qfq/npm/
	cd /var/tmp/qfq/npm; npm update
	/bin/cp -r /var/tmp/qfq/npm/node_modules ./

84 85
	touch $@

86 87 88
.support:
	mkdir -p support
	touch $@
89

90 91 92
.support_plantuml: .support
	mkdir -p support/plantuml
	touch $@
93

94
.virtual_env: pip-temp-directory
95
	virtualenv .python_virtualenv
96
	. .python_virtualenv/bin/activate ; TMPDIR="$(PIP_TMP)" pip install --upgrade sphinx==1.5.5
97 98
	touch $@

99 100 101
pip-temp-directory:
	test -d "$(PIP_TMP)" || mkdir -p "$(PIP_TMP)"

102
#.PHONY: nightly maintainer-clean snapshot release git-revision build-dist make-dist-dir dist-copy-extension pip-temp-directory plantuml sonar
103

Carsten  Rose's avatar
Carsten Rose committed
104
copyReleaseNotes:
Marc Egger's avatar
Marc Egger committed
105 106
	cp Documentation/Release.rst extension/RELEASE.txt
	cp Documentation/Release.rst CHANGELOG.md
107

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
phpunit:
	# update composer with dev to install phpunit package
	cd extension; composer update

	# create test config files and get test database password from environment variable
	cp -v extension/Tests/phpunit_config.qfq.php extension/config.qfq.php; sed -i "s/#PHPUNIT_PASSWORD#/$(PHPUNIT_MYSQL_PASSWORD)/" extension/config.qfq.php
	cp -v extension/Tests/phpunit_LocalConfiguration.php extension/LocalConfiguration.php

	# mock typo3 directory structure
	mkdir -p  typo3conf/ext/qfq
	mv -v extension/* typo3conf/ext/qfq/

	# run phpunit
	cd typo3conf/ext/qfq/; pwd; vendor/bin/phpunit --configuration phpunit.xml

phpunit_snapshot: snapshot phpunit

phpunit_release: release phpunit
Marc Egger's avatar
Marc Egger committed
126 127 128 129 130

doc-local:
	source docker/_helper_functions.sh; makePathExecutable "${PWD}/../"
	docker pull t3docs/render-documentation
	source <(docker run --rm t3docs/render-documentation show-shell-commands); dockrun_t3rd makehtml
Carsten  Rose's avatar
Carsten Rose committed
131 132 133 134 135
	xdg-open "Documentation-GENERATED-temp/Result/project/0.0.0/Index.html"

doc-qfqio:
	rsync -av "Documentation-GENERATED-temp/Result/project/0.0.0/" root@w16.math.uzh.ch:/var/www/html/qfq/doc/