forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
517 lines (443 loc) · 20.9 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<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="cesiumJsFileSet" />
</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="Build">
<fileset dir="Apps/">
<include name="HelloWorld.html" />
<include name="index.html" />
<include name="server.js" />
</fileset>
</copy>
<replace file="Build/HelloWorld.html" token="../Build/" value="" />
<replace file="Build/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="release" description="A full release build that creates a shippable product, including building apps and generating documentation.">
<antcall target="minify" />
<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="Build">
<include name="Cesium/**" />
<include name="Documentation/**" />
<include name="HelloWorld.html" />
<include name="index.html" />
<include name="server.js" />
</fileset>
<include name="LICENSE.md" />
<include name="CHANGES.md" />
<include name="README.md" />
</zip>
<zip destfile="Cesium-full-${version}.zip" basedir="${basedir}">
<include name="Build/**" />
<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="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" />
<!-- properties controlling how to run the server-->
<property name="runServer.public" value="false" />
<property name="runServer.port" value="8080" />
<property name="runServer.allowedHosts" value="localhost,*.arcgisonline.com,tile.openstreetmap.org,otile1.mqcdn.com,oatile1.mqcdn.com,tile.stamen.com,*.virtualearth.net,mesonet.agron.iastate.edu" />
<!-- Inputs -->
<!-- this version should be set to the upcoming version, so it can be tagged without requiring a bump first -->
<property name="version" value="b20" />
<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.6" />
<property name="rjsPath" location="${requirejsPath}/r.js" />
<property name="rjsOptions" location="${toolsDirectory}/build.js" />
<property name="almondPath" location="${thirdPartyDirectory}/almond-0.2.5/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.2/jshint-2.1.2.js" />
<property name="jsHintOptionsPath" location=".jshintrc" />
<!-- properties controlling documentation source-->
<property name="githubRepoLink" value="https://github.com/AnalyticalGraphicsInc/cesium/" />
<property name="githubLinkExt" value="blob/" />
<!-- 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" />
<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>
<fileset dir="${sourceDirectory}" id="cesiumJsFileSet">
<include name="**/*.js" />
<exclude name="*.js" />
<exclude name="Workers/**" />
<exclude name="**/*.profile.js" />
</fileset>
<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="extractShaderComments" language="javascript" src="${tasksDirectory}/extractShaderComments.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
<attribute name="output" />
<element name="glslfiles" 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="fileset" />
</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>
<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="setNodePathValue">
<condition property="nodePathValue" value="${toolsDirectory}/nodejs-0.6.17/windows/node.exe">
<os family="windows" />
</condition>
<condition property="nodePathValue" value="${toolsDirectory}/nodejs-0.6.17/mac/node">
<os family="mac" />
</condition>
<condition property="nodePathValue" value="${toolsDirectory}/nodejs-0.6.17/linux/node">
<os family="unix" />
</condition>
</target>
<target name="setNodePathLocation" if="nodePathValue">
<property name="nodePath" location="${nodePathValue}" />
</target>
<target name="setNodePath" depends="setNodePathValue,setNodePathLocation">
<condition property="nodePath" value="node">
<not>
<isset property="nodePath" />
</not>
</condition>
</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" />
<!-- 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="${nodePath}" dir="${sourceDirectory}">
<arg value="${rjsPath}" />
<arg value="-o" />
<arg value="${rjsOptions}" />
<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 cesiumWorkerBootstrapper -->
<exec executable="${nodePath}" dir="${sourceDirectory}">
<arg value="${rjsPath}" />
<arg value="-o" />
<arg value="${rjsOptions}" />
<arg value="optimize=${optimize}" />
<arg value="baseUrl=." />
<arg value="skipModuleInsertion=true" />
<arg value="wrap=false" />
<arg value="include=Workers/cesiumWorkerBootstrapper.js" />
<arg value="out=${relativeCombineOutputDirectory}/Workers/cesiumWorkerBootstrapper.js" />
</exec>
<!-- create each combined worker layer -->
<apply executable="${nodePath}" dir="${sourceDirectory}" relative="true" force="true">
<arg value="${rjsPath}" />
<arg value="-o" />
<arg value="${rjsOptions}" />
<arg value="optimize=${optimize}" />
<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="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">
<srcfiles refid="cesiumJsFileSet" />
</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.copyUnminified" unless="${build.minification}">
<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="setNodePath,combineJavaScript.createUnminified,combineJavaScript.copyUnminified,combineJavaScript.createMinified" />
<target name="minifyCSS" depends="setNodePath">
<copy todir="${buildOutputDirectory}" includeEmptyDirs="false" overwrite="true">
<fileset dir="${sourceDirectory}">
<include name="**/*.css" />
</fileset>
</copy>
<apply executable="${nodePath}" 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="generateDocumentation" description="Generates HTML documentation.">
<extractShaderComments output="${shadersDirectory}/glslComments.js">
<glslfiles dir="${shadersDirectory}" includes="**/*.glsl" />
</extractShaderComments>
<!--
These needs to be a relative path because Rhino doesn't work properly with Windows
absolute paths:
https://github.com/mozilla/rhino/issues/10
-->
<property name="relativeDocOutputDirectory" location="${buildDocumentationDirectory}" relative="true" basedir="${jsdoc3Directory}" />
<property name="relativeSourceFilesPath" location="${sourceDirectory}" relative="true" basedir="${jsdoc3Directory}" />
<java jar="${jsdoc3Directory}/lib/js.jar" dir="${jsdoc3Directory}" fork="true" failonerror="true">
<arg line="-modules node_modules" />
<arg line="-modules rhino_modules" />
<arg line="-modules ." />
<arg value="jsdoc.js" />
<arg value="-r" />
<arg line="-d ${relativeDocOutputDirectory}" />
<arg value="${relativeSourceFilesPath}" />
<arg value="${version}" />
<arg value="${githubRepoLink}" />
<arg value="${githubLinkExt}" />
</java>
<copy todir="${buildDocumentationImagesDirectory}">
<fileset dir="${documentationImagesDirectory}" />
</copy>
</target>
<target name="runServer" description="Runs a local web server.">
<taskdef name="server" classname="com.agi.ServerTask">
<classpath>
<fileset dir="${webProxyDirectory}" includes="**/*.jar" />
</classpath>
</taskdef>
<!--
Other server options:
upstreamProxyHost: a standard proxy server that the local server will use to retrieve data
upstreamProxyPort: the port number of the upstream proxy, default 80
noUpstreamProxyHostList: A comma-separated list of hosts that will not use the upstreamProxy
-->
<server listenOnAllAddresses="${runServer.public}" allowedHostList="${runServer.allowedHosts}" port="${runServer.port}" baseDir="${basedir}" proxyContextPath="/proxy" terrainTranscodingContextPath="/terrain" mimeTypesPath="${webProxyDirectory}/mime.properties" />
</target>
<target name="runPublicServer" description="Runs a public web server.">
<antcall target="runServer">
<param name="runServer.public" value="true" />
</antcall>
</target>
<target name="buildApps" description="Create built versions of all example applications.">
<antcall target="combine">
<param name="build.minification" value="true" />
</antcall>
<antcall target="buildCesiumViewer" />
</target>
<target name="buildCesiumViewer" depends="setNodePath">
<property name="cesiumViewerDirectory" location="Apps/CesiumViewer" />
<property name="cesiumViewerOutputDirectory" location="${buildDirectory}/Apps/CesiumViewer" />
<mkdir dir="${cesiumViewerOutputDirectory}" />
<property name="relativeCesiumViewerOutputDirectory" location="${cesiumViewerOutputDirectory}" relative="true" basedir="${cesiumViewerDirectory}" />
<!-- mainConfigFile is relative to the build.js file -->
<exec executable="${nodePath}" dir="${cesiumViewerDirectory}">
<arg value="${rjsPath}" />
<arg value="-o" />
<arg value="${rjsOptions}" />
<arg value="optimize=uglify2" />
<arg value="mainConfigFile=../Apps/CesiumViewer/CesiumViewerStartup.js" />
<arg value="name=CesiumViewer/CesiumViewerStartup" />
<arg value="out=${relativeCesiumViewerOutputDirectory}/CesiumViewerStartup.js" />
</exec>
<exec executable="${nodePath}" dir="${cesiumViewerDirectory}">
<arg value="${rjsPath}" />
<arg value="-o" />
<arg value="${rjsOptions}" />
<arg value="cssIn=CesiumViewer.css" />
<arg value="out=${relativeCesiumViewerOutputDirectory}/CesiumViewer.css" />
</exec>
<!-- Copy other app files -->
<copy todir="${cesiumViewerOutputDirectory}">
<fileset dir="${cesiumViewerDirectory}">
<exclude name="*.js" />
<exclude name="*.css" />
</fileset>
</copy>
<!-- Copy RequireJS -->
<copy file="${requirejsPath}/require.min.js" tofile="${cesiumViewerOutputDirectory}/require.js" />
<!-- Copy the built Cesium assets and workers -->
<copy todir="${cesiumViewerOutputDirectory}">
<fileset dir="${buildOutputDirectory}" excludes="Cesium.js" />
</copy>
<!-- rewrite the paths in the configuration -->
<replace dir="${cesiumViewerOutputDirectory}" summary="true">
<replacefilter token="../../Source" value="." />
<replacefilter token="../Apps/CesiumViewer" value="." />
<replacefilter token="../ThirdParty/requirejs-2.1.6" value="." />
<include name="CesiumViewerStartup.js" />
</replace>
<!-- rewrite the paths in the HTML -->
<replace dir="${cesiumViewerOutputDirectory}" summary="true">
<replacefilter token="../../ThirdParty/requirejs-2.1.6" value="." />
<include name="index.html" />
</replace>
<!-- rewrite the paths in the CSS -->
<replace dir="${cesiumViewerOutputDirectory}" summary="true">
<replacefilter token="../../Source/" value="" />
<include name="*.css" />
</replace>
</target>
</project>