| 525 | | <!-- -set-profile-deps task --> |
| 526 | | <target name="-set-profile-deps" depends="-fix-config" |
| 527 | | description="populates the contents of the dependency list for a given profile"> |
| 528 | | <!-- |
| 529 | | FIXME: this is just a stub! need to fill it in! |
| 530 | | --> |
| 531 | | <script language="javascript"> |
| 532 | | <![CDATA[ |
| 533 | | function echo(msg){ |
| 534 | | var echo = dojo.createTask("echo"); |
| 535 | | echo.setMessage(msg); |
| 536 | | echo.execute(); |
| 537 | | } |
| 538 | | var pf = dojo.getProperty("profileFile"); |
| 539 | | if((!pf)||(pf=="null")||(pf=="")){ |
| 540 | | // echo("profile: "+dojo.getProperty("profile"), compress); |
| 541 | | var prof = dojo.getProperty("profile"); |
| 542 | | if((prof)&&(prof!="null")&&(prof!="")){ |
| 543 | | dojo.setNewProperty("profileFile", "profiles/"+prof+".profile.js"); |
| 544 | | }else{ |
| 545 | | dojo.setNewProperty("profileFile", "getDependencyList.js"); |
| 546 | | } |
| 547 | | } |
| 548 | | ]]> |
| 549 | | </script> |
| 550 | | |
| 551 | | <!-- FIXME: need to actually get a list of js files to be processed --> |
| 552 | | |
| 553 | | <java jar="./lib/custom_rhino.jar" failonerror="true" |
| 554 | | fork="true" outputproperty="concatFilesProp" logError="true"> |
| 555 | | <arg value="-opt" /> |
| 556 | | <arg value="-1" /> |
| 557 | | <arg value="-f" /> |
| 558 | | <arg value="${profileFile}" /> |
| 559 | | <sysproperty key="DOJO_LOADER" value="${dojoLoader}" /> |
| 560 | | </java> |
| 561 | | |
| 562 | | <script language="javascript"> |
| 563 | | <![CDATA[ |
| 564 | | var currentTask = dojo.getTargets().get("-set-profile-deps"); |
| 565 | | var files = dojo.getProperty("concatFilesProp"); |
| 566 | | dojo.setNewProperty("profileDeps", files); |
| 567 | | ]]> |
| 568 | | </script> |
| 569 | | </target> |
| 570 | | <!-- end -set-profile-deps task --> |
| 571 | | |
| 572 | | <!-- list-profile-deps task --> |
| 573 | | <target name="list-profile-deps" depends="-fix-config, -set-profile-deps" |
| 574 | | description="lists out the contents of the file dependencies"> |
| 575 | | <echo level="info" taskName="list-profile-deps">${profileDeps}</echo> |
| 576 | | </target> |
| 577 | | <!-- end list-profile-deps task --> |
| 578 | | |
| 579 | | <!-- list-profile-sizes task --> |
| 580 | | <target name="list-profile-sizes" depends="-fix-config, -set-profile-deps" |
| 581 | | description="lists out the contents of the file dependencies"> |
| 582 | | <script language="javascript"> |
| 583 | | <![CDATA[ |
| 584 | | function echo(msg){ |
| 585 | | var echo = dojo.createTask("echo"); |
| 586 | | echo.setMessage(msg); |
| 587 | | echo.setTaskName("list-profile-sizes"); |
| 588 | | echo.execute(); |
| 589 | | } |
| 590 | | |
| 591 | | var files = new String(dojo.getProperty("profileDeps")); |
| 592 | | var outparts = files.split("\n"); |
| 593 | | for(var x=0; x<outparts.length; x++){ |
| 594 | | if(outparts[x][outparts[x].length-1]==","){ |
| 595 | | outparts[x] = outparts[x].substring(0, outparts[x].length-1); |
| 596 | | } |
| 597 | | var flen = parseInt(new java.io.File(new java.lang.String(outparts[x])).length()); |
| 598 | | echo(((flen>=1024) ? parseInt(flen/1024)+"K" : flen+"B") +": \t"+ outparts[x]); |
| 599 | | } |
| 600 | | ]]></script> |
| 601 | | <!-- <echo>${profileDeps}</echo> --> |
| 602 | | </target> |
| 603 | | <!-- end list-profile-sizes task --> |
| 604 | | |
| 605 | | <!-- compress task --> |
| 606 | | <target name="compress" depends="-fix-config, list-profile-deps" |
| 607 | | description="runs compression code over release JS files"> |
| 608 | | <echo level="info" taskName="compress">profileFile: ${profileFile}</echo> |
| 609 | | |
| 610 | | <!-- Create the release dir if it doesn't exist. --> |
| 611 | | <mkdir dir="${release_dir}"/> |
| 612 | | <!-- write the list of files included to the release directory --> |
| 613 | | <echo file="${release_dir}/build.txt">Files baked into this package: |
| 614 | | |
| 615 | | ${profileDeps}</echo> |
| 616 | | |
| 617 | | <!-- now write 'em all to a single file --> |
| 618 | | <concat fixlastline="yes" eol="crlf" destfile="${release_dir}/source.__package__.js"> |
| 619 | | <!-- |
| 620 | | <concat fixlastline="yes" eol="crlf" destfile="${release_dir}/dojo.js"> |
| 621 | | --> |
| 622 | | <filelist |
| 623 | | dir="." |
| 624 | | files="${profileDeps}" /> |
| 625 | | </concat> |
| 626 | | |
| 627 | | <!-- remove UTF-8 BOM sequence |
| 628 | | <replaceregexp match="\u00ef\u00bb\u00bf" encoding="utf-8" |
| 629 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 630 | | <substitution expression="BOM!"/> |
| 631 | | </replaceregexp> |
| 632 | | --> |
| 633 | | |
| 634 | | <!-- |
| 635 | | clobber requireIf and requireAfterIf statements since they |
| 636 | | aren't applicable in build |
| 637 | | --> |
| 638 | | <replaceregexp match="dojo.requireIf\((.*?)\);" |
| 639 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 640 | | <substitution expression=""/> |
| 641 | | </replaceregexp> |
| 642 | | |
| 643 | | <replaceregexp match="dojo.requireAfterIf\((.*?)\);" |
| 644 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 645 | | <substitution expression=""/> |
| 646 | | </replaceregexp> |
| 647 | | |
| 648 | | <!-- Set the version number --> |
| 649 | | <script language="jython" taskName="compress"> |
| 650 | | <![CDATA[ |
| 651 | | import sys |
| 652 | | # make the python standard library avialable |
| 653 | | sys.path.append(project.resolveFile("lib/pyLib.zip").getPath()) |
| 654 | | sys.path.append(project.resolveFile(".").getPath()) |
| 655 | | |
| 656 | | # import re |
| 657 | | import os |
| 658 | | from buildUtil import * |
| 659 | | |
| 660 | | print "Setting version for Dojo to: " + dojo.getProperty("version") |
| 661 | | replaceVersion(project.resolveFile(dojo.getProperty("release_dir") + "/source.__package__.js").getPath(), dojo.getProperty("version")) |
| 662 | | print "Removing dojo.require calls in source.__package__.js." |
| 663 | | removeRequires(project.resolveFile(dojo.getProperty("release_dir") + "/source.__package__.js").getPath()) |
| 664 | | ]]> |
| 665 | | </script> |
| 666 | | |
| 667 | | <antcall target="-preload-resources"> |
| 668 | | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| 669 | | <param name="dstFile" value="${release_dir}/source.__package__.js" /> |
| 670 | | <param name="buildPrefix" value="dojo" /> |
| 671 | | </antcall> |
| 672 | | |
| 673 | | <!-- |
| 674 | | clobber requireLocalization statements. They need to be come no-ops since the resources |
| 675 | | are now prebuilt and also because we do not want dojo.js to trigger XHRs on load |
| 676 | | --> |
| 677 | | <replaceregexp match="dojo.requireLocalization\((.*?)\);" |
| 678 | | byline="true" flags="g" file="${release_dir}/source.__package__.js"> |
| 679 | | <substitution expression=""/> |
| 680 | | </replaceregexp> |
| 681 | | |
| 682 | | <antcall target="-rhino-compress"> |
| 683 | | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| 684 | | <param name="dstFile" value="${release_dir}/dojo.js" /> |
| 685 | | </antcall> |
| 686 | | |
| 687 | | <antcall target="-no-rhino-compress"> |
| 688 | | <param name="srcFile" value="${release_dir}/source.__package__.js" /> |
| 689 | | <param name="dstFile" value="${release_dir}/dojo.js" /> |
| 690 | | </antcall> |
| 691 | | |
| 692 | | <!-- add build notice --> |
| 693 | | <replaceregexp match="^" byline="false" replace="${build_notice}"> |
| 694 | | <fileset dir="${release_dir}" includes="dojo.js"/> |
| 695 | | </replaceregexp> |
| 696 | | |
| 697 | | <!-- add copyright notice --> |
| 698 | | <replaceregexp match="^" byline="false" replace="${copyright}"> |
| 699 | | <fileset dir="${release_dir}"> |
| 700 | | <include name="**/*.js" /> |
| 701 | | <include name="**/*.as" /> |
| 702 | | <not> |
| 703 | | <contains text="copyright" casesensitive="no" /> |
| 704 | | </not> |
| 705 | | </fileset> |
| 706 | | </replaceregexp> |
| 707 | | |
| 708 | | <delete file="${release_dir}/source.__package__.js"/> |
| 709 | | |
| 710 | | <!-- we copy over iframe_history.html here just in case this is a truly |
| 711 | | stand-alone build that isn't being kicked off via release --> |
| 712 | | <copy file="../iframe_history.html" todir="${release_dir}/" /> |
| 713 | | |
| 714 | | <!-- copy our dojo.storage and dojo.flash SWFs --> |
| 715 | | <copy todir="${release_dir}/" preservelastmodified="true"> |
| 716 | | <fileset dir="${root}/"> |
| 717 | | <include name="**/*.swf" /> |
| 718 | | <include name="*.jar" /> |
| 719 | | </fileset> |
| 720 | | </copy> |
| 721 | | |
| 722 | | </target> |
| 723 | | <!-- end compress task --> |
| 724 | | |
| 725 | | <target name="-rhino-compress" unless="nostrip"> |
| 726 | | <copy overwrite="true" file="${srcFile}" tofile="${dstFile}.uncompressed.js" /> |
| 727 | | <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true" |
| 728 | | logerror="true" output="${dstFile}"> |
| 729 | | <arg value="-strict" /> |
| 730 | | <arg value="-opt"/> |
| 731 | | <arg value="-1" /> |
| 732 | | <arg value="-c" /> |
| 733 | | <arg value="${srcFile}" /> |
| 734 | | </java> |
| 735 | | </target> |
| 736 | | |
| 737 | | <target name="-no-rhino-compress" |
| 738 | | if="nostrip"> |
| 739 | | <copy overwrite="true" file="${srcFile}" tofile="${dstFile}" /> |
| 740 | | </target> |
| 741 | | |
| 742 | | <target name="-flatten-resources" |
| 743 | | description="loads all localization bundles in the build for a particular locale, flattens the object, and outputs a preloaded version"> |
| 744 | | <!-- FIXME: should also remove dojo.requireLocalization() calls from the build? --> |
| 745 | | <copy overwrite="true" file="${srcFile}" tofile="${release_dir}/localizations.tmp.js"> |
| 746 | | <filterchain> |
| 747 | | <tokenfilter> |
| 748 | | <containsregex pattern="dojo\.requireLocalization\(.*\);"/> |
| 749 | | </tokenfilter> |
| 750 | | </filterchain> |
| 751 | | </copy> |
| 752 | | |
| 753 | | <!-- Hmm. have to repeat this work here even though it was done in -set-profile-deps. I guess script block changes |
| 754 | | 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 | |