Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 1 | ## |
| 2 | # Provides targets to build, test and run the Veyron Browser application. |
| 3 | # |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 4 | # make # Builds the project. |
| 5 | # make test # Runs unit and integration tests. |
Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 6 | # make start # Starts the services and http server needed to run the application at http://localhost:9000 |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 7 | # make clean # Deleted all build, testing and other artifacts. |
Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 8 | # |
| 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 Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 16 | PATH:=$(VEYRON_ROOT)/environment/cout/node/bin:$(PATH) |
| 17 | PATH:=node_modules/.bin:$(PATH) |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 18 | ifndef TMPDIR |
| 19 | export TMPDIR:=/tmp |
| 20 | endif |
| 21 | TMPDIR:=$(TMPDIR)/veyron_browser |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 22 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 23 | # All JS and CSS files except build.js and third party. |
Ali Ghassemi | 8d21ded | 2014-08-06 10:11:28 -0700 | [diff] [blame] | 24 | BROWSERIFY_FILES = $(shell find src -name "*.js" -o -name "*.css") |
Alex Fandrianto | 0c09b31 | 2014-10-31 13:41:39 -0700 | [diff] [blame] | 25 | BROWSERIFY_OPTIONS = --transform ./main-transform --debug |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 26 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 27 | # All Go and VDL files. |
Alex Fandrianto | 560fc9a | 2014-08-18 18:09:55 -0700 | [diff] [blame] | 28 | GO_FILES = $(shell find go -name "*.go") |
| 29 | VDL_FILES = $(shell find go -name "*.vdl") |
| 30 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 31 | # Builds everything. |
Ali Ghassemi | 41a3c4f | 2014-11-20 14:45:58 -0800 | [diff] [blame^] | 32 | all: directories public/bundle.js public/bundle.html |
Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 33 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 34 | # Creating the bundle JS file. |
Ali Ghassemi | 8d21ded | 2014-08-06 10:11:28 -0700 | [diff] [blame] | 35 | public/bundle.js: $(BROWSERIFY_FILES) node_modules |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 36 | :;jshint src # lint all src JavaScript files. |
| 37 | :;browserify src/app.js $(BROWSERIFY_OPTIONS) $< | exorcist $@.map > $@ # Browserify and generate map file. |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 38 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 39 | # Creating the bundle HTML file. |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 40 | public/bundle.html: web-component-dependencies.html node_modules bower_components |
aghassemi | a3af206 | 2014-09-03 14:16:38 -0700 | [diff] [blame] | 41 | :;vulcanize --output public/bundle.html web-component-dependencies.html --inline |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 42 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 43 | # Install what we need from NPM. |
Ali Ghassemi | 6e0648c | 2014-10-30 15:46:15 -0700 | [diff] [blame] | 44 | node_modules: package.json |
aghassemi | a3af206 | 2014-09-03 14:16:38 -0700 | [diff] [blame] | 45 | :;npm prune |
| 46 | :;npm install |
Ali Ghassemi | 6e0648c | 2014-10-30 15:46:15 -0700 | [diff] [blame] | 47 | # TODO(aghassemi) Temporarily use local veyron.js add github/npm to package.json later |
Ali Ghassemi | ca292bb | 2014-10-09 12:08:05 -0700 | [diff] [blame] | 48 | cd "$(VEYRON_ROOT)/veyron.js" && npm link |
| 49 | :;npm link veyron |
Ali Ghassemi | 8500c7a | 2014-11-14 13:32:15 -0800 | [diff] [blame] | 50 | cd "$(VEYRON_ROOT)/veyron/javascript/vom" && npm link |
| 51 | :;npm link vom |
Ali Ghassemi | ca292bb | 2014-10-09 12:08:05 -0700 | [diff] [blame] | 52 | |
Ali Ghassemi | 6e0648c | 2014-10-30 15:46:15 -0700 | [diff] [blame] | 53 | touch node_modules |
| 54 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 55 | # Install non-JS dependencies from bower. |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 56 | bower_components: bower.json node_modules |
aghassemi | a3af206 | 2014-09-03 14:16:38 -0700 | [diff] [blame] | 57 | :;bower prune |
| 58 | :;bower install |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 59 | touch bower_components |
| 60 | |
| 61 | # PHONY targets: |
| 62 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 63 | # Run unit and integration tests. |
Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 64 | test: all |
Ali Ghassemi | 9afb388 | 2014-10-08 10:44:32 -0700 | [diff] [blame] | 65 | :;jshint test # lint all test JavaScript files. |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 66 | :;./scripts/services/run-tests.sh |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 67 | |
| 68 | # Continuously watch for changes to .js, .html or .css files. |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 69 | # Rebundles the appropriate bundles when local files change. |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 70 | watch: |
| 71 | watch -n 1 make |
| 72 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 73 | # Continuously reruns the tests as they change. |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 74 | watch-test: |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 75 | :;PROVA_WATCH=true ./scripts/services/run-tests.sh |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 76 | |
Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 77 | # Serves the needed daemons and starts a server at http://localhost:9000 |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 78 | # CTRL-C to stop |
Nicolas LaCasse | a234096 | 2014-08-18 17:05:32 -0700 | [diff] [blame] | 79 | start: all |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 80 | :;./scripts/services/run-webapp.sh |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 81 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 82 | # Create needed directories like temp. |
| 83 | directories: |
| 84 | mkdir -p $(TMPDIR) |
| 85 | |
| 86 | # Clean all build artifacts. |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 87 | clean: |
Ali Ghassemi | e58f4b1 | 2014-10-03 10:10:51 -0700 | [diff] [blame] | 88 | rm -f public/bundle.* |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 89 | rm -rf node_modules |
Ali Ghassemi | cbe23cf | 2014-09-12 14:28:54 -0700 | [diff] [blame] | 90 | rm -rf go/bin |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 91 | rm -rf bower_components |
Ali Ghassemi | a35f042 | 2014-09-26 09:04:04 -0700 | [diff] [blame] | 92 | rm -rf $(TMPDIR) |
Ali Ghassemi | df9e1fe | 2014-07-31 12:26:22 -0700 | [diff] [blame] | 93 | |
Ali Ghassemi | 6e18f56 | 2014-09-26 13:47:41 -0700 | [diff] [blame] | 94 | .PHONY: start clean watch test watch-test directories |