| 468 | | <!-- -set-profile-deps task --> |
| 469 | | <target name="-set-profile-deps" depends="-fix-config" |
| 470 | | description="populates the contents of the dependency list for a given profile"> |
| 471 | | <!-- |
| 472 | | FIXME: this is just a stub! need to fill it in! |
| 473 | | --> |
| 474 | | <script language="javascript"> |
| 475 | | <![CDATA[ |
| 476 | | function echo(msg){ |
| 477 | | var echo = dojo.createTask("echo"); |
| 478 | | echo.setMessage(msg); |
| 479 | | echo.execute(); |
| 480 | | } |
| 481 | | var pf = dojo.getProperty("profileFile"); |
| 482 | | if((!pf)||(pf=="null")||(pf=="")){ |
| 483 | | // echo("profile: "+dojo.getProperty("profile"), compress); |
| 484 | | var prof = dojo.getProperty("profile"); |
| 485 | | if((prof)&&(prof!="null")&&(prof!="")){ |
| 486 | | dojo.setNewProperty("profileFile", "profiles/"+prof+".profile.js"); |
| 487 | | }else{ |
| 488 | | dojo.setNewProperty("profileFile", "getDependencyList.js"); |
| 489 | | } |
| 490 | | } |
| 491 | | ]]> |
| 492 | | </script> |
| 493 | | |
| 494 | | <!-- FIXME: need to actually get a list of js files to be processed --> |
| 495 | | |
| 496 | | <java jar="./lib/custom_rhino.jar" failonerror="true" |
| 497 | | fork="true" outputproperty="concatFilesProp" logError="true"> |
| 498 | | <arg value="-opt" /> |
| 499 | | <arg value="-1" /> |
| 500 | | <arg value="-f" /> |
| 501 | | <arg value="${profileFile}" /> |
| 502 | | <sysproperty key="DOJO_LOADER" value="${dojoLoader}" /> |
| 503 | | </java> |
| 504 | | |
| 505 | | <script language="javascript"> |
| 506 | | <![CDATA[ |
| 507 | | var currentTask = dojo.getTargets().get("-set-profile-deps"); |
| 508 | | var files = dojo.getProperty("concatFilesProp"); |
| 509 | | dojo.setNewProperty("profileDeps", files); |
| 510 | | ]]> |
| 511 | | </script> |
| 512 | | </target> |
| 513 | | <!-- end -set-profile-deps task --> |
| 514 | | |
| 515 | | <!-- list-profile-deps task --> |
| 516 | | <target name="list-profile-deps" depends="-fix-config, -set-profile-deps" |
| 517 | | description="lists out the contents of the file dependencies"> |
| 518 | | <echo level="info" taskName="list-profile-deps">${profileDeps}</echo> |
| 519 | | </target> |
| 520 | | <!-- end list-profile-deps task --> |
| 521 | | |
| 522 | | <!-- list-profile-sizes task --> |
| 523 | | <target name="list-profile-sizes" depends="-fix-config, -set-profile-deps" |
| 524 | | description="lists out the contents of the file dependencies"> |
| 525 | | <script language="javascript"> |
| 526 | | <![CDATA[ |
| 527 | | function echo(msg){ |
| 528 | | var echo = dojo.createTask("echo"); |
| 529 | | echo.setMessage(msg); |
| 530 | | echo.setTaskName("list-profile-sizes"); |
| 531 | | echo.execute(); |
| 532 | | } |
| 533 | | |
| 534 | | var files = new String(dojo.getProperty("profileDeps")); |
| 535 | | var outparts = files.split("\n"); |
| 536 | | for(var x=0; x<outparts.length; x++){ |
| 537 | | if(outparts[x][outparts[x].length-1]==","){ |
| 538 | | outparts[x] = outparts[x].substring(0, outparts[x].length-1); |
| 539 | | } |
| 540 | | var flen = parseInt(new java.io.File(new java.lang.String(outparts[x])).length()); |
| 541 | | echo(((flen>=1024) ? parseInt(flen/1024)+"K" : flen+"B") +": \t"+ outparts[x]); |
| 542 | | } |
| 543 | | ]]></script> |
| 544 | | <!-- <echo>${profileDeps}</echo> --> |
| 545 | | </target> |
| 546 | | <!-- end list-profile-sizes task --> |
| 547 | | |
| 548 | | <!-- compress task --> |
| 549 | | <target name="compress" depends="-fix-config, list-profile-deps" |
| 550 | | description="runs compression code over release JS files"> |
| 551 | | <echo level="info" taskName="compress">profileFile: ${profileFile}</echo> |
| 552 | | |
| 553 | | <!-- Create the release dir if it doesn't exist. --> |
| 554 | | <mkdir dir="${release_dir}"/> |
| 555 | | <!-- write the list of files included to the release directory --> |
| 556 | | <echo file="${release_dir}/build.txt">Files baked into this package: |
| 557 | | |
| 558 | | ${profileDeps}</echo> |
| 559 | | |
| 560 | | <!-- now write 'em all to a single file --> |
| 561 | | <concat fixlastline="yes" eol="crlf" destfile="${release_dir}/source.__package__.js"> |
| 562 | | <!-- |
| 563 | | <concat fixlastline="yes" eol="crlf" destfile="${release_dir}/dojo.js"> |
| 564 | | --> |
| 565 | | <filelist |
| 566 | | dir="." |
| 567 | | files="${profileDeps}" /> |
| 568 | | </concat> |
| 569 | | |
| 570 | | <!-- remove UTF-8 BOM sequence |
| 571 | | <replaceregexp match="\u00ef\u00bb\u00bf" encoding="utf-8" |
| 572 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 573 | | <substitution expression="BOM!"/> |
| 574 | | </replaceregexp> |
| 575 | | --> |
| 576 | | |
| 577 | | <!-- |
| 578 | | clobber requireIf and requireAfterIf statements since they |
| 579 | | aren't applicable in build |
| 580 | | --> |
| 581 | | <replaceregexp match="dojo.requireIf\((.*?)\);" |
| 582 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 583 | | <substitution expression=""/> |
| 584 | | </replaceregexp> |
| 585 | | |
| 586 | | <replaceregexp match="dojo.requireAfterIf\((.*?)\);" |
| 587 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 588 | | <substitution expression=""/> |
| 589 | | </replaceregexp> |
| 590 | | |
| 591 | | <!-- Set the version number --> |
| 592 | | <script language="jython" taskName="compress"> |
| 593 | | <![CDATA[ |
| 594 | | import sys |
| 595 | | # make the python standard library avialable |
| 596 | | sys.path.append(project.resolveFile("lib/pyLib.zip").getPath()) |
| 597 | | sys.path.append(project.resolveFile(".").getPath()) |
| 598 | | |
| 599 | | # import re |
| 600 | | import os |
| 601 | | from buildUtil import * |
| 602 | | |
| 603 | | print "Setting version for Dojo to: " + dojo.getProperty("version") |
| 604 | | replaceVersion(project.resolveFile(dojo.getProperty("release_dir") + "/source.__package__.js").getPath(), dojo.getProperty("version")) |
| 605 | | print "Removing dojo.require calls in source.__package__.js." |
| 606 | | removeRequires(project.resolveFile(dojo.getProperty("release_dir") + "/source.__package__.js").getPath()) |
| 607 | | ]]> |
| 608 | | </script> |
| 609 | | |
| 610 | | <antcall target="-preload-resources"> |
| 611 | | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| 612 | | <param name="dstFile" value="${release_dir}/source.__package__.js" /> |
| 613 | | <param name="buildPrefix" value="dojo" /> |
| 614 | | </antcall> |
| 615 | | |
| 616 | | <!-- |
| 617 | | clobber requireLocalization statements. They need to be come no-ops since the resources |
| 618 | | are now prebuilt and also because we do not want dojo.js to trigger XHRs on load |
| 619 | | --> |
| 620 | | <replaceregexp match="dojo.requireLocalization\((.*?)\);" |
| 621 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 622 | | <substitution expression=""/> |
| 623 | | </replaceregexp> |
| 624 | | |
| 625 | | <antcall target="-rhino-compress"> |
| 626 | | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| 627 | | <param name="dstFile" value="${release_dir}/dojo.js" /> |
| 628 | | </antcall> |
| 629 | | |
| 630 | | <antcall target="-no-rhino-compress"> |
| 631 | | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| 632 | | <param name="dstFile" value="${release_dir}/dojo.js" /> |
| 633 | | </antcall> |
| 634 | | |
| 635 | | <!-- add build notice --> |
| 636 | | <replaceregexp match="^" byline="false" replace="${build_notice}"> |
| 637 | | <fileset dir="${release_dir}" includes="dojo.js"/> |
| 638 | | </replaceregexp> |
| 639 | | |
| 640 | | <!-- add copyright notice --> |
| 641 | | <replaceregexp match="^" byline="false" replace="${copyright}"> |
| 642 | | <fileset dir="${release_dir}"> |
| 643 | | <include name="**/*.js" /> |
| 644 | | <include name="**/*.as" /> |
| 645 | | <not> |
| 646 | | <contains text="copyright" casesensitive="no" /> |
| 647 | | </not> |
| 648 | | </fileset> |
| 649 | | </replaceregexp> |
| 650 | | |
| 651 | | <delete file="${release_dir}/source.__package__.js"/> |
| 652 | | |
| 653 | | <!-- we copy over iframe_history.html here just in case this is a truly |
| 654 | | stand-alone build that isn't being kicked off via release --> |
| 655 | | <copy file="../iframe_history.html" todir="${release_dir}/" /> |
| 656 | | |
| 657 | | <!-- copy our dojo.storage and dojo.flash SWFs --> |
| 658 | | <copy todir="${release_dir}/" preservelastmodified="true"> |
| 659 | | <fileset dir="${root}/"> |
| 660 | | <include name="**/*.swf" /> |
| 661 | | <include name="*.jar" /> |
| 662 | | </fileset> |
| 663 | | </copy> |
| 664 | | |
| 665 | | </target> |
| 666 | | <!-- end compress task --> |
| 667 | | |
| 668 | | <target name="-rhino-compress" unless="nostrip"> |
| 669 | | <copy overwrite="true" file="${srcFile}" tofile="${dstFile}.uncompressed.js" /> |
| 670 | | <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true" |
| 671 | | logerror="true" output="${dstFile}"> |
| 672 | | <arg value="-strict" /> |
| 673 | | <arg value="-opt"/> |
| 674 | | <arg value="-1" /> |
| 675 | | <arg value="-c" /> |
| 676 | | <arg value="${srcFile}" /> |
| 677 | | </java> |
| 678 | | </target> |
| 679 | | |
| 680 | | <target name="-no-rhino-compress" |
| 681 | | if="nostrip"> |
| 682 | | <copy overwrite="true" file="${srcFile}" tofile="${dstFile}" /> |
| 683 | | </target> |
| 684 | | |
| 685 | | <target name="-flatten-resources" |
| 686 | | description="loads all localization bundles in the build for a particular locale, flattens the object, and outputs a preloaded version"> |
| 687 | | <!-- FIXME: should also remove dojo.requireLocalization() calls from the build? --> |
| 688 | | <copy overwrite="true" file="${srcFile}" tofile="${release_dir}/localizations.tmp.js"> |
| 689 | | <filterchain> |
| 690 | | <tokenfilter> |
| 691 | | <containsregex pattern="dojo\.requireLocalization\(.*\);"/> |
| 692 | | </tokenfilter> |
| 693 | | </filterchain> |
| 694 | | </copy> |
| 695 | | |
| 696 | | <!-- Hmm. have to repeat this work here even though it was done in -set-profile-deps. I guess script block changes |
| 697 | | to properties only last within that target? --> |
| | 504 | |
| | 505 | <!-- -set-profileFile task --> |
| | 506 | <target name="-set-profileFile" depends="-fix-config" |
| | 507 | description="Configures profileFile property."> |
| | 508 | <!-- Set up the profileFile property. --> |
| | 522 | </target> |
| | 523 | <!-- end -set-profileFile task --> |
| | 524 | |
| | 525 | <!-- list-profile-deps task --> |
| | 526 | <target name="list-profile-deps" depends="-fix-config, -set-profileFile" |
| | 527 | description="Lists the files that will be included in dojo.js for a given profile"> |
| | 528 | <!-- Call the JS script that will generate the file list. --> |
| | 529 | <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true" |
| | 530 | logError="true"> |
| | 531 | <arg value="listProfileDeps.js" /> |
| | 532 | <arg value="${profileFile}" /> |
| | 533 | <arg value="${version}" /> |
| | 534 | <sysproperty key="DOJO_LOADER" value="${dojoLoader}" /> |
| | 535 | </java> |
| | 536 | </target> |
| | 537 | <!-- end list-profile-deps task --> |
| | 538 | |
| | 539 | <!-- compress task --> |
| | 540 | <target name="compress" depends="-fix-config, -set-profileFile" |
| | 541 | description="runs compression code over release JS files"> |
| | 542 | <!-- Create the release dir if it doesn't exist. --> |
| | 543 | <mkdir dir="${release_dir}"/> |
| | 544 | |
| | 545 | <echo level="info" taskName="compress">profileFile: ${profileFile}</echo> |
| | 546 | |
| | 547 | <!-- Call the JS script that will generate the raw dojo.js file --> |
| | 548 | <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true" |
| | 549 | logError="true"> |
| | 550 | <arg value="makeDojoJs.js" /> |
| | 551 | <arg value="${profileFile}" /> |
| | 552 | <arg value="${release_dir}" /> |
| | 553 | <arg value="source.__package__.js" /> |
| | 554 | <arg value="${version}" /> |
| | 555 | <sysproperty key="DOJO_LOADER" value="${dojoLoader}" /> |
| | 556 | </java> |
| | 557 | |
| | 558 | <antcall target="-preload-resources"> |
| | 559 | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| | 560 | <param name="dstFile" value="${release_dir}/source.__package__.js" /> |
| | 561 | <param name="buildPrefix" value="dojo" /> |
| | 562 | </antcall> |
| | 563 | |
| | 564 | <!-- |
| | 565 | clobber requireLocalization statements. They need to be come no-ops since the resources |
| | 566 | are now prebuilt and also because we do not want dojo.js to trigger XHRs on load |
| | 567 | --> |
| | 568 | <replaceregexp match="dojo.requireLocalization\((.*?)\);" |
| | 569 | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| | 570 | <substitution expression=""/> |
| | 571 | </replaceregexp> |
| | 572 | |
| | 573 | <antcall target="-rhino-compress"> |
| | 574 | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| | 575 | <param name="dstFile" value="${release_dir}/dojo.js" /> |
| | 576 | </antcall> |
| | 577 | |
| | 578 | <antcall target="-no-rhino-compress"> |
| | 579 | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| | 580 | <param name="dstFile" value="${release_dir}/dojo.js" /> |
| | 581 | </antcall> |
| | 582 | |
| | 583 | <!-- add build notice --> |
| | 584 | <replaceregexp match="^" byline="false" replace="${build_notice}"> |
| | 585 | <fileset dir="${release_dir}" includes="dojo.js"/> |
| | 586 | </replaceregexp> |
| | 587 | |
| | 588 | <!-- add copyright notice --> |
| | 589 | <replaceregexp match="^" byline="false" replace="${copyright}"> |
| | 590 | <fileset dir="${release_dir}"> |
| | 591 | <include name="**/*.js" /> |
| | 592 | <include name="**/*.as" /> |
| | 593 | <not> |
| | 594 | <contains text="copyright" casesensitive="no" /> |
| | 595 | </not> |
| | 596 | </fileset> |
| | 597 | </replaceregexp> |
| | 598 | |
| | 599 | <delete file="${release_dir}/source.__package__.js"/> |
| | 600 | |
| | 601 | <!-- we copy over iframe_history.html here just in case this is a truly |
| | 602 | stand-alone build that isn't being kicked off via release --> |
| | 603 | <copy file="../iframe_history.html" todir="${release_dir}/" /> |
| | 604 | |
| | 605 | <!-- copy our dojo.storage and dojo.flash SWFs --> |
| | 606 | <copy todir="${release_dir}/" preservelastmodified="true"> |
| | 607 | <fileset dir="${root}/"> |
| | 608 | <include name="**/*.swf" /> |
| | 609 | <include name="*.jar" /> |
| | 610 | </fileset> |
| | 611 | </copy> |
| | 612 | |
| | 613 | </target> |
| | 614 | <!-- end compress task --> |
| | 615 | |
| | 616 | <target name="-rhino-compress" unless="nostrip"> |
| | 617 | <copy overwrite="true" file="${srcFile}" tofile="${dstFile}.uncompressed.js" /> |
| | 618 | <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true" |
| | 619 | logerror="true" output="${dstFile}"> |
| | 620 | <arg value="-strict" /> |
| | 621 | <arg value="-opt"/> |
| | 622 | <arg value="-1" /> |
| | 623 | <arg value="-c" /> |
| | 624 | <arg value="${srcFile}" /> |
| | 625 | </java> |
| | 626 | </target> |
| | 627 | |
| | 628 | <target name="-no-rhino-compress" |
| | 629 | if="nostrip"> |
| | 630 | <copy overwrite="true" file="${srcFile}" tofile="${dstFile}" /> |
| | 631 | </target> |
| | 632 | |
| | 633 | <target name="-flatten-resources" depends="-set-profileFile" |
| | 634 | description="loads all localization bundles in the build for a particular locale, flattens the object, and outputs a preloaded version"> |
| | 635 | <!-- FIXME: should also remove dojo.requireLocalization() calls from the build? --> |
| | 636 | <copy overwrite="true" file="${srcFile}" tofile="${release_dir}/localizations.tmp.js"> |
| | 637 | <filterchain> |
| | 638 | <tokenfilter> |
| | 639 | <containsregex pattern="dojo\.requireLocalization\(.*\);"/> |
| | 640 | </tokenfilter> |
| | 641 | </filterchain> |
| | 642 | </copy> |
| | 643 | |