* Stamp on each compilation of the frontend
[armadillo.git] / Makefile
1 # Armadillo File Manager
2 # Copyright (c) 2012, Robert Sesek <http://www.bluestatic.org>
3 #
4 # This program is free software: you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or any later version.
7
8 VERSION_MAJOR=0
9 VERSION_MINOR=8
10 VERSION_NAMESPACE=armadillo.Version
11 VERSION_FILE=frontend/version.js.proto2
12 VERSION_SOURCE=$(basename $(VERSION_FILE))
13
14 FRONTEND_SOURCES=frontend/jquery-1.7.1.js \
15 frontend/utils.js \
16 $(VERSION_SOURCE) \
17 frontend/tv_renamer.js \
18 frontend/path_control.js \
19 frontend/actor.js \
20 frontend/file.js \
21 frontend/main.js
22 FRONTEND_BIN=frontend/armadillo.js
23
24 # Default target, used to produce the backend and uncompiled frontend.
25 all: backend frontend
26
27 # Creates the compiled frontend code and stamps the version information into
28 # the release.
29 release: backend stamp_version compiled
30
31 # Compiles the backend server.
32 backend:
33 go build -v .
34
35 # Compiles the frontend code for development.
36 frontend: stamp $(FRONTEND_BIN)
37
38 $(FRONTEND_BIN): $(FRONTEND_SOURCES)
39 echo $(foreach f,$^,"document.write('<script src="fe/$(notdir $f)"></script>');\n") > $(FRONTEND_BIN)
40
41 # Compiles the frontend code for release.
42 compiled: SOURCES_FLAGS=$(foreach f,$(FRONTEND_SOURCES),--js=$f)
43 compiled: version
44 java -jar closure-compiler.jar \
45 $(SOURCES_FLAGS) \
46 --js_output_file=$(FRONTEND_BIN) \
47 --compilation_level=SIMPLE_OPTIMIZATIONS
48
49 # Advances the frontend version.
50 stamp:
51 if [[ -f $(VERSION_FILE) ]]; then gitcrement next; fi;
52
53 # Builds the version file template.
54 version: STAMP=$(shell date +%s)
55 version: BUILD=$(shell gitcrement current)
56 version: stamp $(VERSION_FILE)
57 @echo "// This file is automatically generated." > $(VERSION_FILE)
58 @echo >> $(VERSION_FILE)
59 @echo "$$.namespace('$(VERSION_NAMESPACE)');" >> $(VERSION_FILE)
60 @echo >> $(VERSION_FILE)
61 echo "$(VERSION_NAMESPACE).MAJOR = $(VERSION_MAJOR);" >> $(VERSION_FILE)
62 echo "$(VERSION_NAMESPACE).MINOR = $(VERSION_MINOR);" >> $(VERSION_FILE)
63 echo "$(VERSION_NAMESPACE).BUILD = $(BUILD);" >> $(VERSION_FILE)
64 echo "$(VERSION_NAMESPACE).STAMP = $(STAMP);" >> $(VERSION_FILE)
65
66 # Copies the version template to the source and commits it.
67 stamp_version: version
68 cp $(VERSION_FILE) $(VERSION_SOURCE)
69 git commit $(VERSION_SOURCE) \
70 --author='Armadillo Build Script <armadillo@bluestatic.org>' \
71 -m 'Stamp version.js @ $(shell gitcrement current)'