Improve build system: read version from version.txt, fix build without compiler

* read the version from version.txt
 * set default target to build
 * added dependencies to all targets
 * allow the build to run without a local copy of the closure compiler
 * updated license header with @VERSION@ which will be replaced during the build
 * added the license header to all files (that one will be stripped out by the closure compiler)
This commit is contained in:
MoyuScript 2011-11-16 00:25:02 +01:00
parent a27b60f491
commit 4615eb3073
12 changed files with 105 additions and 54 deletions

5
.gitignore vendored
View File

@ -6,9 +6,8 @@
/tests/flashcanvas.html /tests/flashcanvas.html
/lib/ /lib/
/dist/ /dist/
/build/tmp.js /build/*.js
/build/html2canvas.min.js
index.html index.html
image.jpg image.jpg
screenshots.html screenshots.html
screenshots_local.html screenshots_local.html

View File

@ -1,77 +1,75 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<project name="html2canvas" basedir="."> <project name="html2canvas" basedir="." default="build">
<property name="src.dir" location="src"/> <property name="src.dir" location="src"/>
<property name="lib.dir" location="../lib"/> <property name="lib.dir" location="../lib"/>
<property name="build.dir" location="build"/> <property name="build.dir" location="build"/>
<property name="dist" location="dist"/> <property name="dist" location="dist"/>
<property name="jquery-externs" value="jquery-1.4.4.externs.js"/> <property name="jquery-externs" value="jquery-1.4.4.externs.js"/>
<property name="JS_NAME" value="html2canvas.js"/> <property name="JS_NAME" value="html2canvas.js"/>
<property name="JS_NAME_MIN" value="html2canvas.min.js"/> <property name="JS_NAME_MIN" value="html2canvas.min.js"/>
<property name="JQUERY_PLUGIN_NAME" value="jquery.plugin.html2canvas.js"/> <property name="JQUERY_PLUGIN_NAME" value="jquery.plugin.html2canvas.js"/>
<loadfile property="version" srcfile="version.txt" />
<path id="sourcefiles"> <fileset id="sourcefiles" dir="${src.dir}">
<fileset dir="${src.dir}" includes="LICENSE"/> <include name="LICENSE"/>
<fileset dir="." includes="LICENSE"/> <include name="Core.js"/>
<fileset dir="${src.dir}" includes="Core.js"/> <include name="Generate.js"/>
<fileset dir="${src.dir}" includes="Generate.js"/> <include name="Parse.js"/>
<fileset dir="${src.dir}" includes="Parse.js"/> <include name="Preload.js"/>
<fileset dir="${src.dir}" includes="Preload.js"/> <include name="Queue.js"/>
<fileset dir="${src.dir}" includes="Queue.js"/> <include name="Renderer.js"/>
<fileset dir="${src.dir}" includes="Renderer.js"/> </fileset>
</path>
<path id="jquery-plugin"> <path id="jquery-plugin">
<fileset dir="${src.dir}" includes="LICENSE"/> <fileset dir="${src.dir}" includes="LICENSE"/>
<fileset dir="." includes="LICENSE"/>
<fileset dir="${src.dir}/plugins" includes="${JQUERY_PLUGIN_NAME}"/> <fileset dir="${src.dir}/plugins" includes="${JQUERY_PLUGIN_NAME}"/>
</path> </path>
<path id="minified">
<fileset dir="${src.dir}" includes="LICENSE"/>
<fileset dir="${build.dir}" includes="tmp.js"/>
</path>
<target name="plugins"> <target name="plugins">
<concat fixlastline="yes" destfile="${build.dir}/${JQUERY_PLUGIN_NAME}"> <concat fixlastline="yes" destfile="${build.dir}/${JQUERY_PLUGIN_NAME}">
<path refid="jquery-plugin"/> <path refid="jquery-plugin"/>
</concat> </concat>
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JQUERY_PLUGIN_NAME}" />
</target> </target>
<target name="build"> <target name="build" depends="plugins">
<concat fixlastline="yes" destfile="${build.dir}/${JS_NAME}"> <concat fixlastline="yes" destfile="${build.dir}/${JS_NAME}">
<path refid="sourcefiles"/> <fileset refid="sourcefiles"/>
</concat> </concat>
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME}" />
</target> </target>
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" <taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask"
classpath="${lib.dir}/compiler.jar"/> classpath="${lib.dir}/compiler.jar" onerror="report"/>
<target name="release"> <target name="release" depends="build">
<jscomp compilationLevel="simple" warning="verbose"
<jscomp compilationLevel="simple" warning="verbose" debug="false"
debug="false" output="${build.dir}/${JS_NAME_MIN}">
output="${build.dir}/tmp.js">
<externs dir="${lib.dir}"> <externs dir="${lib.dir}">
<file name="${jquery-externs}"/> <file name="${jquery-externs}"/>
</externs> </externs>
<sources dir="${build.dir}"> <sources dir="${src.dir}">
<file name="${JS_NAME}" /> <!-- need to write them again here since the closure compiler doesn't understand filesets,... -->
<file name="LICENSE"/>
<file name="Core.js"/>
<file name="Generate.js"/>
<file name="Parse.js"/>
<file name="Preload.js"/>
<file name="Queue.js"/>
<file name="Renderer.js"/>
</sources> </sources>
</jscomp> </jscomp>
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME_MIN}" />
<concat fixlastline="yes" destfile="${build.dir}/${JS_NAME_MIN}"> </target>
<path refid="minified"/>
</concat>
<target name="clean">
<delete file="${build.dir}/${JS_NAME}"></delete>
<delete file="${build.dir}/${JS_NAME_MIN}"></delete>
<delete file="${build.dir}/${JQUERY_PLUGIN_NAME}"></delete>
</target> </target>
</project> </project>

0
build/.gitkeepdir Normal file
View File

View File

@ -1,3 +1,11 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
var html2canvas = {}; var html2canvas = {};
html2canvas.logging = true; html2canvas.logging = true;
@ -121,4 +129,4 @@ html2canvas.Util.Extend = function (options, defaults) {
html2canvas.Util.Children = function(el) { html2canvas.Util.Children = function(el) {
// $(el).contents() !== el.childNodes, Opera / IE have issues with that // $(el).contents() !== el.childNodes, Opera / IE have issues with that
return $(el).contents(); return $(el).contents();
} }

View File

@ -1,3 +1,11 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
html2canvas.Generate = {}; html2canvas.Generate = {};

View File

@ -1,7 +1,7 @@
/* /**
html2canvas v0.30 <http://html2canvas.hertzen.com> @license html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved. Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh http://www.twitter.com/niklasvh
Released under MIT License Released under MIT License
*/ */

View File

@ -1,3 +1,11 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
/* /*
* New function for traversing elements * New function for traversing elements
*/ */

View File

@ -1,3 +1,11 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
html2canvas.Preload = function(element, opts){ html2canvas.Preload = function(element, opts){
var options = { var options = {

View File

@ -1,3 +1,10 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
html2canvas.canvasContext = function (width, height) { html2canvas.canvasContext = function (width, height) {
this.storage = []; this.storage = [];
this.width = width; this.width = width;

View File

@ -1,3 +1,10 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
html2canvas.Renderer = function(parseQueue, opts){ html2canvas.Renderer = function(parseQueue, opts){

View File

@ -0,0 +1,7 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/

1
version.txt Normal file
View File

@ -0,0 +1 @@
v0.30