blob: 2bd460eea6eff3c8ebc75896f3d00a441a9e58f8 [file] [log] [blame]
Ali Ghassemia35f0422014-09-26 09:04:04 -07001##
2# Provides targets to build, test and run the Veyron Browser application.
3#
Ali Ghassemi6e18f562014-09-26 13:47:41 -07004# make # Builds the project.
5# make test # Runs unit and integration tests.
Ali Ghassemia35f0422014-09-26 09:04:04 -07006# make start # Starts the services and http server needed to run the application at http://localhost:9000
Ali Ghassemi6e18f562014-09-26 13:47:41 -07007# make clean # Deleted all build, testing and other artifacts.
Ali Ghassemia35f0422014-09-26 09:04:04 -07008#
9# Note: :; at the beginning of commands is a work-around for an issue in MacOS version of GNU `make` where
10# `make` may not invoke shell to run a command if command is deemed simple enough causing environment variables
11# like PATH that are modified here not to be used.
12# :; tricks make to assume command is not simple and needs to invoke shell.
13# see http://stackoverflow.com/questions/21708839/problems-setting-path-in-makefile for details.
14##
15
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070016PATH:=$(VEYRON_ROOT)/environment/cout/node/bin:$(PATH)
17PATH:=node_modules/.bin:$(PATH)
Ali Ghassemi6e18f562014-09-26 13:47:41 -070018ifndef TMPDIR
19 export TMPDIR:=/tmp
20endif
21TMPDIR:=$(TMPDIR)/veyron_browser
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070022
Ali Ghassemi6e18f562014-09-26 13:47:41 -070023# All JS and CSS files except build.js and third party.
Ali Ghassemi8d21ded2014-08-06 10:11:28 -070024BROWSERIFY_FILES = $(shell find src -name "*.js" -o -name "*.css")
Alex Fandrianto0c09b312014-10-31 13:41:39 -070025BROWSERIFY_OPTIONS = --transform ./main-transform --debug
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070026
Ali Ghassemi6e18f562014-09-26 13:47:41 -070027# All Go and VDL files.
Alex Fandrianto560fc9a2014-08-18 18:09:55 -070028GO_FILES = $(shell find go -name "*.go")
29VDL_FILES = $(shell find go -name "*.vdl")
30
Ali Ghassemi6e18f562014-09-26 13:47:41 -070031# Builds everything.
Ali Ghassemi41a3c4f2014-11-20 14:45:58 -080032all: directories public/bundle.js public/bundle.html
Ali Ghassemia35f0422014-09-26 09:04:04 -070033
Ali Ghassemi6e18f562014-09-26 13:47:41 -070034# Creating the bundle JS file.
Ali Ghassemi8d21ded2014-08-06 10:11:28 -070035public/bundle.js: $(BROWSERIFY_FILES) node_modules
Ali Ghassemi6e18f562014-09-26 13:47:41 -070036 :;jshint src # lint all src JavaScript files.
37 :;browserify src/app.js $(BROWSERIFY_OPTIONS) $< | exorcist $@.map > $@ # Browserify and generate map file.
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070038
Ali Ghassemi6e18f562014-09-26 13:47:41 -070039# Creating the bundle HTML file.
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070040public/bundle.html: web-component-dependencies.html node_modules bower_components
aghassemia3af2062014-09-03 14:16:38 -070041 :;vulcanize --output public/bundle.html web-component-dependencies.html --inline
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070042
Ali Ghassemi6e18f562014-09-26 13:47:41 -070043# Install what we need from NPM.
Ali Ghassemi6e0648c2014-10-30 15:46:15 -070044node_modules: package.json
aghassemia3af2062014-09-03 14:16:38 -070045 :;npm prune
46 :;npm install
Ali Ghassemi6e0648c2014-10-30 15:46:15 -070047 # TODO(aghassemi) Temporarily use local veyron.js add github/npm to package.json later
Ali Ghassemica292bb2014-10-09 12:08:05 -070048 cd "$(VEYRON_ROOT)/veyron.js" && npm link
49 :;npm link veyron
Ali Ghassemi8500c7a2014-11-14 13:32:15 -080050 cd "$(VEYRON_ROOT)/veyron/javascript/vom" && npm link
51 :;npm link vom
Ali Ghassemica292bb2014-10-09 12:08:05 -070052
Ali Ghassemi6e0648c2014-10-30 15:46:15 -070053 touch node_modules
54
Ali Ghassemi6e18f562014-09-26 13:47:41 -070055# Install non-JS dependencies from bower.
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070056bower_components: bower.json node_modules
aghassemia3af2062014-09-03 14:16:38 -070057 :;bower prune
58 :;bower install
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070059 touch bower_components
60
61# PHONY targets:
62
Ali Ghassemi6e18f562014-09-26 13:47:41 -070063# Run unit and integration tests.
Ali Ghassemia35f0422014-09-26 09:04:04 -070064test: all
Ali Ghassemi9afb3882014-10-08 10:44:32 -070065 :;jshint test # lint all test JavaScript files.
Ali Ghassemi6e18f562014-09-26 13:47:41 -070066 :;./scripts/services/run-tests.sh
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070067
68# Continuously watch for changes to .js, .html or .css files.
Ali Ghassemi6e18f562014-09-26 13:47:41 -070069# Rebundles the appropriate bundles when local files change.
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070070watch:
71 watch -n 1 make
72
Ali Ghassemi6e18f562014-09-26 13:47:41 -070073# Continuously reruns the tests as they change.
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070074watch-test:
Ali Ghassemi6e18f562014-09-26 13:47:41 -070075 :;PROVA_WATCH=true ./scripts/services/run-tests.sh
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070076
Ali Ghassemia35f0422014-09-26 09:04:04 -070077# Serves the needed daemons and starts a server at http://localhost:9000
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070078# CTRL-C to stop
Nicolas LaCassea2340962014-08-18 17:05:32 -070079start: all
Ali Ghassemi6e18f562014-09-26 13:47:41 -070080 :;./scripts/services/run-webapp.sh
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070081
Ali Ghassemi6e18f562014-09-26 13:47:41 -070082# Create needed directories like temp.
83directories:
84 mkdir -p $(TMPDIR)
85
86# Clean all build artifacts.
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070087clean:
Ali Ghassemie58f4b12014-10-03 10:10:51 -070088 rm -f public/bundle.*
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070089 rm -rf node_modules
Ali Ghassemicbe23cf2014-09-12 14:28:54 -070090 rm -rf go/bin
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070091 rm -rf bower_components
Ali Ghassemia35f0422014-09-26 09:04:04 -070092 rm -rf $(TMPDIR)
Ali Ghassemidf9e1fe2014-07-31 12:26:22 -070093
Ali Ghassemi6e18f562014-09-26 13:47:41 -070094.PHONY: start clean watch test watch-test directories