Bug 1017490 - rewrite clock build script in javascrip

I got console not defined error, so I will still use dump here.