forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
537 lines (454 loc) · 19 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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
<project name="Cesium" default="combine">
<target name="build" description="A developer build that runs in-place.">
<glslToJavascript stripcomments="${build.minification}">
<fileset dir="${shadersDirectory}" includes="**/*.glsl" />
</glslToJavascript>
<parallel>
<createCesiumJs output="${sourceDirectory}/Cesium.js">
<fileset dir="${sourceDirectory}">
<include name="**/*.js" />
<exclude name="Widgets/**" />
<exclude name="Cesium.js" />
<exclude name="main.js" />
<exclude name="**/*.profile.js" />
</fileset>
</createCesiumJs>
<createSpecList output="${specsDirectory}/SpecList.js">
<fileset dir="${specsDirectory}" includes="**/*.js" excludes="*.js" />
</createSpecList>
<createGalleryList output="${galleryDirectory}/gallery-index.js">
<fileset dir="${galleryDirectory}" includes="**/*.html" />
</createGalleryList>
</parallel>
</target>
<target name="combine" description="Combines all source files into a single stand-alone script." depends="build, combineJavaScript" />
<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>
</target>
<target name="release" description="A full release build that creates a shippable product, including documentation.">
<antcall target="combine">
<param name="build.minification" value="true" />
</antcall>
<antcall target="generateDocumentation" />
<antcall target="buildApps" />
</target>
<target name="instrumentForCoverage" description="A debug build instrumented for JSCoverage (currently Windows only)." depends="build">
<exec executable="${jscoveragePath}">
<arg line="${sourceDirectory} ${instrumentedDirectory}" />
<arg line="--no-instrument=./ThirdParty" />
</exec>
</target>
<target name="makeZipFile" description="Builds a zip file containing all release files." depends="release">
<zip destfile="Cesium-${version}.zip" basedir="${basedir}">
<include name="Build/**" />
<include name="Apps/**" />
<include name="Examples/**" />
<include name="Images/**" />
<include name="Source/**" />
<include name="Specs/**" />
<include name="ThirdParty/**" />
<include name="index.html" />
<include name="LICENSE.md" />
<include name="CHANGES.md" />
<include name="README.md" />
</zip>
</target>
<target name="clean" description="Cleans the build.">
<delete includeEmptyDirs="true" failonerror="false">
<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="${galleryDirectory}" includes="gallery-index.js" />
<fileset dir="." includes="Cesium-*.zip" />
</delete>
</target>
<!-- properties controlling which steps get run -->
<property name="build.minification" value="false" />
<!-- Inputs -->
<property name="version" value="b8" />
<property name="sourceDirectory" location="Source" />
<property name="shadersDirectory" location="${sourceDirectory}/Shaders" />
<property name="examplesDirectory" location="Examples" />
<property name="galleryDirectory" location="Apps/Sandcastle/gallery" />
<property name="specsDirectory" location="Specs" />
<property name="imagesDirectory" location="Images" />
<property name="toolsDirectory" location="Tools" />
<property name="thirdPartyDirectory" location="ThirdParty" />
<property name="rjsPath" location="${thirdPartyDirectory}/requirejs-1.0.8/r.js" />
<property name="almondPath" location="${thirdPartyDirectory}/almond-0.0.3/almond.js" />
<property name="jscoveragePath" location="${toolsDirectory}/jscoverage-0.5.1/jscoverage.exe" />
<property name="documentationImagesDirectory" location="Documentation/Images" />
<property name="jsdoc3Directory" location="${toolsDirectory}/jsdoc3" />
<property name="webProxyDirectory" location="${toolsDirectory}/proxy" />
<property name="dojoPath" location="${thirdPartyDirectory}/dojo-release-1.7.2-src" />
<!-- Outputs -->
<property name="buildDirectory" location="Build" />
<property name="instrumentedDirectory" location="Instrumented" />
<property name="buildOutputDirectory" location="${buildDirectory}/Cesium" />
<property name="buildDocumentationDirectory" location="${buildDirectory}/Documentation" />
<property name="buildDocumentationImagesDirectory" location="${buildDocumentationDirectory}/images" />
<property name="builtCesiumFile" location="${buildDirectory}/Cesium.js" />
<!-- ********************************************************************** -->
<scriptdef name="glslToJavascript" language="javascript">
<!-- Scott Hunter is my hero. - Cozzi -->
<attribute name="stripcomments" />
<element name="fileset" type="fileset" />
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.FileWriter);
importClass(java.io.StringReader);
importClass(Packages.org.apache.tools.ant.util.FileUtils);
importClass(Packages.org.apache.tools.ant.filters.StripJavaComments);
var stripComments = attributes.get("stripcomments");
var filesets = elements.get("fileset");
for (var i = 0; i < filesets.size(); i++) {
var fileset = filesets.get(i);
var basedir = fileset.getDir(project);
var filenames = fileset.getDirectoryScanner(project).getIncludedFiles();
for (var j = 0; j < filenames.length; j++) {
var filename = filenames[j];
var file = new File(basedir, filename);
var targetFile = new File(basedir, filename.replace('.glsl', '.js'));
if (file.lastModified() < targetFile.lastModified()) {
continue;
}
var reader = new FileReader(file);
var contents = String(FileUtils.readFully(reader));
reader.close();
contents = contents.replace(/\r\n/gm, '\n');
var copyrightComments = contents.match(/\/\*\!(?:.|\n)*?\*\//gm) || [];
if (stripComments) {
contents = String(FileUtils.readFully(new StripJavaComments(new StringReader(contents))));
contents = contents.replace(/\s+$/gm, '').replace(/^\s+/gm, '').replace(/\n+/gm, '\n');
contents += '\n';
}
contents = contents.split('"').join('\\"').replace(/\n/gm, '\\n" +\n"');
contents = copyrightComments.join('\n') + '\n' +
'/*global define*/\n' +
'define(function() {\n' +
' "use strict";\n' +
' return "' + contents + '";\n' +
'});'
var writer = new FileWriter(targetFile);
writer.write(contents);
writer.close();
}
}
]]>
</scriptdef>
<scriptdef name="extractShaderComments" language="javascript">
<element name="fileset" type="fileset" />
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.FileWriter);
importClass(Packages.org.apache.tools.ant.util.FileUtils);
var filesets = elements.get("fileset");
for (var i = 0; i < filesets.size(); i++) {
var fileset = filesets.get(i);
var basedir = fileset.getDir(project);
var filenames = fileset.getDirectoryScanner(project).getIncludedFiles();
var glslDoc = "";
for (var j = 0; j < filenames.length; j++) {
var filename = filenames[j];
var file = new File(basedir, filename);
var reader = new FileReader(file);
var contents = String(FileUtils.readFully(reader));
reader.close();
contents = contents.replace(/\r\n/gm, '\n');
var docComments = contents.match(/\/\*\*[\s\S]*?\*\//gm) || [];
if (docComments.length > 0) {
glslDoc = glslDoc + docComments.join('\n');
}
}
var glslDocFile = new File(basedir, 'glslComments.js');
var glslDocWriter = new FileWriter(glslDocFile);
glslDocWriter.write(glslDoc);
glslDocWriter.close();
}
]]>
</scriptdef>
<scriptdef name="createCesiumJs" language="javascript">
<attribute name="output" />
<element name="fileset" type="fileset" />
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.FileWriter);
importClass(Packages.org.apache.tools.ant.util.FileUtils);
var moduleIds = [];
var parameters = [];
var assignments = [];
var filesets = elements.get("fileset");
for (var i = 0, len = filesets.size(); i < len; i++) {
var fileset = filesets.get(i);
var basedir = fileset.getDir(project);
var filenames = fileset.getDirectoryScanner(project).getIncludedFiles();
for (var j = 0, len2 = filenames.length; j < len2; j++) {
var relativePath = filenames[j];
var file = new File(basedir, relativePath);
var moduleId = relativePath.replace('\\', '/');
moduleId = moduleId.substring(0, moduleId.lastIndexOf('.'));
var baseName = file.getName();
var assignmentName = baseName.substring(0, baseName.lastIndexOf('.'));
if (/Shaders\//.test(moduleId)) {
assignmentName = '_shaders.' + assignmentName;
}
var parameterName = moduleId.replace('/', '_');
moduleIds.push("'" + moduleId + "'");
parameters.push(parameterName);
assignments.push('Cesium.' + assignmentName + ' = ' + parameterName + ';');
}
}
var output = attributes.get("output");
if (new File(output).exists()) {
var reader = new FileReader(output);
var oldContents = String(FileUtils.readFully(reader));
reader.close();
}
var contents = '/*global define*/\n' +
'define([' + moduleIds.join(', ') + '], function (' + parameters.join(', ') + ') {\n' +
' "use strict";\n' +
' var Cesium = { _shaders : {} };\n ' +
assignments.join('\n ') + '\n' +
' return Cesium;\n' +
'});';
if (oldContents !== contents) {
var writer = new FileWriter(output);
writer.write(contents);
writer.close();
}
]]>
</scriptdef>
<scriptdef name="createSpecList" language="javascript">
<attribute name="output" />
<element name="fileset" type="fileset" />
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.FileWriter);
importClass(Packages.org.apache.tools.ant.util.FileUtils);
var specs = [];
var filesets = elements.get("fileset");
for (var i = 0, len = filesets.size(); i < len; i++) {
var fileset = filesets.get(i);
var basedir = fileset.getDir(project);
var filenames = fileset.getDirectoryScanner(project).getIncludedFiles();
for (var j = 0, len2 = filenames.length; j < len2; j++) {
var relativePath = filenames[j];
var spec = relativePath.substring(0, relativePath.lastIndexOf('.')).replace('\\', '/');
specs.push("'Specs/" + spec + "'");
}
}
var output = attributes.get("output");
if (new File(output).exists()) {
var reader = new FileReader(output);
var oldContents = String(FileUtils.readFully(reader));
reader.close();
}
var contents = 'var specs = [' + specs.join(',') + '];';
if (oldContents !== contents) {
var writer = new FileWriter(output);
writer.write(contents);
writer.close();
}
]]>
</scriptdef>
<scriptdef name="createGalleryList" language="javascript">
<attribute name="output" />
<element name="fileset" type="fileset" />
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.FileWriter);
importClass(Packages.org.apache.tools.ant.util.FileUtils);
var demos = [];
var filesets = elements.get("fileset");
for (var i = 0, len = filesets.size(); i < len; i++) {
var fileset = filesets.get(i);
var basedir = fileset.getDir(project);
var filenames = fileset.getDirectoryScanner(project).getIncludedFiles();
for (var j = 0, len2 = filenames.length; j < len2; j++) {
var relativePath = filenames[j];
var demo = relativePath.substring(0, relativePath.lastIndexOf('.')).replace('\\', '/');
var thumbnail = new File(basedir, demo + '.jpg').exists() ? (", 'img':'" + demo + ".jpg'") : '';
var fileDate = new File(basedir, demo + '.html').lastModified().toString();
demos.push("\n\t{'name':'" + demo + "'" + thumbnail + ", 'date':" + fileDate + '}');
}
}
var output = attributes.get("output");
if (new File(output).exists()) {
var reader = new FileReader(output);
var oldContents = String(FileUtils.readFully(reader));
reader.close();
}
var contents = '// This file is automatically rebuilt by the Cesium build process.\n' +
'var gallery_demos = [' + demos.join(',') + '\n];';
if (oldContents !== contents) {
var writer = new FileWriter(output);
writer.write(contents);
writer.close();
}
]]>
</scriptdef>
<target name="combineJavaScript.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="combineJavaScript.setNodePathLocation" if="nodePathValue">
<property name="nodePath" location="${nodePathValue}" />
</target>
<target name="combineJavaScript.setNodePath" depends="combineJavaScript.setNodePathValue,combineJavaScript.setNodePathLocation">
<condition property="nodePath" value="node">
<not>
<isset property="nodePath" />
</not>
</condition>
</target>
<target name="combineJavaScript.runrjs">
<!-- create relative paths because r.js can't handle full Windows paths -->
<property name="relativeAlmondPath" location="${almondPath}" relative="true" basedir="${sourceDirectory}" />
<property name="relativeCesiumFilePath" location="${buildDirectory}\temp.js" relative="true" basedir="${sourceDirectory}" />
<exec executable="${nodePath}" dir="${sourceDirectory}">
<arg line="${rjsPath} -o optimize=${optimize} wrap=true baseUrl=. name=${relativeAlmondPath} include=main out=${relativeCesiumFilePath}" />
</exec>
<concat destfile="${builtCesiumFile}">
<header trimleading="true">
/*!
* Copyright 2011-2012 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*/
</header>
<fileset file="${buildDirectory}\temp.js" />
</concat>
<delete file="${buildDirectory}\temp.js" />
</target>
<target name="combineJavaScript.createUnminified" depends="combineJavaScript.setNodePath">
<antcall target="combineJavaScript.runrjs">
<param name="optimize" value="none" />
</antcall>
<copy file="${builtCesiumFile}" tofile="${buildDirectory}/CesiumUnminified.js" />
</target>
<target name="combineJavaScript.createMinified" if="${build.minification}">
<antcall target="combineJavaScript.runrjs">
<param name="optimize" value="uglify" />
</antcall>
</target>
<target name="combineJavaScript" depends="combineJavaScript.createUnminified,combineJavaScript.createMinified" />
<target name="copyIndexHtml">
<copy file="index.html" todir="${buildDirectory}" />
</target>
<target name="generateDocumentation">
<extractShaderComments>
<fileset 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">
<arg line="-modules node_modules -modules rhino_modules -modules ." />
<arg line="jsdoc.js" />
<arg line="-r" />
<arg line="-d ${relativeDocOutputDirectory}" />
<arg line="${relativeSourceFilesPath}" />
</java>
<copy todir="${buildDocumentationImagesDirectory}">
<fileset dir="${documentationImagesDirectory}" />
</copy>
</target>
<target name="runServer">
<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
listenOnAllAddresses: Set to true if you want the server to listen to all addresses, not just localhost.
-->
<server proxyContextPath="/proxy" allowedHostList="localhost,*.arcgisonline.com,tile.openstreetmap.org,otile1.mqcdn.com,oatile1.mqcdn.com,tile.stamen.com,*.virtualearth.net" port="8080" baseDir="${basedir}" />
</target>
<target name="buildApps">
<antcall target="buildApp">
<param name="app.path" value="Apps/CesiumViewer" />
</antcall>
</target>
<target name="buildApp">
<java classname="org.mozilla.javascript.tools.shell.Main" fork="true">
<classpath>
<pathelement location="${dojoPath}/util/shrinksafe/js.jar" />
<pathelement location="${dojoPath}/util/closureCompiler/compiler.jar " />
</classpath>
<sysproperty key="java.util.logging.config.file" value="${toolsDirectory}/dojoBuildLogging.properties" />
<arg line="${dojoPath}/dojo/dojo.js" />
<arg line="baseUrl=${dojoPath}/dojo" />
<arg line="load=build" />
<arg line="--require ${app.path}/boot.js" />
<arg line="--profile ${app.path}/CesiumViewer.profile.js" />
</java>
<delete>
<fileset dir="${buildDirectory}/${app.path}" includes="**/*.uncompressed.js" />
</delete>
<copy todir="${buildDirectory}/${app.path}">
<fileset dir=".">
<include name="Images/*" />
</fileset>
</copy>
<replace dir="${buildDirectory}/${app.path}" summary="true">
<include name="index.html" />
<include name="*.css" />
<replacefilter token="../../" value="" />
<replacefilter token="ThirdParty/dojo-release-1.7.2-src/" value="" />
<replacefilter token="Source/" value="" />
</replace>
<replace dir="${buildDirectory}/${app.path}" summary="true">
<replacefilter token="ThirdParty/dojo-release-1.7.2-src/" value="" />
<include name="boot.js" />
<include name="dojo/dojo.js" />
</replace>
<fileset dir="${buildDirectory}/${app.path}" id="jsFiles">
<include name="boot.js" />
<include name="dojo/dojo.js" />
</fileset>
<replaceregexp match="(location\s*:\s*["'])Source/" flags="g" replace="\1">
<fileset refid="jsFiles" />
</replaceregexp>
<replaceregexp match="(location\s*:\s*["'])${app.path}" flags="g" replace="\1.">
<fileset refid="jsFiles" />
</replaceregexp>
<replaceregexp match="(baseUrl\s*:\s*["'])../.." flags="g" replace="\1.">
<fileset refid="jsFiles" />
</replaceregexp>
</target>
</project>