-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
211 lines (146 loc) · 4.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# This file contains rules to build the server binary, the client
# javascript code, and the stylesheets. In addition, there are some
# development helpers and a 'deploy' task.
# Paths to executable tools
CSS_PREFIXER = node_modules/.bin/autoprefixer
AMD_BUILD = bin/amd-build
export PATH := node_modules/.bin/:$(PATH)
# Directory containing the assets (JS, CSS) that are served by the
# server
ASSETS = assets
.PHONY: web client first all dev
first: all
all: server client
dev: server client-dev
# DEVELOPMENT AND DEPLOYMENT
.PHONY: deploy
deploy: web
git push
ssh [email protected] bash < scripts/deploy.sh
rsync --archive assets [email protected]:www/pladen
.PHONY: test
test: test/* webapp-dev
karma start --port 12001 --single-run
# Install tools and utilities required for building the application
build-deps: server-deps client-deps
docs:
cabal haddock --executables
.PHONY: clean
clean: client-clean
cabal clean
rm $(CABAL_DEPS)
.PHONY: todo
todo:
@ack-grep '[T]ODO .*' client/ Pladen/ test/ --no-heading -o --nojs
# BROWSER APPLICATION
#
# Compiles the styles with Sass and the client with TypeScript,
# CoffeeScript and RequireJS. Creates the targets in the assets
# directory.
# Install the tools and vendor libraries that are required to build the
# client
.PHONY: client-deps
client-deps:
npm install
bower install
which sass || gem install sass
.PHONY: client client-dev
client: styles webapp
client-dev: styles webapp-dev
.PHONY: client-clean
client-clean:
find client -name '*.js' -exec rm {} \;
rm -rf $(ASSETS)/*
# TypeScript and CoffeeScript files in the 'client' directory that make
# up the browser application and have to be compiled to JavaScript.
WEBAPP_SOURCES=$(filter-out %.d.ts,\
$(shell find client -name '*.coffee' -or -name '*.ts'))
# JavaScript files that are generated from the client sources
WEBAPP_TARGETS:=$(WEBAPP_SOURCES:%.coffee=%.js)
WEBAPP_TARGETS:=$(WEBAPP_TARGETS:%.ts=%.js)
# Compiled client side application for production
WEBAPP = $(ASSETS)/boot.js
# Vendor components that are included in the webapp builds.
BOWER_COMPONENTS = $(shell find bower_components -name .bower.json)
webapp: $(WEBAPP)
# Link the client javascript file into a bundle using RequireJS
$(WEBAPP): $(AMD_BUILD) $(WEBAPP_TARGETS) $(BOWER_COMPONENTS)
$< client $@
# The development application only contains vendor. RequireJS loads the
# client code from the `client` directory.
WEBAPP_DEV = $(ASSETS)/boot.dev.js
webapp-dev: $(WEBAPP_DEV) $(WEBAPP_TARGETS)
$(WEBAPP_DEV): $(AMD_BUILD) $(BOWER_COMPONENTS)
$< vendor $@
# Rules
%.js: %.coffee
@echo -n COFFEE $< ...
@coffee --compile $<
@echo OK
%.js: %.ts
@echo -n tsc $< ...
@tsc --module amd --target ES5 $<
@echo OK
# Built the main stylesheet with SASS
STYLE = $(ASSETS)/style.css
STYLE_MAIN_SOURCE = styles/main.scss
STYLE_INCLUDES = $(shell find styles -type f) $(ICOMOON_STYLE)
TEST_STYLE=test/interact/style.css
TEST_STYLE_SOURCE=test/interact/style.scss
styles: $(STYLE) $(TEST_STYLE) icomoon
$(STYLE): $(STYLE_MAIN_SOURCE) $(STYLE_INCLUDES)
scss --load-path styles \
--require ./styles/functions.rb \
--sourcemap=none \
$< $@
$(CSS_PREFIXER) $@
$(TEST_STYLE): $(TEST_STYLE_SOURCE) $(STYLE)
scss --load-path styles \
--require ./styles/functions.rb \
--sourcemap=none \
$< $@
$(CSS_PREFIXER) $@
# IcoMoon fonts and styles will be added to the assets
ICOMOON_EXT = svg woff ttf eot
ICOMOON_FONTS = $(ICOMOON_EXT:%=static/assets/fonts/icomoon.%)
ICOMOON_STYLE = styles/icons.scss
icomoon: $(ICOMOON_FONTS) $(ICOMOON_STYLE)
$(ICOMOON_FONTS): static/assets/%: icomoon/%
cp $< $@
$(ICOMOON_STYLE): icomoon/style.css
cp $< $@
# SERVER
#
# Uses cabal to build the server executable. Also makes sure that all
# cabal dependencies are installed in the sandbox.
# The server binary
SERVER_BIN = bin/server
# The server binary, built by 'cabal'
CABAL_SERVER_BIN = dist/build/server/server
# Source files the server is built from
SERVER_SOURCES = $(shell find Pladen -name '*.hs')
# Install all dependencies in the cabal package configuration to the
# local sandbox.
CABAL_DEPS = .cabal-sandbox/install-timestamp
CABAL_SANDBOX = cabal.sandbox.config
.PHONY: server
server: $(SERVER_BIN)
$(SERVER_BIN): $(CABAL_SERVER_BIN)
#cp -af $< $@
$(CABAL_SERVER_BIN): $(CABAL_DEPS) $(SERVER_SOURCES)
cabal build
touch $@
.PHONY: server-deps
server-deps: $(CABAL_DEPS)
$(CABAL_DEPS): pladen.cabal $(CABAL_SANDBOX)
cabal install --dependencies-only
touch $@
# Create the cabal sandbox
$(CABAL_SANDBOX):
cabal sandbox init
# More development tasks
# Generate tags for project and cabal packages
tags: $(SERVER_SOURCES) codex.tags
hasktags --ctags $(SERVER_SOURCES)
codex.tags: $(CABAL_DEPS)
codex update