Skip to content

Instantly share code, notes, and snippets.

@MichaelMartinez
Forked from pamelafox/Makefile
Created February 21, 2012 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelMartinez/1878220 to your computer and use it in GitHub Desktop.
Save MichaelMartinez/1878220 to your computer and use it in GitHub Desktop.
Phonegap/App Engine Makefile
# Javascript/CSS Compressor Makefile - By Benjamin "balupton" Lupton (MIT Licenced)
MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)
BUILDDIR = ./.build
# Tools and such
CLOSUREURL = http://closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.6.zip
YUIDIR = $(BUILDDIR)/yui
YUIFILE = $(YUIDIR)/yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar
JSHINTURL = https://github.com/jshint/jshint/zipball/master
JSHINTDIR = $(BUILDDIR)/jshint
GAEDIR = /usr/local/bin/
# Application bits live inside these walls
STATICDIR = ./application/static
ANDROIDDIR = ./android/assets/www
IPHONEDIR = ./iphone/everyday/www
BLOGDIR = ./learningblog
# Pretty sure this is just removing, creating, opening and updating tools
downloadtools:
rm -Rf $(BUILDDIR);
mkdir $(BUILDDIR) $(CLOSUREDIR) $(YUIDIR) $(JSHINTDIR);
cd $(CLOSUREDIR); curl -L $(CLOSUREURL) > file.zip; tar -xf file.zip;
cd $(YUIDIR); curl -L $(YUIURL) > file.zip; tar -xf file.zip;
cd $(JSHINTDIR); curl -L $(JSHINTURL) > file.zip; tar -xf file.zip; cp -R jshint-*/* .; rm -rf jshint-*/;
# Code Style
pystyle:
pep8 . --filename=*.py
pep8 ./application/*.py
#compass
compass:
cd ./application; compass watch;
# Clean, cat and compress el JavaScript & CSS
# Self-explanatory
jscss-clean:
rm -f $(STATICDIR)/js/libs.js \
$(STATICDIR)/js/libs-min.js \
$(STATICDIR)/js/all-web.js \
$(STATICDIR)/js/all-web-min.js \
$(STATICDIR)/css/all-web.css \
$(STATICDIR)/css/all-web-min.css \
$(STATICDIR)/css/all-phonegap-min* \
$(STATICDIR)/js/all-phonegap* \
$(STATICDIR)/js/all-phonegap-min* \
$(STATICDIR)/js/phonegap-fb-android.js \
$(STATICDIR)/js/phonegap-fb-ios.js \
$(STATICDIR)/css/all-blog* \
$(STATICDIR)/css/all-phonegap* \
$(ANDROIDDIR)/js/all-phonegap-min* \
$(ANDROIDDIR)/css/all-phonegap* \
$(IPHONEDIR)/css/all-phonegap-min* \
$(IPHONEDIR)/js/all-phonegap-min*;
jscss-jshint:
find $(STATICDIR)/js -maxdepth 1 -name "*.js" -exec $(JSHINTDIR)/env/jsc.sh {} \;
jscss-cat:
cat \
$(STATICDIR)/js/libs/jsrender.js \
$(STATICDIR)/js/libs/jquery.calendrical.js \
$(STATICDIR)/js/libs/jquery.autosuggest.js \
$(STATICDIR)/js/libs/colorslider.js \
$(STATICDIR)/js/libs/jquery.tablesorter.js \
$(STATICDIR)/js/libs/jquery.sparkline.js \
$(STATICDIR)/js/libs/jquery.fancybox.js \
$(STATICDIR)/js/libs/jquery.dateinput.js \
$(STATICDIR)/js/libs/timeago.js \
$(STATICDIR)/js/libs/bootstrap.js \
$(STATICDIR)/js/libs/lscache.js \
$(STATICDIR)/js/libs/personalize.js \
$(STATICDIR)/js/libs/useragent.js \
$(STATICDIR)/js/libs/stacktrace.js \
$(STATICDIR)/js/libs/highcharts.js \
$(STATICDIR)/js/libs/date.format.js \
$(STATICDIR)/js/libs/throttle.js \
> $(STATICDIR)/js/libs.js;
cat \
$(STATICDIR)/js/util.js \
$(STATICDIR)/js/data.js \
$(STATICDIR)/js/models.js \
$(STATICDIR)/js/shared.js \
$(STATICDIR)/js/web.js \
> $(STATICDIR)/js/all-web.js;
cat \
$(STATICDIR)/css/normalize.css \
$(STATICDIR)/css/autosuggest.css \
$(STATICDIR)/css/calendrical.css \
$(STATICDIR)/css/colorslider.css \
$(STATICDIR)/css/tablesorter.css \
$(STATICDIR)/css/dateinput.css \
$(STATICDIR)/css/tagfield.css \
$(STATICDIR)/css/fancybox.css \
$(STATICDIR)/css/bootstrap.css \
$(STATICDIR)/css/bootstrap-responsive.css \
$(STATICDIR)/css/web.css \
> $(STATICDIR)/css/all-web.css;
jscss-compress:
java -jar $(CLOSUREFILE) --js_output_file=$(STATICDIR)/js/libs-min.js --js=$(STATICDIR)/js/libs.js;
java -jar $(CLOSUREFILE) --js_output_file=$(STATICDIR)/js/all-web-min.js --js=$(STATICDIR)/js/all-web.js;
java -jar $(YUIFILE) $(STATICDIR)/css/all-web.css -o $(STATICDIR)/css/all-web-min.css;
mobile-jscss-cat:
cat \
$(STATICDIR)/js/util.js \
$(STATICDIR)/js/data.js \
$(STATICDIR)/js/models.js \
$(STATICDIR)/js/shared.js \
$(STATICDIR)/js/mobile.js \
$(STATICDIR)/js/libs/date.format.js \
$(STATICDIR)/js/libs/jsrender.js \
$(STATICDIR)/js/libs/colorslider.js \
$(STATICDIR)/js/libs/bootstrap.datepicker.js \
$(STATICDIR)/js/libs/timeago.js \
$(STATICDIR)/js/libs/lscache.js \
$(STATICDIR)/js/libs/personalize.js \
> $(STATICDIR)/js/all-phonegap.js;
cat \
$(STATICDIR)/js/libs/pg-plugin-fb-connect.js \
$(STATICDIR)/js/libs/facebook_js_sdk.js \
> $(STATICDIR)/js/phonegap-fb-ios.js;
cat \
$(STATICDIR)/js/libs/facebook.js \
> $(STATICDIR)/js/phonegap-fb-android.js;
cat \
$(STATICDIR)/css/colorslider.css \
$(STATICDIR)/css/dateinput.css \
$(STATICDIR)/css/bootstrap.css \
$(STATICDIR)/css/bootstrap-responsive.css \
$(STATICDIR)/css/phonegap.css \
> $(STATICDIR)/css/all-phonegap.css;
mobile-jscss-compress:
java -jar $(CLOSUREFILE) --js_output_file=$(STATICDIR)/js/all-phonegap-min.js --js=$(STATICDIR)/js/all-phonegap.js;
java -jar $(CLOSUREFILE) --js_output_file=$(STATICDIR)/js/libs/zepto-min.js --js=$(STATICDIR)/js/libs/zepto.js;
java -jar $(YUIFILE) $(STATICDIR)/css/all-phonegap.css -o $(STATICDIR)/css/all-phonegap-min.css;
mobile-jscss-cachebust:
mv $(STATICDIR)/js/all-phonegap-min.js $(STATICDIR)/js/all-phonegap-min-`date +%m%d%H%M`.js;
sed -i '' "s/all-phonegap-min-[0-9]*\.js/all-phonegap-min-`date +%m%d%H%M`\.js/" ./application/templates/phonegap/index.html;
mv $(STATICDIR)/css/all-phonegap-min.css $(STATICDIR)/css/all-phonegap-min-`date +%m%d%H%M`.css;
sed -i '' "s/all-phonegap-min-[0-9]*\.css/all-phonegap-min-`date +%m%d%H%M`\.css/" ./application/templates/phonegap/index.html;
jscss:
$(MAKE) jscss-clean;
$(MAKE) jscss-jshint;
$(MAKE) jscss-cat;
$(MAKE) jscss-compress;
#Totally confused in this section as to what is really goin' on
#It looks like this is where the magic happens, but I don't understand a lot of the syntax (i need mommy)
deploy-files:
/usr/local/bin/appcfg.py update .;
deploy-all:
sh ./checkgit.sh deploy
$(MAKE) jscss;
sh ./checkgit.sh deploy;
git tag -a v`date +%m%d%H%M` -m "Deployed to prod on $(shell date)";
git push origin master;
$(MAKE) deploy-files;
deploy-testversion:
/usr/local/bin/appcfg.py update . --version=test;
deploy-testapp:
/usr/local/bin/appcfg.py update . --application=everyday-app-test --email=pamelafox@everyday.io --no_cookies;
deploy-androidversion:
git tag -a Android-backend-`date +%m%d%H%M` -m "Deployed Android backend on $(shell date)";
/usr/local/bin/appcfg.py update . --version=android;
deploy-iphoneversion:
git tag -a iPhone-backend-`date +%m%d%H%M` -m "Deployed iPhone backend on $(shell date)";
/usr/local/bin/appcfg.py update . --version=iphone;
android-jscss:
$(MAKE) jscss-clean;
$(MAKE) jscss-jshint;
$(MAKE) mobile-jscss-cat;
$(MAKE) mobile-jscss-compress;
python android_index.py > $(ANDROIDDIR)/index.html
cp $(STATICDIR)/js/all-phonegap-min.js $(ANDROIDDIR)/js/all-phonegap-min-`date +%m%d%H%M`.js;
cp $(STATICDIR)/css/all-phonegap-min.css $(ANDROIDDIR)/css/all-phonegap-min-`date +%m%d%H%M`.css;
sed -i '' "s/all-phonegap-min-[0-9]*\.js/all-phonegap-min-`date +%m%d%H%M`\.js/" $(ANDROIDDIR)/index.html
sed -i '' "s/all-phonegap-min-[0-9]*\.css/all-phonegap-min-`date +%m%d%H%M`\.css/" $(ANDROIDDIR)/index.html;
cp $(STATICDIR)/img/icon-* $(ANDROIDDIR)/css/images/.;
cp $(STATICDIR)/js/all-phonegap-min* $(ANDROIDDIR)/js/.;
cp $(STATICDIR)/css/all-phonegap-min* $(ANDROIDDIR)/css/.;
cp $(STATICDIR)/js/phonegap-fb-android.js $(ANDROIDDIR)/js/libs/phonegap-fb.js;
cp $(STATICDIR)/js/libs/zepto-min.js $(ANDROIDDIR)/js/libs/zepto-min.js;
android-build:
rm -f ./android/bin/everyday.io*
cd android; ant debug;
cd ../;
adb -d install -r ./android/bin/everyday.io-debug.apk
adb shell am start -n io.everyday.app/io.everyday.app.App
android-all:
$(MAKE) android-jscss;
$(MAKE) android-build;
android-release:
python android_release.py;
cd android; ant release;
iphone-all:
$(MAKE) jscss-clean;
$(MAKE) jscss-jshint;
$(MAKE) mobile-jscss-cat;
$(MAKE) mobile-jscss-compress;
python android_index.py > $(IPHONEDIR)/index.html
cp $(STATICDIR)/js/all-phonegap-min.js $(IPHONEDIR)/js/all-phonegap-min-`date +%m%d%H%M`.js;
cp $(STATICDIR)/css/all-phonegap-min.css $(IPHONEDIR)/css/all-phonegap-min-`date +%m%d%H%M`.css;
sed -i '' "s/all-phonegap-min-[0-9]*\.js/all-phonegap-min-`date +%m%d%H%M`\.js/" $(IPHONEDIR)/index.html
sed -i '' "s/all-phonegap-min-[0-9]*\.css/all-phonegap-min-`date +%m%d%H%M`\.css/" $(IPHONEDIR)/index.html;
cp $(STATICDIR)/img/icon-* $(IPHONEDIR)/css/images/.;
cp $(STATICDIR)/js/all-phonegap-min* $(IPHONEDIR)/js/.;
cp $(STATICDIR)/css/all-phonegap-min* $(IPHONEDIR)/css/.;
cp $(STATICDIR)/js/phonegap-fb-ios.js $(IPHONEDIR)/js/libs/phonegap-fb.js;
cp $(STATICDIR)/js/libs/zepto-min.js $(IPHONEDIR)/js/libs/zepto-min.js;
iphone-release:
python iphone_release.py;
@pamelafox
Copy link

deploy-* : You can remove those, they are for deploying to App Engine.

android-jscss: Removes old generated JS files, runs jshint on the original files, concatenates new mobile JS and CSS, compressed JS and CSS. Then it generates the new index.html (from Jinja templates). Then it renames them based on current time, to bust cache (we're still not sure if that's necessary), then replaces the filenames in the index.html file. Then it copies JS/CSS/images over.

android-build: Rebuilds APK and copies to the device (not emulator - you have to remove -d -r for emulator, IIRC).

android-all: does both

android-release: A script I use for auto-updating the version in the AndroidManifest.xml when I want to actually release. Can be done manually.

@MichaelMartinez
Copy link
Author

Gracias!!! I really appreciate the help. I am trying to automate the mundane optimization / build tasks even though I don't really have any "products, projects" or otherwise to use them on .... YET!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment