Clean up the version stamping logic so that it can run if not on a dev machine
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 12 Aug 2012 17:49:06 +0000 (13:49 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 12 Aug 2012 17:49:06 +0000 (13:49 -0400)
Makefile

index bcbf550fec8489d61f1034895d938e5fcf5d267e..1410cd60d2c484ac0a1cdce1fa93e94cde6c91c0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,34 +26,34 @@ all: backend frontend
 
 # Creates the compiled frontend code and stamps the version information into
 # the release.
-release: backend stamp_version compiled
+release: backend compiled
 
 # Compiles the backend server.
 backend:
        go build -v .
 
 # Compiles the frontend code for development.
-frontend: stamp $(FRONTEND_BIN)
+frontend: version $(FRONTEND_BIN)
 
 $(FRONTEND_BIN): $(FRONTEND_SOURCES)
        echo $(foreach f,$^,"document.write('<script src="fe/$(notdir $f)"></script>');\n") > $(FRONTEND_BIN)
 
 # Compiles the frontend code for release.
 compiled: SOURCES_FLAGS=$(foreach f,$(FRONTEND_SOURCES),--js=$f)
-compiled: version
+compiled: stamp
        java -jar closure-compiler.jar \
                $(SOURCES_FLAGS) \
                --js_output_file=$(FRONTEND_BIN) \
                --compilation_level=SIMPLE_OPTIMIZATIONS
 
-# Advances the frontend version.
-stamp:
-       if [[ -f $(VERSION_FILE) ]]; then gitcrement next; fi;
+.PHONY: $(VERSION_FILE)
 
 # Builds the version file template.
-version: STAMP=$(shell date +%s)
-version: BUILD=$(shell gitcrement current)
-version: stamp $(VERSION_FILE)
+version:
+       if [[ -f $(VERSION_FILE) ]]; then $(MAKE) $(VERSION_FILE); fi
+$(VERSION_FILE): STAMP=$(shell date +%s)
+$(VERSION_FILE): BUILD=$(shell gitcrement next)
+$(VERSION_FILE):
        @echo "// This file is automatically generated." > $(VERSION_FILE)
        @echo >> $(VERSION_FILE)
        @echo "$$.namespace('$(VERSION_NAMESPACE)');" >> $(VERSION_FILE)
@@ -64,7 +64,7 @@ version: stamp $(VERSION_FILE)
        echo "$(VERSION_NAMESPACE).STAMP = $(STAMP);" >> $(VERSION_FILE)
 
 # Copies the version template to the source and commits it.
-stamp_version: version
+stamp: version
        cp $(VERSION_FILE) $(VERSION_SOURCE)
        git commit $(VERSION_SOURCE) \
                --author='Armadillo Build Script <armadillo@bluestatic.org>' \