| # Copyright 2014 the Melange authors. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # all targets are PHONY because they don't actually generate a file with the |
| # name of the target. |
| .PHONY: setup test pylint lint localserver gitclean |
| .PHONY: pyunit functionaltest jstest _ptests ptest |
| |
| # try and avoid downloading things more than once. |
| DOWNLOAD_CACHE=/var/tmp/melange-download-cache-$(USER) |
| ifdef DOWNLOAD_CACHE |
| # where should bootstrap store its download cache? |
| DOWNLOAD_CACHE_ARG=download-cache=$(DOWNLOAD_CACHE) |
| # where should PIP store its download cache? |
| export PIP_DOWNLOAD_CACHE=$(DOWNLOAD_CACHE)/pip |
| export npm_config_cache=$(DOWNLOAD_CACHE)/npm |
| endif |
| |
| # bootstrap gets unhappy if the directory doesn't exist |
| $(DOWNLOAD_CACHE): |
| ifdef DOWNLOAD_CACHE |
| mkdir -p $(DOWNLOAD_CACHE) |
| endif |
| |
| # initial setup for the development environment |
| initial-setup: .initial-setup |
| .initial-setup: $(DOWNLOAD_CACHE) |
| virtualenv venv |
| venv/bin/pip install -U lxml setuptools |
| venv/bin/python bootstrap.py $(DOWNLOAD_CACHE_ARG) bootstrap |
| touch $@ |
| |
| # run buildout |
| buildout: .buildout |
| .buildout: $(DOWNLOAD_CACHE) buildout.cfg |
| bin/buildout $(DOWNLOAD_CACHE_ARG) |
| touch $@ |
| |
| # clear the sentinel files that prevent buildout and initial-setup from |
| # running again unless a dependency has changed. |
| clean-setup: |
| rm -f .buildout .initial-setup |
| echo now re-run 'make setup' |
| |
| # setup target sets up the basics of the development environment |
| setup: initial-setup buildout |
| bin/gen-app-yaml -f local-devel |
| bin/paver build --skip-pylint --skip-docs |
| |
| # force all setup dependencies to run again |
| force-setup: clean-setup setup |
| |
| # update python and js generated docs |
| docs: |
| bin/paver build_docs |
| bin/grunt yuidoc |
| |
| # run all the tests |
| test: |
| bin/run-tests |
| |
| # run only the lint tests |
| pylint: |
| bin/run-tests -t pylint |
| |
| lint: pylint |
| |
| # run only the pyunit tests |
| pyunit: PROCESSES=$(if $(PTESTS),4,-1) |
| pyunit: |
| bin/run-tests -t pyunit --processes=$(PROCESSES) |
| |
| functionaltest: |
| bin/run-tests -t functional |
| |
| jstest: |
| bin/run-tests -t js |
| |
| # helper target for ptest target (specifies which tests to run) |
| _ptests: PTESTS=1 |
| _ptests: functionaltest pyunit pylint jstest |
| @echo |
| |
| # run tests in parallel (note, output will be interleaved) |
| ptest: |
| make -j _ptests |
| |
| # build less files into css |
| css: |
| bin/grunt less |
| |
| # start a local instance. defaults to port 8080 for the app and 8000 |
| # for the appengine console |
| localserver: |
| thirdparty/google_appengine/dev_appserver.py build |
| |
| # return to a pristine git checkout. *DELETES EVERYTHING WITHOUT PROMPTING* |
| gitclean: |
| git clean -xdf |
| |
| # Targets related to making a release --- |
| # |
| # Usage: |
| # make do-release |
| # make do-release VERSION=custom-version |
| # make do-release APP=robert-melange |
| # |
| # after running a make gitclean && make setup && make test |
| |
| .PHONY: update-template-version commit-release push-release-to-appengine |
| .PHONY: do-release |
| |
| # Sets the version in app.yaml.template to the version as specified by |
| # the current day. |
| # If you need to specify a patchlevel (i.e. -1, -2), you must specify |
| # the whole VERSION on the make command line. |
| update-template-version: VERSION=2-1-$(shell date +%Y%m%d) |
| update-template-version: |
| sed -i.bak -r 's/^(version: )[^ \t]+/\1$(VERSION)/' app/app.yaml.template |
| |
| commit-release: VERSION=$(shell awk '/^version: / { print $$2 }' app/app.yaml.template) |
| commit-release: |
| git commit -e -m "Set new Melange version number to $(VERSION) in app.yaml.template" app/app.yaml.template |
| git tag v$(VERSION) HEAD |
| |
| # TODO(robert): factor gen-app-yaml into its own build target |
| # TODO(robert): set the default value of APP to local-devel? |
| push-release-to-appengine: |
| bin/gen-app-yaml -f $(APP) |
| thirdparty/google_appengine/appcfg.py --oauth2 update build |
| |
| do-release: APP=google-melange |
| do-release: update-template-version commit-release push-release-to-appengine |
| @echo |
| @echo ========================================================== |
| @echo Melange release $(VERSION) pushed successfully! |
| @echo 1. push the release commit to the repository |
| @echo git push origin master |
| @echo 2. go to the App Engine control panel and send it traffic |
| @echo https://appengine.google.com/deployment?app_id=s~$(APP) |