* Stamp on each compilation of the frontend
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 12 Aug 2012 16:58:58 +0000 (12:58 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 12 Aug 2012 16:58:58 +0000 (12:58 -0400)
* Make stamp work if there's no version file
* Add comments for each target

Makefile

index caf3e9cdea34070738b3a14456b18f18cc54a463..13db7ded5962d1620a764351580f4ff63089a66f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,18 +21,24 @@ FRONTEND_SOURCES=frontend/jquery-1.7.1.js \
        frontend/main.js
 FRONTEND_BIN=frontend/armadillo.js
 
-all: backend dev
+# Default target, used to produce the backend and uncompiled frontend.
+all: backend frontend
 
+# Creates the compiled frontend code and stamps the version information into
+# the release.
+release: backend stamp_version compiled
+
+# Compiles the backend server.
 backend:
        go build -v .
 
-frontend: $(FRONTEND_BIN)
+# Compiles the frontend code for development.
+frontend: stamp $(FRONTEND_BIN)
 
 $(FRONTEND_BIN): $(FRONTEND_SOURCES)
        echo $(foreach f,$^,"document.write('<script src="fe/$(notdir $f)"></script>');\n") > $(FRONTEND_BIN)
 
-dev: version frontend
-
+# Compiles the frontend code for release.
 compiled: SOURCES_FLAGS=$(foreach f,$(FRONTEND_SOURCES),--js=$f)
 compiled: version
        java -jar closure-compiler.jar \
@@ -40,12 +46,14 @@ compiled: version
                --js_output_file=$(FRONTEND_BIN) \
                --compilation_level=SIMPLE_OPTIMIZATIONS
 
+# Advances the frontend version.
 stamp:
-       gitcrement next
+       if [[ -f $(VERSION_FILE) ]]; then gitcrement next; fi;
 
+# Builds the version file template.
 version: STAMP=$(shell date +%s)
 version: BUILD=$(shell gitcrement current)
-version:
+version: stamp $(VERSION_FILE)
        @echo "// This file is automatically generated." > $(VERSION_FILE)
        @echo >> $(VERSION_FILE)
        @echo "$$.namespace('$(VERSION_NAMESPACE)');" >> $(VERSION_FILE)
@@ -55,7 +63,8 @@ version:
        echo "$(VERSION_NAMESPACE).BUILD = $(BUILD);" >> $(VERSION_FILE)
        echo "$(VERSION_NAMESPACE).STAMP = $(STAMP);" >> $(VERSION_FILE)
 
-stamp_version: stamp version
+# Copies the version template to the source and commits it.
+stamp_version: version
        cp $(VERSION_FILE) $(VERSION_SOURCE)
        git commit $(VERSION_SOURCE) \
                --author='Armadillo Build Script <armadillo@bluestatic.org>' \