<commit_before><project name="Cesium" default="combine">
	<target name="build" description="A developer build that prepares the source tree for use as standard AMD modules.">
		<mkdir dir="${buildDirectory}" />
		<glslToJavascript minify="${build.minification}" minifystatefile="${buildDirectory}/minifyShaders.state">
			<glslfiles dir="${shadersDirectory}" includes="**/*.glsl" />
			<existingjsfiles dir="${shadersDirectory}" includes="**/*.js" excludes="*.profile.js" />
		</glslToJavascript>

		<createCesiumJs output="${sourceDirectory}/Cesium.js">
			<sourcefiles refid="cesiumJsFiles" />
		</createCesiumJs>

		<createSpecList output="${specsDirectory}/SpecList.js">
			<specs dir="${specsDirectory}" includes="**/*.js" excludes="*.js" />
		</createSpecList>

		<createGalleryList output="${galleryDirectory}/gallery-index.js">
			<demos dir="${galleryDirectory}" includes="**/*.html" />
		</createGalleryList>

		<createSandcastleJsHintOptions output="${sandcastleDirectory}/jsHintOptions.js" jshintoptionspath="${jsHintOptionsPath}" />
	</target>

	<target name="combine" depends="build,combineJavaScript" description="Combines all source files into a single stand-alone script.">
		<copy todir="${buildDirectory}">
			<fileset dir="Apps/">
				<include name="HelloWorld.html" />
				<include name="index.html" />
			</fileset>
		</copy>

		<replace file="${buildDirectory}/HelloWorld.html" token="../Build/" value="" />
		<replace file="${buildDirectory}/index.html" token="../Build/" value="" />
	</target>

	<target name="minify" description="Combines all source files into a single stand-alone, minified script.">
		<antcall target="combine">
			<param name="build.minification" value="true" />
		</antcall>
		<antcall target="minifyCSS" />
	</target>

	<target name="combineRelease" description="Combines all source files into a single stand-alone script with debugging code removed.">
		<antcall target="combine">
			<param name="pragmas.debug" value="false" />
		</antcall>
	</target>

	<target name="minifyRelease" description="Combines all source files into a single stand-alone, minified script with debugging code removed.">
		<antcall target="minify">
			<param name="pragmas.debug" value="false" />
		</antcall>
	</target>

	<target name="release" description="A full release build that creates a shippable product, including building apps and generating documentation.">
		<antcall target="minifyRelease" />
		<antcall target="combine">
			<param name="build.debugUnminified" value="true" />
		</antcall>
		<antcall target="generateDocumentation" />
		<antcall target="buildApps" />
	</target>

	<target name="instrumentForCoverage" depends="build" description="A debug build instrumented for JSCoverage (currently Windows only).">
		<exec executable="${jscoveragePath}">
			<arg value="${sourceDirectory}" />
			<arg value="${instrumentedDirectory}" />
			<arg value="--no-instrument=./ThirdParty" />
		</exec>
	</target>

	<target name="makeZipFile" depends="release" description="Builds zip files containing all release files.">
		<zip destfile="Cesium-${version}.zip" basedir="${basedir}">
			<fileset dir="${buildDirectory}">
				<include name="Cesium/**" />
				<include name="Documentation/**" />
				<include name="*.html" />
			</fileset>
			<include name="server.js" />
			<include name="package.json" />
			<include name="LICENSE.md" />
			<include name="CHANGES.md" />
			<include name="README.md" />
		</zip>

		<zip destfile="Cesium-full-${version}.zip" basedir="${basedir}">
			<zipfileset dir="${buildDirectory}" prefix="Build">
				<include name="Cesium/**" />
				<include name="CesiumUnminified/**" />
				<include name="Documentation/**" />
				<include name="Apps/**" />
				<include name="*.html" />
			</zipfileset>
			<include name="Apps/**" />
			<include name="Examples/**" />
			<include name="Source/**" />
			<include name="Specs/**" />
			<include name="ThirdParty/**" />
			<include name="HelloWorld.html" />
			<include name="index.html" />
			<include name="server.js" />
			<include name="package.json" />
			<include name="LICENSE.md" />
			<include name="CHANGES.md" />
			<include name="README.md" />
		</zip>
	</target>

	<target name="clean" description="Removes all generated build artifacts.">
		<delete includeEmptyDirs="true" failonerror="false">
			<fileset dir="${sourceDirectory}" includes="Cesium.js" />
			<fileset dir="${buildDirectory}" defaultexcludes="false" />
			<fileset dir="${instrumentedDirectory}" defaultexcludes="false" />
			<fileset dir="${shadersDirectory}" includes="**/*.js" excludes="*.profile.js" />
			<fileset dir="${specsDirectory}" includes="SpecList.js" />
			<fileset dir="${sandcastleDirectory}" includes="jsHintOptions.js" />
			<fileset dir="${galleryDirectory}" includes="gallery-index.js" />
			<fileset dir="." includes="Cesium-*.zip" />
		</delete>
	</target>

	<!-- properties controlling which steps get run -->
	<property name="build.minification" value="false" />
	<property name="pragmas.debug" value="true" />

	<!-- properties controlling how to run the server-->
	<property name="runServer.public" value="false" />
	<property name="runServer.port" value="8080" />

	<!-- Inputs -->
	<!-- this version should be set to the upcoming version, so it can be tagged without requiring a bump first -->
	<property name="version" value="b29" />
	<property name="sourceDirectory" location="Source" />
	<property name="shadersDirectory" location="${sourceDirectory}/Shaders" />
	<property name="examplesDirectory" location="Examples" />
	<property name="sandcastleDirectory" location="Apps/Sandcastle" />
	<property name="galleryDirectory" location="${sandcastleDirectory}/gallery" />
	<property name="specsDirectory" location="Specs" />
	<property name="toolsDirectory" location="Tools" />
	<property name="tasksDirectory" location="${toolsDirectory}/buildTasks" />
	<property name="thirdPartyDirectory" location="ThirdParty" />
	<property name="requirejsPath" location="${thirdPartyDirectory}/requirejs-2.1.9" />
	<property name="rjsPath" location="${requirejsPath}/r.js" />
	<property name="rjsOptions" location="${toolsDirectory}/build.js" />
	<property name="almondPath" location="${thirdPartyDirectory}/almond-0.2.6/almond.js" />
	<property name="jscoveragePath" location="${toolsDirectory}/jscoverage-0.5.1/jscoverage.exe" />
	<property name="rhinoJarPath" location="${toolsDirectory}/rhino-1.7R4/js.jar" />
	<property name="documentationImagesDirectory" location="Documentation/Images" />
	<property name="jsdoc3Directory" location="${toolsDirectory}/jsdoc3" />
	<property name="webProxyDirectory" location="${toolsDirectory}/proxy" />
	<property name="jsHintPath" location="${thirdPartyDirectory}/jshint-2.1.10/jshint.js" />
	<property name="clocPath" location="${toolsDirectory}/cloc-1.60/cloc-1.60.pl" />
	<property name="clocDefinitionsPath" location="${toolsDirectory}/cloc-1.60/cloc_definitions" />
	<property name="jsHintOptionsPath" location=".jshintrc" />

	<!-- Outputs -->
	<property name="buildDirectory" location="Build" />
	<property name="buildOutputDirectory" location="${buildDirectory}/Cesium" />
	<property name="unminifiedOutputDirectory" location="${buildDirectory}/CesiumUnminified" />
	<property name="buildDocumentationDirectory" location="${buildDirectory}/Documentation" />
	<property name="buildDocumentationImagesDirectory" location="${buildDocumentationDirectory}/images" />
	<property name="instrumentedDirectory" location="Instrumented" />
	<property name="buildStubsDirectory" location="${buildDirectory}/Stubs" />

	<path id="javascriptClassPath">
		<pathelement path="${rhinoJarPath}" />
		<pathelement path="${toolsDirectory}/bsf-2.4.0/bsf.jar" />
		<pathelement path="${toolsDirectory}/commons-logging-1.1.1/commons-logging-1.1.1.jar" />
	</path>

	<union id="cesiumJsFiles">
		<fileset dir="${sourceDirectory}">
			<include name="**/*.js" />
			<exclude name="*.js" />
			<exclude name="Workers/**" />
			<exclude name="**/*.profile.js" />
		</fileset>
		<fileset dir="${sourceDirectory}">
			<include name="Workers/createTaskProcessorWorker.js" />
		</fileset>
	</union>

	<fileset dir="${sourceDirectory}" id="cesiumWorkersJsFileSet">
		<include name="**/*.js" />
		<exclude name="*.js" />
		<exclude name="**/*.profile.js" />
	</fileset>

	<scriptdef name="glslToJavascript" language="javascript" src="${tasksDirectory}/glslToJavaScript.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="minify" />
		<attribute name="minifystatefile" />
		<element name="glslfiles" type="fileset" />
		<element name="existingjsfiles" type="fileset" />
	</scriptdef>

	<scriptdef name="createCesiumJs" language="javascript" src="${tasksDirectory}/createCesiumJs.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<element name="sourcefiles" type="resources" />
	</scriptdef>

	<scriptdef name="createSpecList" language="javascript" src="${tasksDirectory}/createSpecList.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<element name="specs" type="fileset" />
	</scriptdef>

	<scriptdef name="createGalleryList" language="javascript" src="${tasksDirectory}/createGalleryList.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<element name="demos" type="fileset" />
	</scriptdef>

	<scriptdef name="createSandcastleJsHintOptions" language="javascript" src="${tasksDirectory}/createSandcastleJsHintOptions.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<attribute name="jshintoptionspath" />
	</scriptdef>

	<scriptdef name="runJsHint" language="javascript" src="${tasksDirectory}/runJsHint.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="jshintpath" />
		<attribute name="jshintoptionspath" />
		<attribute name="sandcastlejshintoptionspath" />
		<attribute name="failureproperty" />
		<element name="sourcefiles" type="fileset" />
	</scriptdef>

	<scriptdef name="generateStubs" language="javascript" src="${tasksDirectory}/generateStubs.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="stuboutput" />
		<attribute name="pathsoutput" />
		<element name="sourcefiles" type="resources" />
	</scriptdef>

	<scriptdef name="sortRequires" language="javascript" src="${tasksDirectory}/sortRequires.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<element name="sourcefiles" type="fileset" />
	</scriptdef>

	<target name="jsHint" depends="build" description="Runs JSHint on the entire source tree.">
		<runJsHint jshintpath="${jsHintPath}" jshintoptionspath="${jsHintOptionsPath}" sandcastlejshintoptionspath="${sandcastleDirectory}/jsHintOptions.js" failureproperty="jsHint.failure">
			<sourcefiles dir="${basedir}">
				<include name="Source/**/*.js" />
				<exclude name="Source/Shaders/**" />
				<exclude name="Source/ThirdParty/**" />
				<exclude name="Source/Workers/cesiumWorkerBootstrapper.js" />

				<include name="Apps/**/*.js" />
				<include name="Apps/Sandcastle/gallery/*.html" />

				<exclude name="Apps/Sandcastle/ThirdParty/**" />

				<include name="Specs/**/*.js" />

				<include name="Tools/buildTasks/**/*.js" />
			</sourcefiles>
		</runJsHint>
		<fail if="jsHint.failure" message="JSHint failed!" />
	</target>

	<target name="sortRequires" description="Sorts the list of requires in all source files">
		<sortRequires>
			<sourcefiles dir="${basedir}">
				<include name="Source/**/*.js" />
				<exclude name="Source/Shaders/**" />
				<exclude name="Source/ThirdParty/**" />
				<exclude name="Source/Workers/cesiumWorkerBootstrapper.js" />
				<exclude name="Source/copyrightHeader.js" />
				<exclude name="Source/Workers/transferTypedArrayTest.js" />

				<include name="Apps/**/*.js" />
				<exclude name="Apps/Sandcastle/ThirdParty/**" />

				<include name="Specs/**/*.js" />
				<exclude name="Specs/SpecRunner.js" />
				<exclude name="Specs/SpecList.js" />

				<exclude name="Apps/Sandcastle/Sandcastle-client.js" />
				<exclude name="Apps/Sandcastle/Sandcastle-header.js" />
				<exclude name="Apps/Sandcastle/Sandcastle-warn.js" />
				<exclude name="Apps/Sandcastle/gallery/gallery-index.js" />
				<exclude name="Apps/Sandcastle/jsHintOptions.js" />

				<exclude name="**/*.profile.js" />
			</sourcefiles>
		</sortRequires>
	</target>

	<target name="cloc" depends="build" description="Runs cloc to count lines of code for Source and Specs directories.">
		<echo message="Source:" />
		<apply executable="perl" parallel="true">
			<arg value="${clocPath}" />
			<arg value="--read-lang-def=${clocDefinitionsPath}" />
			<arg value="Source/Core/" />
			<arg value="Source/DynamicScene/" />
			<arg value="Source/Renderer/" />
			<arg value="Source/Scene/" />
			<arg value="Source/Widgets/" />
			<arg value="Source/Workers/" />
			<fileset id="clocFileSet" dir="Source/">
				<include name="Shaders/*.glsl" />
				<include name="Shaders/**/*.glsl" />
				<include name="main.js" />
			</fileset>
		</apply>
		<echo message="${line.separator}Specs:" />
		<exec executable="perl">
			<arg value="${clocPath}" />
			<arg value="--read-lang-def=${clocDefinitionsPath}" />
			<arg value="Specs/" />
		</exec>
	</target>

	<target name="checkForNode">
		<exec executable="node" failonerror="false" failifexecutionfails="false" resultproperty="node.exec.result">
			<arg value="--version" />
		</exec>
		<fail message="Node.js is required to run this part of the build.  Install from http://nodejs.org/">
			<condition>
				<isfailure code="${node.exec.result}" />
			</condition>
		</fail>
	</target>

	<target name="combineJavaScript.create">
		<!-- create relative paths because r.js can't handle full Windows paths -->
		<property name="relativeAlmondPath" location="${almondPath}" relative="true" basedir="${sourceDirectory}" />
		<property name="combineOutputDirectory" location="${buildDirectory}/combineOutput" />

		<mkdir dir="${combineOutputDirectory}" />
		<property name="relativeCombineOutputDirectory" location="${combineOutputDirectory}" relative="true" basedir="${sourceDirectory}" />

		<!-- create combined Cesium.js	-->
		<antcall target="combineJavaScript.combineCesium" />

		<mkdir dir="${buildStubsDirectory}" />
		<generateStubs stuboutput="${buildStubsDirectory}/Cesium.js" pathsoutput="${buildStubsDirectory}/paths.js">
			<sourcefiles refid="cesiumJsFiles" />
		</generateStubs>

		<!-- create combined Cesium.js workers -->
		<antcall target="combineJavaScript.combineCesiumWorkers" />

		<!-- copy to build folder with copyright header added at the top -->
		<copy todir="${outputDirectory}">
			<fileset dir="${combineOutputDirectory}" />
			<filterchain>
				<concatfilter prepend="${sourceDirectory}/copyrightHeader.js" />
			</filterchain>
		</copy>

		<delete dir="${combineOutputDirectory}" />

		<!-- copy other resources -->
		<copy todir="${outputDirectory}" includeEmptyDirs="false">
			<fileset dir="${sourceDirectory}">
				<exclude name="**/*.js" />
				<exclude name="**/*.glsl" />
				<exclude name="**/.gitignore" />
				<exclude name="**/package.json" />
			</fileset>
		</copy>
	</target>

	<target name="combineJavaScript.combineCesium" depends="combineJavaScript.combineCesium.check" unless="no.combineCesium.create">
		<exec executable="node" dir="${sourceDirectory}">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<arg value="pragmas.debug=${pragmas.debug}" />
			<arg value="optimize=${optimize}" />
			<arg value="baseUrl=." />
			<arg value="skipModuleInsertion=true" />
			<arg value="name=${relativeAlmondPath}" />
			<arg value="include=main" />
			<arg value="out=${relativeCombineOutputDirectory}/Cesium.js" />
		</exec>
	</target>

	<target name="combineJavaScript.combineCesiumWorkers" depends="combineJavaScript.combineCesiumWorkers.check" unless="no.combineCesiumWorkers.create">
		<!-- create standalone worker files -->
		<apply executable="node" dir="${sourceDirectory}" relative="true" force="true">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<arg value="pragmas.debug=${pragmas.debug}" />
			<arg value="optimize=${optimize}" />
			<arg value="baseUrl=." />
			<arg value="skipModuleInsertion=true" />
			<arg value="wrap=false" />
			<srcfile prefix="include=Workers/" />
			<targetfile prefix="out=" />
			<globmapper from="*" to="${relativeCombineOutputDirectory}/Workers/*.js" />
			<mappedresources>
				<fileset dir="${sourceDirectory}/Workers">
					<include name="cesiumWorkerBootstrapper.js" />
					<include name="transferTypedArrayTest.js" />
				</fileset>
				<chainedmapper>
					<flattenmapper />
					<globmapper from="*.js" to="*" />
				</chainedmapper>
			</mappedresources>
		</apply>

		<!-- create combined worker layer files -->
		<apply executable="node" dir="${sourceDirectory}" relative="true" force="true">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<arg value="optimize=${optimize}" />
			<arg value="pragmas.debug=${pragmas.debug}" />
			<arg value="baseUrl=." />

			<srcfile prefix="name=Workers/" />
			<targetfile prefix="out=" />
			<globmapper from="*" to="${relativeCombineOutputDirectory}/Workers/*.js" />
			<mappedresources>
				<fileset dir="${sourceDirectory}/Workers">
					<include name="*.js" />
					<exclude name="*.profile.js" />
					<exclude name="cesiumWorkerBootstrapper.js" />
					<exclude name="transferTypedArrayTest.js" />
					<exclude name="createTaskProcessorWorker.js" />
				</fileset>
				<chainedmapper>
					<flattenmapper />
					<globmapper from="*.js" to="*" />
				</chainedmapper>
			</mappedresources>
		</apply>
	</target>

	<target name="combineJavaScript.combineCesium.check">
		<uptodate property="no.combineCesium.create" targetfile="${outputDirectory}/Cesium.js">
			<srcresources refid="cesiumJsFiles" />
		</uptodate>
	</target>

	<target name="combineJavaScript.combineCesiumWorkers.check">
		<uptodate property="no.combineCesiumWorkers.create" targetfile="${outputDirectory}/Cesium.js">
			<srcfiles refid="cesiumWorkersJsFileSet" />
		</uptodate>
	</target>

	<target name="combineJavaScript.createUnminified">
		<antcall target="combineJavaScript.create">
			<param name="optimize" value="none" />
			<param name="outputDirectory" value="${unminifiedOutputDirectory}" />
		</antcall>
	</target>

	<target name="combineJavascript.checkCopy">
		<condition property="combineJavascript.noCopy">
			<or>
				<istrue value="${build.minification}" />
				<isset property="build.debugUnminified" />
			</or>
		</condition>
	</target>

	<target name="combineJavaScript.copyUnminified" depends="combineJavascript.checkCopy" unless="${combineJavascript.noCopy}">
		<copy todir="${buildOutputDirectory}">
			<fileset dir="${unminifiedOutputDirectory}" />
		</copy>
	</target>

	<target name="combineJavaScript.createMinified" if="${build.minification}">
		<antcall target="combineJavaScript.create">
			<param name="optimize" value="uglify2" />
			<param name="outputDirectory" value="${buildOutputDirectory}" />
		</antcall>
	</target>

	<target name="combineJavaScript" depends="checkForNode,combineJavaScript.createUnminified,combineJavaScript.copyUnminified,combineJavaScript.createMinified" />

	<target name="minifyCSS" depends="checkForNode">
		<copy todir="${buildOutputDirectory}" includeEmptyDirs="false" overwrite="true">
			<fileset dir="${sourceDirectory}">
				<include name="**/*.css" />
			</fileset>
		</copy>
		<apply executable="node" dir="${buildOutputDirectory}" relative="true">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<srcfile prefix="cssIn=" />
			<targetfile prefix="out=" />
			<identitymapper />
			<fileset dir="${buildOutputDirectory}">
				<include name="**/*.css" />
			</fileset>
		</apply>
	</target>

	<target name="npmInstall">
		<exec executable="npm" dir="${basedir}" failonerror="true">
			<arg value="install" />
		</exec>
	</target>

	<target name="generateDocumentation" depends="checkForNode,npmInstall" description="Generates HTML documentation.">
		<exec executable="node" dir="${basedir}" failonerror="true">
			<env key="CESIUM_VERSION" value="${version}" />
			<arg value="node_modules/jsdoc/jsdoc.js" />
			<arg line="--configure Tools/jsdoc/conf.json" />
		</exec>

		<copy todir="${buildDocumentationImagesDirectory}">
			<fileset dir="${documentationImagesDirectory}" />
		</copy>
	</target>

	<target name="runServer" depends="checkForNode,npmInstall" description="Runs a local web server.">
		<echo>The local web server can also be launched directly by running: node server.js</echo>
		<condition property="runServer.arg.public" value="--public" else="">
			<istrue value="${runServer.public}" />
		</condition>
		<exec executable="node" dir="${basedir}" failonerror="true">
			<arg value="server.js" />
			<arg line="${runServer.arg.public}" />
			<arg line="--port ${runServer.port}" />
		</exec>
	</target>

	<target name="runPublicServer" description="Runs a public web server.">
		<antcall target="runServer">
			<param name="runServer.public" value="true" />
		</antcall><commit_msg>Fix npm install on Windows.<commit_after><project name="Cesium" default="combine">
	<target name="build" description="A developer build that prepares the source tree for use as standard AMD modules.">
		<mkdir dir="${buildDirectory}" />
		<glslToJavascript minify="${build.minification}" minifystatefile="${buildDirectory}/minifyShaders.state">
			<glslfiles dir="${shadersDirectory}" includes="**/*.glsl" />
			<existingjsfiles dir="${shadersDirectory}" includes="**/*.js" excludes="*.profile.js" />
		</glslToJavascript>

		<createCesiumJs output="${sourceDirectory}/Cesium.js">
			<sourcefiles refid="cesiumJsFiles" />
		</createCesiumJs>

		<createSpecList output="${specsDirectory}/SpecList.js">
			<specs dir="${specsDirectory}" includes="**/*.js" excludes="*.js" />
		</createSpecList>

		<createGalleryList output="${galleryDirectory}/gallery-index.js">
			<demos dir="${galleryDirectory}" includes="**/*.html" />
		</createGalleryList>

		<createSandcastleJsHintOptions output="${sandcastleDirectory}/jsHintOptions.js" jshintoptionspath="${jsHintOptionsPath}" />
	</target>

	<target name="combine" depends="build,combineJavaScript" description="Combines all source files into a single stand-alone script.">
		<copy todir="${buildDirectory}">
			<fileset dir="Apps/">
				<include name="HelloWorld.html" />
				<include name="index.html" />
			</fileset>
		</copy>

		<replace file="${buildDirectory}/HelloWorld.html" token="../Build/" value="" />
		<replace file="${buildDirectory}/index.html" token="../Build/" value="" />
	</target>

	<target name="minify" description="Combines all source files into a single stand-alone, minified script.">
		<antcall target="combine">
			<param name="build.minification" value="true" />
		</antcall>
		<antcall target="minifyCSS" />
	</target>

	<target name="combineRelease" description="Combines all source files into a single stand-alone script with debugging code removed.">
		<antcall target="combine">
			<param name="pragmas.debug" value="false" />
		</antcall>
	</target>

	<target name="minifyRelease" description="Combines all source files into a single stand-alone, minified script with debugging code removed.">
		<antcall target="minify">
			<param name="pragmas.debug" value="false" />
		</antcall>
	</target>

	<target name="release" description="A full release build that creates a shippable product, including building apps and generating documentation.">
		<antcall target="minifyRelease" />
		<antcall target="combine">
			<param name="build.debugUnminified" value="true" />
		</antcall>
		<antcall target="generateDocumentation" />
		<antcall target="buildApps" />
	</target>

	<target name="instrumentForCoverage" depends="build" description="A debug build instrumented for JSCoverage (currently Windows only).">
		<exec executable="${jscoveragePath}">
			<arg value="${sourceDirectory}" />
			<arg value="${instrumentedDirectory}" />
			<arg value="--no-instrument=./ThirdParty" />
		</exec>
	</target>

	<target name="makeZipFile" depends="release" description="Builds zip files containing all release files.">
		<zip destfile="Cesium-${version}.zip" basedir="${basedir}">
			<fileset dir="${buildDirectory}">
				<include name="Cesium/**" />
				<include name="Documentation/**" />
				<include name="*.html" />
			</fileset>
			<include name="server.js" />
			<include name="package.json" />
			<include name="LICENSE.md" />
			<include name="CHANGES.md" />
			<include name="README.md" />
		</zip>

		<zip destfile="Cesium-full-${version}.zip" basedir="${basedir}">
			<zipfileset dir="${buildDirectory}" prefix="Build">
				<include name="Cesium/**" />
				<include name="CesiumUnminified/**" />
				<include name="Documentation/**" />
				<include name="Apps/**" />
				<include name="*.html" />
			</zipfileset>
			<include name="Apps/**" />
			<include name="Examples/**" />
			<include name="Source/**" />
			<include name="Specs/**" />
			<include name="ThirdParty/**" />
			<include name="HelloWorld.html" />
			<include name="index.html" />
			<include name="server.js" />
			<include name="package.json" />
			<include name="LICENSE.md" />
			<include name="CHANGES.md" />
			<include name="README.md" />
		</zip>
	</target>

	<target name="clean" description="Removes all generated build artifacts.">
		<delete includeEmptyDirs="true" failonerror="false">
			<fileset dir="${sourceDirectory}" includes="Cesium.js" />
			<fileset dir="${buildDirectory}" defaultexcludes="false" />
			<fileset dir="${instrumentedDirectory}" defaultexcludes="false" />
			<fileset dir="${shadersDirectory}" includes="**/*.js" excludes="*.profile.js" />
			<fileset dir="${specsDirectory}" includes="SpecList.js" />
			<fileset dir="${sandcastleDirectory}" includes="jsHintOptions.js" />
			<fileset dir="${galleryDirectory}" includes="gallery-index.js" />
			<fileset dir="." includes="Cesium-*.zip" />
		</delete>
	</target>

	<!-- properties controlling which steps get run -->
	<property name="build.minification" value="false" />
	<property name="pragmas.debug" value="true" />

	<!-- properties controlling how to run the server-->
	<property name="runServer.public" value="false" />
	<property name="runServer.port" value="8080" />

	<!-- Inputs -->
	<!-- this version should be set to the upcoming version, so it can be tagged without requiring a bump first -->
	<property name="version" value="b29" />
	<property name="sourceDirectory" location="Source" />
	<property name="shadersDirectory" location="${sourceDirectory}/Shaders" />
	<property name="examplesDirectory" location="Examples" />
	<property name="sandcastleDirectory" location="Apps/Sandcastle" />
	<property name="galleryDirectory" location="${sandcastleDirectory}/gallery" />
	<property name="specsDirectory" location="Specs" />
	<property name="toolsDirectory" location="Tools" />
	<property name="tasksDirectory" location="${toolsDirectory}/buildTasks" />
	<property name="thirdPartyDirectory" location="ThirdParty" />
	<property name="requirejsPath" location="${thirdPartyDirectory}/requirejs-2.1.9" />
	<property name="rjsPath" location="${requirejsPath}/r.js" />
	<property name="rjsOptions" location="${toolsDirectory}/build.js" />
	<property name="almondPath" location="${thirdPartyDirectory}/almond-0.2.6/almond.js" />
	<property name="jscoveragePath" location="${toolsDirectory}/jscoverage-0.5.1/jscoverage.exe" />
	<property name="rhinoJarPath" location="${toolsDirectory}/rhino-1.7R4/js.jar" />
	<property name="documentationImagesDirectory" location="Documentation/Images" />
	<property name="jsdoc3Directory" location="${toolsDirectory}/jsdoc3" />
	<property name="webProxyDirectory" location="${toolsDirectory}/proxy" />
	<property name="jsHintPath" location="${thirdPartyDirectory}/jshint-2.1.10/jshint.js" />
	<property name="clocPath" location="${toolsDirectory}/cloc-1.60/cloc-1.60.pl" />
	<property name="clocDefinitionsPath" location="${toolsDirectory}/cloc-1.60/cloc_definitions" />
	<property name="jsHintOptionsPath" location=".jshintrc" />

	<!-- Outputs -->
	<property name="buildDirectory" location="Build" />
	<property name="buildOutputDirectory" location="${buildDirectory}/Cesium" />
	<property name="unminifiedOutputDirectory" location="${buildDirectory}/CesiumUnminified" />
	<property name="buildDocumentationDirectory" location="${buildDirectory}/Documentation" />
	<property name="buildDocumentationImagesDirectory" location="${buildDocumentationDirectory}/images" />
	<property name="instrumentedDirectory" location="Instrumented" />
	<property name="buildStubsDirectory" location="${buildDirectory}/Stubs" />

	<path id="javascriptClassPath">
		<pathelement path="${rhinoJarPath}" />
		<pathelement path="${toolsDirectory}/bsf-2.4.0/bsf.jar" />
		<pathelement path="${toolsDirectory}/commons-logging-1.1.1/commons-logging-1.1.1.jar" />
	</path>

	<union id="cesiumJsFiles">
		<fileset dir="${sourceDirectory}">
			<include name="**/*.js" />
			<exclude name="*.js" />
			<exclude name="Workers/**" />
			<exclude name="**/*.profile.js" />
		</fileset>
		<fileset dir="${sourceDirectory}">
			<include name="Workers/createTaskProcessorWorker.js" />
		</fileset>
	</union>

	<fileset dir="${sourceDirectory}" id="cesiumWorkersJsFileSet">
		<include name="**/*.js" />
		<exclude name="*.js" />
		<exclude name="**/*.profile.js" />
	</fileset>

	<scriptdef name="glslToJavascript" language="javascript" src="${tasksDirectory}/glslToJavaScript.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="minify" />
		<attribute name="minifystatefile" />
		<element name="glslfiles" type="fileset" />
		<element name="existingjsfiles" type="fileset" />
	</scriptdef>

	<scriptdef name="createCesiumJs" language="javascript" src="${tasksDirectory}/createCesiumJs.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<element name="sourcefiles" type="resources" />
	</scriptdef>

	<scriptdef name="createSpecList" language="javascript" src="${tasksDirectory}/createSpecList.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<element name="specs" type="fileset" />
	</scriptdef>

	<scriptdef name="createGalleryList" language="javascript" src="${tasksDirectory}/createGalleryList.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<element name="demos" type="fileset" />
	</scriptdef>

	<scriptdef name="createSandcastleJsHintOptions" language="javascript" src="${tasksDirectory}/createSandcastleJsHintOptions.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="output" />
		<attribute name="jshintoptionspath" />
	</scriptdef>

	<scriptdef name="runJsHint" language="javascript" src="${tasksDirectory}/runJsHint.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="jshintpath" />
		<attribute name="jshintoptionspath" />
		<attribute name="sandcastlejshintoptionspath" />
		<attribute name="failureproperty" />
		<element name="sourcefiles" type="fileset" />
	</scriptdef>

	<scriptdef name="generateStubs" language="javascript" src="${tasksDirectory}/generateStubs.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<attribute name="stuboutput" />
		<attribute name="pathsoutput" />
		<element name="sourcefiles" type="resources" />
	</scriptdef>

	<scriptdef name="sortRequires" language="javascript" src="${tasksDirectory}/sortRequires.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
		<element name="sourcefiles" type="fileset" />
	</scriptdef>

	<target name="jsHint" depends="build" description="Runs JSHint on the entire source tree.">
		<runJsHint jshintpath="${jsHintPath}" jshintoptionspath="${jsHintOptionsPath}" sandcastlejshintoptionspath="${sandcastleDirectory}/jsHintOptions.js" failureproperty="jsHint.failure">
			<sourcefiles dir="${basedir}">
				<include name="Source/**/*.js" />
				<exclude name="Source/Shaders/**" />
				<exclude name="Source/ThirdParty/**" />
				<exclude name="Source/Workers/cesiumWorkerBootstrapper.js" />

				<include name="Apps/**/*.js" />
				<include name="Apps/Sandcastle/gallery/*.html" />

				<exclude name="Apps/Sandcastle/ThirdParty/**" />

				<include name="Specs/**/*.js" />

				<include name="Tools/buildTasks/**/*.js" />
			</sourcefiles>
		</runJsHint>
		<fail if="jsHint.failure" message="JSHint failed!" />
	</target>

	<target name="sortRequires" description="Sorts the list of requires in all source files">
		<sortRequires>
			<sourcefiles dir="${basedir}">
				<include name="Source/**/*.js" />
				<exclude name="Source/Shaders/**" />
				<exclude name="Source/ThirdParty/**" />
				<exclude name="Source/Workers/cesiumWorkerBootstrapper.js" />
				<exclude name="Source/copyrightHeader.js" />
				<exclude name="Source/Workers/transferTypedArrayTest.js" />

				<include name="Apps/**/*.js" />
				<exclude name="Apps/Sandcastle/ThirdParty/**" />

				<include name="Specs/**/*.js" />
				<exclude name="Specs/SpecRunner.js" />
				<exclude name="Specs/SpecList.js" />

				<exclude name="Apps/Sandcastle/Sandcastle-client.js" />
				<exclude name="Apps/Sandcastle/Sandcastle-header.js" />
				<exclude name="Apps/Sandcastle/Sandcastle-warn.js" />
				<exclude name="Apps/Sandcastle/gallery/gallery-index.js" />
				<exclude name="Apps/Sandcastle/jsHintOptions.js" />

				<exclude name="**/*.profile.js" />
			</sourcefiles>
		</sortRequires>
	</target>

	<target name="cloc" depends="build" description="Runs cloc to count lines of code for Source and Specs directories.">
		<echo message="Source:" />
		<apply executable="perl" parallel="true">
			<arg value="${clocPath}" />
			<arg value="--read-lang-def=${clocDefinitionsPath}" />
			<arg value="Source/Core/" />
			<arg value="Source/DynamicScene/" />
			<arg value="Source/Renderer/" />
			<arg value="Source/Scene/" />
			<arg value="Source/Widgets/" />
			<arg value="Source/Workers/" />
			<fileset id="clocFileSet" dir="Source/">
				<include name="Shaders/*.glsl" />
				<include name="Shaders/**/*.glsl" />
				<include name="main.js" />
			</fileset>
		</apply>
		<echo message="${line.separator}Specs:" />
		<exec executable="perl">
			<arg value="${clocPath}" />
			<arg value="--read-lang-def=${clocDefinitionsPath}" />
			<arg value="Specs/" />
		</exec>
	</target>

	<target name="checkForNode">
		<exec executable="node" failonerror="false" failifexecutionfails="false" resultproperty="node.exec.result">
			<arg value="--version" />
		</exec>
		<fail message="Node.js is required to run this part of the build.  Install from http://nodejs.org/">
			<condition>
				<isfailure code="${node.exec.result}" />
			</condition>
		</fail>
	</target>

	<target name="combineJavaScript.create">
		<!-- create relative paths because r.js can't handle full Windows paths -->
		<property name="relativeAlmondPath" location="${almondPath}" relative="true" basedir="${sourceDirectory}" />
		<property name="combineOutputDirectory" location="${buildDirectory}/combineOutput" />

		<mkdir dir="${combineOutputDirectory}" />
		<property name="relativeCombineOutputDirectory" location="${combineOutputDirectory}" relative="true" basedir="${sourceDirectory}" />

		<!-- create combined Cesium.js	-->
		<antcall target="combineJavaScript.combineCesium" />

		<mkdir dir="${buildStubsDirectory}" />
		<generateStubs stuboutput="${buildStubsDirectory}/Cesium.js" pathsoutput="${buildStubsDirectory}/paths.js">
			<sourcefiles refid="cesiumJsFiles" />
		</generateStubs>

		<!-- create combined Cesium.js workers -->
		<antcall target="combineJavaScript.combineCesiumWorkers" />

		<!-- copy to build folder with copyright header added at the top -->
		<copy todir="${outputDirectory}">
			<fileset dir="${combineOutputDirectory}" />
			<filterchain>
				<concatfilter prepend="${sourceDirectory}/copyrightHeader.js" />
			</filterchain>
		</copy>

		<delete dir="${combineOutputDirectory}" />

		<!-- copy other resources -->
		<copy todir="${outputDirectory}" includeEmptyDirs="false">
			<fileset dir="${sourceDirectory}">
				<exclude name="**/*.js" />
				<exclude name="**/*.glsl" />
				<exclude name="**/.gitignore" />
				<exclude name="**/package.json" />
			</fileset>
		</copy>
	</target>

	<target name="combineJavaScript.combineCesium" depends="combineJavaScript.combineCesium.check" unless="no.combineCesium.create">
		<exec executable="node" dir="${sourceDirectory}">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<arg value="pragmas.debug=${pragmas.debug}" />
			<arg value="optimize=${optimize}" />
			<arg value="baseUrl=." />
			<arg value="skipModuleInsertion=true" />
			<arg value="name=${relativeAlmondPath}" />
			<arg value="include=main" />
			<arg value="out=${relativeCombineOutputDirectory}/Cesium.js" />
		</exec>
	</target>

	<target name="combineJavaScript.combineCesiumWorkers" depends="combineJavaScript.combineCesiumWorkers.check" unless="no.combineCesiumWorkers.create">
		<!-- create standalone worker files -->
		<apply executable="node" dir="${sourceDirectory}" relative="true" force="true">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<arg value="pragmas.debug=${pragmas.debug}" />
			<arg value="optimize=${optimize}" />
			<arg value="baseUrl=." />
			<arg value="skipModuleInsertion=true" />
			<arg value="wrap=false" />
			<srcfile prefix="include=Workers/" />
			<targetfile prefix="out=" />
			<globmapper from="*" to="${relativeCombineOutputDirectory}/Workers/*.js" />
			<mappedresources>
				<fileset dir="${sourceDirectory}/Workers">
					<include name="cesiumWorkerBootstrapper.js" />
					<include name="transferTypedArrayTest.js" />
				</fileset>
				<chainedmapper>
					<flattenmapper />
					<globmapper from="*.js" to="*" />
				</chainedmapper>
			</mappedresources>
		</apply>

		<!-- create combined worker layer files -->
		<apply executable="node" dir="${sourceDirectory}" relative="true" force="true">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<arg value="optimize=${optimize}" />
			<arg value="pragmas.debug=${pragmas.debug}" />
			<arg value="baseUrl=." />

			<srcfile prefix="name=Workers/" />
			<targetfile prefix="out=" />
			<globmapper from="*" to="${relativeCombineOutputDirectory}/Workers/*.js" />
			<mappedresources>
				<fileset dir="${sourceDirectory}/Workers">
					<include name="*.js" />
					<exclude name="*.profile.js" />
					<exclude name="cesiumWorkerBootstrapper.js" />
					<exclude name="transferTypedArrayTest.js" />
					<exclude name="createTaskProcessorWorker.js" />
				</fileset>
				<chainedmapper>
					<flattenmapper />
					<globmapper from="*.js" to="*" />
				</chainedmapper>
			</mappedresources>
		</apply>
	</target>

	<target name="combineJavaScript.combineCesium.check">
		<uptodate property="no.combineCesium.create" targetfile="${outputDirectory}/Cesium.js">
			<srcresources refid="cesiumJsFiles" />
		</uptodate>
	</target>

	<target name="combineJavaScript.combineCesiumWorkers.check">
		<uptodate property="no.combineCesiumWorkers.create" targetfile="${outputDirectory}/Cesium.js">
			<srcfiles refid="cesiumWorkersJsFileSet" />
		</uptodate>
	</target>

	<target name="combineJavaScript.createUnminified">
		<antcall target="combineJavaScript.create">
			<param name="optimize" value="none" />
			<param name="outputDirectory" value="${unminifiedOutputDirectory}" />
		</antcall>
	</target>

	<target name="combineJavascript.checkCopy">
		<condition property="combineJavascript.noCopy">
			<or>
				<istrue value="${build.minification}" />
				<isset property="build.debugUnminified" />
			</or>
		</condition>
	</target>

	<target name="combineJavaScript.copyUnminified" depends="combineJavascript.checkCopy" unless="${combineJavascript.noCopy}">
		<copy todir="${buildOutputDirectory}">
			<fileset dir="${unminifiedOutputDirectory}" />
		</copy>
	</target>

	<target name="combineJavaScript.createMinified" if="${build.minification}">
		<antcall target="combineJavaScript.create">
			<param name="optimize" value="uglify2" />
			<param name="outputDirectory" value="${buildOutputDirectory}" />
		</antcall>
	</target>

	<target name="combineJavaScript" depends="checkForNode,combineJavaScript.createUnminified,combineJavaScript.copyUnminified,combineJavaScript.createMinified" />

	<target name="minifyCSS" depends="checkForNode">
		<copy todir="${buildOutputDirectory}" includeEmptyDirs="false" overwrite="true">
			<fileset dir="${sourceDirectory}">
				<include name="**/*.css" />
			</fileset>
		</copy>
		<apply executable="node" dir="${buildOutputDirectory}" relative="true">
			<arg value="${rjsPath}" />
			<arg value="-o" />
			<arg value="${rjsOptions}" />
			<srcfile prefix="cssIn=" />
			<targetfile prefix="out=" />
			<identitymapper />
			<fileset dir="${buildOutputDirectory}">
				<include name="**/*.css" />
			</fileset>
		</apply>
	</target>

	<condition property="os.windows">
		<os family="windows" />
	</condition>

	<target name="npmInstall.nonWindows" unless="os.windows">
		<exec executable="npm" dir="${basedir}" failonerror="true">
			<arg value="install" />
		</exec>
	</target>

	<target name="npmInstall.windows" if="os.windows">
		<exec executable="cmd" dir="${basedir}" failonerror="true">
			<arg value="/c" />
			<arg value="npm.cmd" />
			<arg value="install" />
		</exec>
	</target>

	<target name="npmInstall" depends="npmInstall.windows,npmInstall.nonWindows" />

	<target name="generateDocumentation" depends="checkForNode,npmInstall" description="Generates HTML documentation.">
		<exec executable="node" dir="${basedir}" failonerror="true">
			<env key="CESIUM_VERSION" value="${version}" />
			<arg value="node_modules/jsdoc/jsdoc.js" />
			<arg line="--configure Tools/jsdoc/conf.json" />
		</exec>

		<copy todir="${buildDocumentationImagesDirectory}">
			<fileset dir="${documentationImagesDirectory}" />
		</copy>
	</target>

	<target name="runServer" depends="checkForNode,npmInstall" description="Runs a local web server.">
		<echo>The local web server can also be launched directly by running: node server.js</echo>
		<condition property="runServer.arg.public" value="--public" else="">
			<istrue value="${runServer.public}" />
		</condition>
		<exec executable="node" dir="${basedir}" failonerror="true">
			<arg value="server.js" />
			<arg line="${runServer.arg.public}" />
			<arg line="--port ${runServer.port}" />
		</exec>
	</target>

	<target name="runPublicServer" description="Runs a public web server.">
		<antcall target="runServer">
			<param name="runServer.public" value="true" />
		</antcall>
{'fraction_non_alphanumeric': 0.18487142096613662, 'fraction_numerical': 0.001990602504455709, 'mean_word_length': 5.148285185712253, 'pattern_counts': {'":': 0, '<': 930, '<?xml version=': 0, '>': 930, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3647223', 'n_tokens_mistral': 15000, 'n_tokens_neox': 13200, 'n_words': 2423}