Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 1 | # This beginning section is used to setup the environment for running with mojo_shell. |
Alex Fandrianto | 6c0b2fa | 2015-09-01 16:34:03 -0700 | [diff] [blame] | 2 | ETHER_DIR := $(V23_ROOT)/release/mojo/syncbase |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 3 | CROUPIER_DIR := $(shell pwd) |
| 4 | SHELL := /bin/bash -euo pipefail |
| 5 | |
Alex Fandrianto | a7f8d3d | 2015-09-03 18:11:13 -0700 | [diff] [blame] | 6 | # Sky wants us to use a later version of pub, so just in case, use theirs when getting packages. |
| 7 | # TODO(alexfandrianto): How do I update my actual pub and my sublime pub? |
| 8 | PATH := $(SKY_DIR)/src/third_party/dart-sdk/dart-sdk/bin:$(PATH) |
| 9 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 10 | ifdef ANDROID |
| 11 | MOJO_ANDROID_FLAGS := --android |
| 12 | |
| 13 | MOJO_BUILD_DIR := $(MOJO_DIR)/src/out/android_Debug |
| 14 | SKY_BUILD_DIR := $(SKY_DIR)/src/out/android_Debug |
| 15 | ETHER_BUILD_DIR := $(ETHER_DIR)/gen/mojo/android |
| 16 | |
| 17 | SYNCBASE_DATA_DIR := /data/data/org.chromium.mojo.shell/app_home/syncbase_data |
| 18 | else |
| 19 | MOJO_BUILD_DIR := $(MOJO_DIR)/src/out/Debug |
| 20 | SKY_BUILD_DIR := $(SKY_DIR)/src/out/Debug |
| 21 | ETHER_BUILD_DIR := $(ETHER_DIR)/gen/mojo/linux_amd64 |
| 22 | |
| 23 | SYNCBASE_DATA_DIR := /tmp/syncbase_data |
| 24 | endif |
| 25 | |
| 26 | # NOTE(nlacasse): Running Go Mojo services requires passing the |
| 27 | # --enable-multiprocess flag to mojo_shell. This is because the Go runtime is |
| 28 | # very large, and can interfere with C++ memory if they are in the same |
| 29 | # process. |
| 30 | MOJO_SHELL_FLAGS := -v --enable-multiprocess \ |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 31 | --config-alias SKY_DIR=$(SKY_DIR) \ |
| 32 | --config-alias SKY_BUILD_DIR=$(SKY_BUILD_DIR) \ |
| 33 | --config-alias ETHER_DIR=$(ETHER_DIR) \ |
| 34 | --config-alias ETHER_BUILD_DIR=$(ETHER_BUILD_DIR) \ |
| 35 | --config-alias CROUPIER_DIR=$(CROUPIER_DIR) |
| 36 | |
| 37 | |
| 38 | .DELETE_ON_ERROR: |
| 39 | |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 40 | # Get the packages used by the dart project, according to pubspec.yaml |
Alex Fandrianto | e74249f | 2015-08-25 18:34:30 -0700 | [diff] [blame] | 41 | # Can also use `pub get`, but Sublime occasionally reverts me to an ealier version. |
| 42 | # Only `pub upgrade` can escape such a thing. |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 43 | packages: pubspec.yaml |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 44 | pub upgrade |
Alex Fandrianto | 7efccfd | 2015-08-12 18:48:03 -0700 | [diff] [blame] | 45 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 46 | DART_LIB_FILES := $(shell find lib -name *.dart ! -name *.part.dart) |
| 47 | DART_TEST_FILES := $(shell find test -name *.dart ! -name *.part.dart) |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 48 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 49 | .PHONY: dartfmt |
| 50 | dartfmt: |
| 51 | dartfmt -w $(DART_LIB_FILES) $(DART_TEST_FILES) |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 52 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 53 | .PHONY: lint |
Nicolas Lacasse | 48f7420 | 2015-09-10 11:33:36 -0700 | [diff] [blame] | 54 | lint: packages |
Alex Fandrianto | cbf5fa2 | 2015-09-01 14:59:01 -0700 | [diff] [blame] | 55 | dartanalyzer lib/main.dart | grep -v "\[warning\] The imported libraries" |
| 56 | dartanalyzer $(DART_TEST_FILES) | grep -v "\[warning\] The imported libraries" |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 57 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 58 | .PHONY: start |
Nicolas Lacasse | 48f7420 | 2015-09-10 11:33:36 -0700 | [diff] [blame] | 59 | start: packages |
Alex Fandrianto | cbf5fa2 | 2015-09-01 14:59:01 -0700 | [diff] [blame] | 60 | ./packages/sky/sky_tool start --checked |
| 61 | |
| 62 | .PHONY: mock |
| 63 | mock: |
| 64 | mv lib/src/syncbase/log_writer.dart lib/src/syncbase/log_writer.dart.backup |
| 65 | cp lib/src/mocks/log_writer.dart lib/src/syncbase/ |
| 66 | |
| 67 | .PHONY: unmock |
| 68 | unmock: |
| 69 | mv lib/src/syncbase/log_writer.dart.backup lib/src/syncbase/log_writer.dart |
Alex Fandrianto | 7efccfd | 2015-08-12 18:48:03 -0700 | [diff] [blame] | 70 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 71 | .PHONY: install |
| 72 | install: packages |
Alex Fandrianto | cbf5fa2 | 2015-09-01 14:59:01 -0700 | [diff] [blame] | 73 | ./packages/sky/sky_tool start --install --checked |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 74 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 75 | .PHONY: env-check |
| 76 | env-check: |
| 77 | ifndef MOJO_DIR |
| 78 | $(error MOJO_DIR is not set) |
| 79 | endif |
| 80 | ifndef SKY_DIR |
| 81 | $(error SKY_DIR is not set) |
| 82 | endif |
| 83 | ifndef V23_ROOT |
| 84 | $(error V23_ROOT is not set) |
| 85 | endif |
| 86 | ifeq ($(wildcard $(MOJO_BUILD_DIR)),) |
| 87 | $(error ERROR: $(MOJO_BUILD_DIR) does not exist. Please see README.md for instructions on compiling Mojo resources.) |
| 88 | endif |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 89 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 90 | # Run the Sky program with mojo shell. This allows use of Syncbase and Mojo. |
| 91 | # If syncbase doesn't load, it could be that port 4002 is still in use; try fuser 4002/tcp. |
| 92 | .PHONY: start-with-mojo |
| 93 | start-with-mojo: env-check packages |
Nicolas Lacasse | 48f7420 | 2015-09-10 11:33:36 -0700 | [diff] [blame] | 94 | $(MOJO_DIR)/src/mojo/devtools/common/mojo_run --config-file $(PWD)/mojoconfig $(MOJO_SHELL_FLAGS) $(MOJO_ANDROID_FLAGS) 'https://core.mojoapps.io/kiosk_wm.mojo https://croupier.v.io/lib/main.dart' |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 95 | |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 96 | # TODO(alexfandrianto): I split off the syncbase logic from game.dart because it |
| 97 | # would not run in a stand-alone VM. We will need to add mojo_test eventually. |
| 98 | .PHONY: test |
| 99 | test: packages |
Alex Fandrianto | cbf5fa2 | 2015-09-01 14:59:01 -0700 | [diff] [blame] | 100 | # Protect src/syncbase/log_writer.dart |
| 101 | mv lib/src/syncbase/log_writer.dart lib/src/syncbase/log_writer.dart.backup |
| 102 | cp lib/src/mocks/log_writer.dart lib/src/syncbase/ |
| 103 | pub run test -r expanded $(DART_TEST_FILES) || (mv lib/src/syncbase/log_writer.dart.backup lib/src/syncbase/log_writer.dart && exit 1) |
| 104 | mv lib/src/syncbase/log_writer.dart.backup lib/src/syncbase/log_writer.dart |
Alex Fandrianto | 3d88169 | 2015-08-27 19:28:30 -0700 | [diff] [blame] | 105 | |
| 106 | .PHONY: clean |
Alex Fandrianto | 598a93c | 2015-08-25 10:47:25 -0700 | [diff] [blame] | 107 | clean: |
Nicolas Lacasse | 48f7420 | 2015-09-10 11:33:36 -0700 | [diff] [blame] | 108 | rm -rf .packages packages .pubspec.lock |