blob: 14f1cab4b0110effa45e275e33d642bd6d343010 [file] [log] [blame]
Alex Fandrianto3d881692015-08-27 19:28:30 -07001# This beginning section is used to setup the environment for running with mojo_shell.
Alex Fandrianto6c0b2fa2015-09-01 16:34:03 -07002ETHER_DIR := $(V23_ROOT)/release/mojo/syncbase
Alex Fandrianto3d881692015-08-27 19:28:30 -07003CROUPIER_DIR := $(shell pwd)
4SHELL := /bin/bash -euo pipefail
5
Alex Fandriantoa7f8d3d2015-09-03 18:11:13 -07006# 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?
8PATH := $(SKY_DIR)/src/third_party/dart-sdk/dart-sdk/bin:$(PATH)
9
Alex Fandrianto3d881692015-08-27 19:28:30 -070010ifdef 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
18else
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
24endif
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.
30MOJO_SHELL_FLAGS := -v --enable-multiprocess \
Alex Fandrianto3d881692015-08-27 19:28:30 -070031 --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 Fandrianto598a93c2015-08-25 10:47:25 -070040# Get the packages used by the dart project, according to pubspec.yaml
Alex Fandriantoe74249f2015-08-25 18:34:30 -070041# Can also use `pub get`, but Sublime occasionally reverts me to an ealier version.
42# Only `pub upgrade` can escape such a thing.
Alex Fandrianto3d881692015-08-27 19:28:30 -070043packages: pubspec.yaml
Alex Fandrianto598a93c2015-08-25 10:47:25 -070044 pub upgrade
Alex Fandrianto7efccfd2015-08-12 18:48:03 -070045
Alex Fandrianto3d881692015-08-27 19:28:30 -070046DART_LIB_FILES := $(shell find lib -name *.dart ! -name *.part.dart)
47DART_TEST_FILES := $(shell find test -name *.dart ! -name *.part.dart)
Alex Fandrianto598a93c2015-08-25 10:47:25 -070048
Alex Fandrianto3d881692015-08-27 19:28:30 -070049.PHONY: dartfmt
50dartfmt:
51 dartfmt -w $(DART_LIB_FILES) $(DART_TEST_FILES)
Alex Fandrianto598a93c2015-08-25 10:47:25 -070052
Alex Fandrianto3d881692015-08-27 19:28:30 -070053.PHONY: lint
Nicolas Lacasse48f74202015-09-10 11:33:36 -070054lint: packages
Alex Fandriantocbf5fa22015-09-01 14:59:01 -070055 dartanalyzer lib/main.dart | grep -v "\[warning\] The imported libraries"
56 dartanalyzer $(DART_TEST_FILES) | grep -v "\[warning\] The imported libraries"
Alex Fandrianto598a93c2015-08-25 10:47:25 -070057
Alex Fandrianto3d881692015-08-27 19:28:30 -070058.PHONY: start
Nicolas Lacasse48f74202015-09-10 11:33:36 -070059start: packages
Alex Fandriantocbf5fa22015-09-01 14:59:01 -070060 ./packages/sky/sky_tool start --checked
61
62.PHONY: mock
63mock:
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
68unmock:
69 mv lib/src/syncbase/log_writer.dart.backup lib/src/syncbase/log_writer.dart
Alex Fandrianto7efccfd2015-08-12 18:48:03 -070070
Alex Fandrianto3d881692015-08-27 19:28:30 -070071.PHONY: install
72install: packages
Alex Fandriantocbf5fa22015-09-01 14:59:01 -070073 ./packages/sky/sky_tool start --install --checked
Alex Fandrianto598a93c2015-08-25 10:47:25 -070074
Alex Fandrianto3d881692015-08-27 19:28:30 -070075.PHONY: env-check
76env-check:
77ifndef MOJO_DIR
78 $(error MOJO_DIR is not set)
79endif
80ifndef SKY_DIR
81 $(error SKY_DIR is not set)
82endif
83ifndef V23_ROOT
84 $(error V23_ROOT is not set)
85endif
86ifeq ($(wildcard $(MOJO_BUILD_DIR)),)
87 $(error ERROR: $(MOJO_BUILD_DIR) does not exist. Please see README.md for instructions on compiling Mojo resources.)
88endif
Alex Fandrianto598a93c2015-08-25 10:47:25 -070089
Alex Fandrianto3d881692015-08-27 19:28:30 -070090# 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
93start-with-mojo: env-check packages
Nicolas Lacasse48f74202015-09-10 11:33:36 -070094 $(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 Fandrianto3d881692015-08-27 19:28:30 -070095
Alex Fandrianto3d881692015-08-27 19:28:30 -070096# 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
99test: packages
Alex Fandriantocbf5fa22015-09-01 14:59:01 -0700100 # 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 Fandrianto3d881692015-08-27 19:28:30 -0700105
106.PHONY: clean
Alex Fandrianto598a93c2015-08-25 10:47:25 -0700107clean:
Nicolas Lacasse48f74202015-09-10 11:33:36 -0700108 rm -rf .packages packages .pubspec.lock