Sebastian Poręba's blog

Makefile for Google Closure Compiler

I’ve been using online version of Google Closure Compiler as a minifier for my projects for some time now. I always wondered how the advanced compilation works, but never really gave it a shot. Lately I started working on a university project and as you may know, academics do not like JavaScript in general. To make it even worse for them, I decided to prepare a very complex JS setup, with fully annotated Google Closure code. Not only out of spice, but also to prove that using a proper approach, it can be fast and well-structured.

I’m not going to describe here how the Compiler works in detail. In short words, it scans your files looking for comments in a specific, JSDoc-like format and makes use of them. There is also a tool called calcdeps which is a linker – it scans files for dependencies and helps compiler to merge files in the correct order.

My project structure

To make it even more fun, I decided to write a Makefile which will be a final jaw-dropper.

PYTHON   = python
CALCDEPS = ~/closure/closure-library-read-only/closure/bin/
CLOSURECOMPILER = ~/closure/compiler.jar

	$(PYTHON) $(CALCDEPS) -p src -i src/init.js -o compiled -c $(CLOSURECOMPILER) > scripts/ai-bot-compiled.js

It works like charm, “make” is compiling all required files from src folder, merging them into one.
I was surprised how easy it was – calcdeps takes a path (-p) where you store all your libraries and an initial file (-i). The rest is based on goog.require(classname) and goog.provide(classname) calls from files. I barely used Google Closure Tools so far, but the Compiler is absolutely great!

Google Closure:

  • RSS
  • Facebook
  • Twitter

FAQ about Wordpress

This came as a surprise for me but gMap is ...

gMap 3.3.3 released

It was a looong time since I last visited gMap. ...

Talks for Google Dev

Two new slide decks appeared in lectures tab. This time with ...

Talks and lectures w

Every now and then I spend a weekend watching various ...

3D Tetris with Three

In the fifth part of tutorial we add some final ...

FAQ about Wordpress

This came as a surprise for me but gMap is ...

gMap 3.3.0 released

Christmas came early! New version of gMap is ready!

Lecture for GTUG: Ja

Today I gave a lecture for GTUG Krakow about optimizations in ...

Unit testing for jQu

In part 1 I described basics of unit testing in ...

Unit testing for jQu

In part 1 I described some basic concepts behind unit ...