Debian Codegraph @

ivette/src/dome/template/makefile

raw
1 # --------------------------------------------------------------------------
2 # --- Main Makefile for building Dome applications
3 # --------------------------------------------------------------------------
4
5 # DOMEMK_ reserved for makefile derived variables
6
7 APP?=$(shell basename $(CURDIR))
8 COPYRIGHT?=CEA Tech
9
10 DOME_MK_NAME=$(shell echo $(APP) | tr [:upper:] [:lower:])
11
12 DOME?=dome
13 DOME_ARGS?=
14 DOME_DEV_ARGS?=
15 DOME_APP_ARGS?=
16 DOME_CLI?=./bin/$(DOME_MK_NAME)
17 DOME_DOC?=./doc/html
18 DOME_API?=
19
20 # --------------------------------------------------------------------------
21 # --- Makefile Help
22 # --------------------------------------------------------------------------
23
24 .PHONY: dome-help
25
26 dome-help:
27 @echo
28 @echo "[Dome] Builtin Targets:"
29 @echo " make dome-help This help"
30 @echo " make dome-dev Run application in development mode"
31 @echo " make dome-app Compile application"
32 @echo " make dome-dist Package application for production"
33 @echo " make dome-doc Generate Dome documentation"
34 @echo " make dome-api Generate Application documentation"
35 @echo " make dome-pkg Install development packages"
36 @echo " make dome-templ Update templates"
37 @echo " make dome-reboot Rebuild templates from scratch"
38 @echo " make dome-clean Remove dome temporary files"
39 @echo
40 @echo "[Dome] Development:"
41 @echo " Dome framework DOME = '$(DOME)'"
42 @echo " Local command DOME_CLI = '$(DOME_CLI)'"
43 @echo " Local arguments DOME_ARGS = '$(DOME_ARGS)'"
44 @echo " Extra arg.(dev) DOME_DEV = '$(DOME_DEV)'"
45 @echo
46 @echo "[Dome] Documentation:"
47 @echo " Application APP = '$(APP)'"
48 @echo " Copyright COPYRIGHT = '$(COPYRIGHT)'"
49 @echo " Output dir DOME_DOC = '$(DOME_DOC)'"
50 @echo " Public API DOME_API = '$(DOME_API)'"
51 @echo
52
53 # --------------------------------------------------------------------------
54 # --- Application Cleaning
55 # --------------------------------------------------------------------------
56
57 .PHONY: dome-clean
58
59 dome-clean:
60 @echo "[Dome] remove temporary files"
61 @rm -fr dist .dome-*.stamp
62
63 # --------------------------------------------------------------------------
64 # --- Development Packages Init & Installation
65 # --------------------------------------------------------------------------
66
67 .PHONY: dome-pkg
68
69 include $(DOME)/template/makefile.packages
70
71 DOME_MK_BIN=$(CURDIR)/node_modules/.bin
72 DOME_MK_PKG= \
73 package.json node_modules \
74 $(DOME)/template/makefile.packages \
75 $(DOME)/template/package.sh
76
77 node_modules:
78 mkdir $@
79
80 dome-pkg: .dome-pkg.stamp
81 .dome-pkg.stamp: $(DOME_MK_PKG)
82 @echo "[Dome] ----------------------------------------------------------------"
83 @echo "[Dome] installing development packages"
84 @echo "[Dome] ----------------------------------------------------------------"
85 @$(DOME)/template/package.sh --dev $(DOME_DEV_PACKAGES)
86 @echo "[Dome] ----------------------------------------------------------------"
87 @echo "[Dome] installing application packages"
88 @echo "[Dome] ----------------------------------------------------------------"
89 @$(DOME)/template/package.sh --app $(DOME_APP_PACKAGES)
90 @echo "[Dome] ----------------------------------------------------------------"
91 @echo "[Dome] building application dependencies"
92 @echo "[Dome] ----------------------------------------------------------------"
93 yarn install
94 yarn run electron-builder install-app-deps
95 @touch $@
96
97 package.json:
98 yarn init
99
100 # --------------------------------------------------------------------------
101 # --- Dome Synchronization
102 # --------------------------------------------------------------------------
103
104 ifneq ("$(DOME)",".")
105
106 .PHONY: dome-pull dome-push
107
108 dome-pull:
109 @echo "[Dome] ----------------------------------------------------------------"
110 @echo "[Dome] Synchronize with updates"
111 @echo "[Dome] ----------------------------------------------------------------"
112 @(cd $(DOME) && ./template/dome-pull.sh)
113
114 dome-push:
115 @echo "[Dome] ----------------------------------------------------------------"
116 @echo "[Dome] Publishing Dome updates to feature/app/$(DOME_MK_NAME)"
117 @echo "[Dome] ----------------------------------------------------------------"
118 @(cd $(DOME) && ./template/dome-push.sh feature/app/$(DOME_MK_NAME))
119
120 endif
121
122 # --------------------------------------------------------------------------
123 # --- Application Templating
124 # --------------------------------------------------------------------------
125
126 .PHONY: dome-templ dome-reboot
127
128 DOME_MK_TEMPLATES= \
129 .gitignore \
130 .babelrc \
131 webpack.main.js \
132 webpack.renderer.js \
133 electron-webpack.json \
134 src/main/index.js \
135 src/renderer/index.js
136
137 dome-templ: $(DOME_MK_TEMPLATES)
138 dome-reboot:
139 echo "[Dome] Backup templates"
140 @for f in $(DOME_MK_TEMPLATES) ; do mv -fv $$f $$f.backup ; done
141 $(MAKE) dome-templ dome-pkg
142
143 # Templated files
144
145 ifeq ("$(DOME)",".")
146 .gitignore:
147 @cp -f $(DOME)/template/git-ignore $@
148 else
149 .gitignore: $(DOME)/template/update.sh $(DOME)/template/git-ignore
150 @((tail -r $(DOME)/template/git-ignore | tail -n +3 | tail -r) || head -n -3 $(DOME)/template/git-ignore) > $(DOME)/template/git-ignore.local
151 @echo "/$(DOME)" >> $(DOME)/template/git-ignore.local
152 @tail -2 $(DOME)/template/git-ignore >> $(DOME)/template/git-ignore.local
153 @$^.local $@
154 @rm -f $(DOME)/template/git-ignore.local
155 endif
156
157 .babelrc: $(DOME)/template/update.sh $(DOME)/template/babelrc.json
158 @$^ $@
159
160 webpack.main.js: $(DOME)/template/update.sh $(DOME)/template/webpack.main.js
161 @$^ $@
162
163 webpack.renderer.js: $(DOME)/template/update.sh $(DOME)/template/webpack.renderer.js
164 @$^ $@
165
166 electron-webpack.json: $(DOME)/template/update.sh $(DOME)/template/electron-webpack.json
167 @$^ $@
168
169 src/renderer/index.js: $(DOME)/template/update.sh $(DOME)/template/renderer.js
170 @$^ $@
171
172 src/main/index.js: $(DOME)/template/update.sh $(DOME)/template/main.js
173 @cp $(DOME)/template/main.js $(DOME)/template/main.js.local
174 @echo "Dome.setName('$(APP)');" >> $(DOME)/template/main.js.local
175 @echo "Dome.start();" >> $(DOME)/template/main.js.local
176 @$^.local $@
177 @rm -f $(DOME)/template/main.js.local
178
179 # --------------------------------------------------------------------------
180 # --- Custom Entry Points
181 # --------------------------------------------------------------------------
182
183 ifndef DOME_CUSTOM_ENTRIES
184
185 dome-templ: src/renderer/Application.js
186 src/renderer/Application.js:
187 @echo "[Dome] creating $@ from template"
188 @mkdir -p src/renderer
189 @cp -f $(DOME)/template/Application.js $@
190
191 dome-templ: src/renderer/Preferences.js
192 src/renderer/Preferences.js:
193 @echo "[Dome] creating $@ from template"
194 @mkdir -p src/renderer
195 @cp -f $(DOME)/template/Preferences.js $@
196
197 endif
198
199 # --------------------------------------------------------------------------
200 # --- Application Development
201 # --------------------------------------------------------------------------
202
203 DOME_MK_CLIDIR=$(dir $(DOME_CLI))
204
205 .PHONY: dome-dev
206
207 dome-dev: dome-pkg dome-templ
208 @echo "[Dome] linking $(DOME_CLI)"
209 @mkdir -p $(DOME_MK_CLIDIR)
210 @rm -f $(DOME_CLI)
211 @echo "#!/bin/sh" >> $(DOME_CLI)
212 @echo "export DOME='$(DOME)'" >> $(DOME_CLI)
213 @echo "export DOME_ENV='dev'" >> $(DOME_CLI)
214 @echo 'exec $(DOME_MK_BIN)/electron-webpack dev $(DOME_ARGS) $(DOME_DEV) "$$@"' >> $(DOME_CLI)
215 @chmod 555 $(DOME_CLI)
216 @echo "[Dome] running application (development)"
217 @$(DOME_CLI)
218
219 # --------------------------------------------------------------------------
220 # --- Application Building
221 # --------------------------------------------------------------------------
222
223 .PHONY: dome-app
224
225 dome-app: dome-pkg dome-templ
226 @echo "[Dome] compiling application (production)"
227 DOME=$(DOME) DOME_ENV='app' yarn run electron-webpack app
228 @echo "[Dome] linking $(DOME_CLI)"
229 @mkdir -p $(DOME_MK_CLIDIR)
230 @rm -f $(DOME_CLI)
231 @echo "#!/bin/sh" >> $(DOME_CLI)
232 @echo "export DOME_LOCAL=true" >> $(DOME_CLI)
233 @echo 'exec $(DOME_MK_BIN)/electron $(CURDIR)/dist/main/main.js $(DOME_ARGS) "$$@"' >> $(DOME_CLI)
234 @chmod 555 $(DOME_CLI)
235
236 # --------------------------------------------------------------------------
237 # --- Application Packaging
238 # --------------------------------------------------------------------------
239
240 .PHONY: dome-dist
241
242 dome-dist: dome-app
243 @echo "[Dome] packaging application (production)"
244 DOME=$(DOME) yarn run electron-builder --dir -c.compression=store -c.mac.identity=null
245 @echo "[Dome] application packaged in ./dist"
246
247 # --------------------------------------------------------------------------
248 # --- Icon gallery
249 # --------------------------------------------------------------------------
250
251 DOME_MK_ICON_MAKE=$(DOME)/doc/icons.js
252 DOME_MK_ICON_DATA=$(DOME)/renderer/controls/icons.json
253 DOME_MK_ICON_HTML=$(DOME)/doc/template/gallery-icons.html
254
255 $(DOME_MK_ICON_HTML): $(DOME_MK_ICON_MAKE) $(DOME_MK_ICON_DATA)
256 @echo "[Dome] generating icons gallery"
257 @node $(DOME_MK_ICON_MAKE) $(DOME_MK_ICON_DATA) > $(DOME_MK_ICON_HTML)
258
259 # --------------------------------------------------------------------------
260 # --- Dome Documentation
261 # --------------------------------------------------------------------------
262
263 DOME_MK_DOC_API=$(addprefix $(CURDIR)/, $(DOME_API))
264 DOME_MK_DOC_OUT=$(addprefix $(CURDIR)/, $(DOME_DOC))
265
266 dome-doc: $(DOME_MK_BIN)/jsdoc $(DOME_MK_ICON_HTML)
267 @echo "[Dome] $(APP) documentation"
268 @mkdir -p $(DOME_DOC)
269 @rm -f $(DOME_DOC)/*.html
270 @rm -f $(DOME_DOC)/*.png
271 @rm -f $(DOME_DOC)/*.css
272 @rm -fr $(DOME_DOC)/fonts
273 @rm -fr $(DOME_DOC)/styles
274 @(cd $(DOME) && DOME="." DOME_PWD=$(CURDIR) APP=$(APP) COPYRIGHT="$(COPYRIGHT)" \
275 $(DOME_MK_BIN)/jsdoc -c ./doc/config.json $(DOME_MK_DOC_API) \
276 -d $(DOME_MK_DOC_OUT))
277 @cp -f $(DOME)/doc/gallery.css $(DOME_DOC)/styles/
278 @cp -f $(DOME)/doc/tutorials/*.png $(DOME_DOC)/
279 @cat \
280 $(DOME)/doc/template/gallery-head.html \
281 $(DOME)/doc/template/gallery-icons.html \
282 $(DOME)/doc/template/gallery-tail.html \
283 > $(DOME_DOC)/tutorial-icons.html
284 @echo "[Dome] $(DOME_DOC)/index.html"
285
286 # --- Doc binaries ---------------------------------------------------------
287
288 $(DOME_MK_BIN)/jsdoc:
289 @echo "[Dome] installing jsdoc"
290 @yarn add -D jsdoc
291
292 # --------------------------------------------------------------------------