build.xml 9.41 KB
Newer Older
Qiang Xue committed
1 2 3
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
4
 * Phing build file for Yii 2.
Qiang Xue committed
5 6 7
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link http://www.yiiframework.com/
8
 * @copyright 2008 Yii Software LLC
Qiang Xue committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * @license http://www.yiiframework.com/license/
 */
-->
<project name="yii" basedir="." default="help">
  <!-- task definitions -->
  <taskdef name="yii-init-build" classname="YiiInitTask" classpath="tasks" />
  <!--
  <taskdef name="yii-pear" classname="YiiPearTask" classpath="tasks"/>
  -->

  <!-- init yii.version, yii.revision and yii.winbuild -->
  <yii-init-build />

  <!-- these are required external commands -->
  <property name="php" value="php" /> <!-- PHP parser -->
24
  <property name="composer" value="composer" /> <!-- composer -->
Qiang Xue committed
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
  <property name="pdflatex" value="pdflatex" />  <!-- generates PDF from LaTex -->

  <property name="pkgname" value="${phing.project.name}-${yii.version}.${yii.revision}"/>
  <property name="docname" value="${phing.project.name}-docs-${yii.version}.${yii.revision}"/>
  <property name="pearname" value="${phing.project.name}-${yii.release}.tgz" />

  <!-- directory definitions -->
  <property name="build.base.dir" value="release"/>
  <property name="build.dist.dir" value="${build.base.dir}/dist"/>
  <property name="build.src.dir" value="${build.base.dir}/${pkgname}"/>
  <property name="build.pear.src.dir" value="${build.src.dir}/framework" />
  <property name="build.doc.dir" value="${build.base.dir}/${docname}"/>
  <property name="build.web.dir" value="${build.base.dir}/web"/>

  <tstamp>
    <format property="DATE" pattern="%b %e %Y" />
  </tstamp>

  <if>
    <equals arg1="${yii.winbuild}" arg2="true"/>
    <then>
      <property name="build" value="build"/>
    </then>
    <else>
      <property name="build" value="php build"/>
    </else>
  </if>

  <!-- source files in the framework -->
  <fileset dir=".." id="framework">
    <exclude name="**/.gitignore"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="framework/**/*"/>
    <include name="requirements/**/*"/>
    <include name="demos/**/*"/>
    <include name="CHANGELOG"/>
    <include name="UPGRADE"/>
    <include name="LICENSE"/>
    <include name="README"/>
  </fileset>

  <!-- doc files -->
  <fileset dir="../docs" id="docs">
    <exclude name="**/.gitignore"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="guide/**/*"/>
    <include name="blog/**/*"/>
  </fileset>

  <fileset dir="../docs/guide" id="docs-guide">
    <exclude name="**/.gitignore"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="**/*"/>
  </fileset>

  <fileset dir="../docs/blog" id="docs-blog">
    <exclude name="**/.gitignore"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="**/*"/>
  </fileset>

  <fileset dir="." id="writables">
    <include name="${build.src.dir}/**/runtime" />
    <include name="${build.src.dir}/**/assets" />
    <include name="${build.src.dir}/demos/**/data" />
  </fileset>

  <fileset dir="." id="executables">
97
    <include name="${build.src.dir}/**/yii" />
Qiang Xue committed
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
  </fileset>

  <target name="src" depends="sync">
    <echo>Building package ${pkgname}...</echo>
    <echo>Copying files to build directory...</echo>
    <copy todir="${build.src.dir}">
      <fileset refid="framework"/>
    </copy>

    <echo>Changing file permissions...</echo>
    <chmod mode="0777">
      <fileset refid="writables" />
    </chmod>
    <chmod mode="0755">
      <fileset refid="executables" />
    </chmod>

    <echo>Generating source release file...</echo>
    <mkdir dir="${build.dist.dir}" />
    <if>
      <equals arg1="${yii.winbuild}" arg2="true"/>
      <then>
        <tar destfile="${build.dist.dir}/${pkgname}.tar.gz" compression="gzip">
          <fileset dir="${build.base.dir}">
            <include name="${pkgname}/**/*"/>
          </fileset>
        </tar>
      </then>
      <else>
        <exec command="tar czpf ${pkgname}.tar.gz ${pkgname}" dir="${build.base.dir}"/>
        <move file="${build.base.dir}/${pkgname}.tar.gz" todir="${build.dist.dir}" />
      </else>
    </if>
    <zip destfile="${build.dist.dir}/${pkgname}.zip">
      <fileset dir="${build.base.dir}">
        <include name="${pkgname}/**/*"/>
      </fileset>
    </zip>
  </target>

  <target name="doc" depends="sync">
    <echo>Building documentation...</echo>

    <echo>Building Guide PDF...</echo>
    <exec command="${build} guideLatex" dir="." passthru="true" />
    <exec command="${pdflatex} guide.tex -interaction=nonstopmode -max-print-line=120" dir="commands/guide" passthru="true"/>
    <exec command="${pdflatex} guide.tex -interaction=nonstopmode -max-print-line=120" dir="commands/guide" passthru="true"/>
    <exec command="${pdflatex} guide.tex -interaction=nonstopmode -max-print-line=120" dir="commands/guide" passthru="true"/>
    <move file="commands/guide/guide.pdf" tofile="${build.doc.dir}/yii-guide-${yii.version}.pdf" />

    <echo>Building Blog PDF...</echo>
    <exec command="${build} blogLatex" dir="." passthru="true" />
    <exec command="${pdflatex} blog.tex -interaction=nonstopmode -max-print-line=120" dir="commands/blog" passthru="true"/>
    <exec command="${pdflatex} blog.tex -interaction=nonstopmode -max-print-line=120" dir="commands/blog" passthru="true"/>
    <exec command="${pdflatex} blog.tex -interaction=nonstopmode -max-print-line=120" dir="commands/blog" passthru="true"/>
    <move file="commands/blog/blog.pdf" tofile="${build.doc.dir}/yii-blog-${yii.version}.pdf" />

    <echo>Building API...</echo>
    <exec command="${build} api ${build.doc.dir}" dir="." passthru="true" />

    <!--
    <echo>Building API CHM...</echo>
    <exec command="${hhc} ${build.doc.dir}/api/manual.hhp" />
    <move file="${build.doc.dir}/api/manual.chm" tofile="${build.doc.dir}/yii-api-${yii.version}.chm" />
    <delete>
      <fileset dir="${build.doc.dir}/api">
        <include name="manual.*" />
      </fileset>
    </delete>
    -->

    <echo>Generating doc release file...</echo>
    <mkdir dir="${build.dist.dir}" />
    <tar destfile="${build.dist.dir}/${docname}.tar.gz" compression="gzip">
      <fileset dir="${build.base.dir}">
        <include name="${docname}/**/*"/>
      </fileset>
    </tar>
    <zip destfile="${build.dist.dir}/${docname}.zip">
      <fileset dir="${build.base.dir}">
        <include name="${docname}/**/*"/>
      </fileset>
    </zip>
  </target>

  <target name="web" depends="sync">

    <echo>Building online API...</echo>
    <mkdir dir="${build.web.dir}/common/data/${yii.version}" />
    <exec command="${build} api ${build.web.dir}/common/data/${yii.version} online" dir="." passthru="true" />

    <echo>Copying tutorials...</echo>
    <copy todir="${build.web.dir}/common/data/${yii.version}/tutorials/guide">
      <fileset refid="docs-guide"/>
    </copy>
    <copy todir="${build.web.dir}/common/data/${yii.version}/tutorials/blog">
      <fileset refid="docs-blog"/>
    </copy>

	<echo>Copying release text files...</echo>
    <mkdir dir="${build.web.dir}/frontend/www/files" />
	<copy file="../CHANGELOG" tofile="${build.web.dir}/frontend/www/files/CHANGELOG-${yii.version}.txt" />
	<copy file="../UPGRADE" tofile="${build.web.dir}/frontend/www/files/UPGRADE-${yii.version}.txt" />

	<echo>

Finished building Web files.
Please update yiisite/common/data/versions.php file with the following code:

    '1.1'=>array(
        'version'=>'${yii.version}',
        'revision'=>'${yii.revision}',
        'date'=>'${yii.date}',
        'latest'=>true,
    ),

	</echo>
  </target>

  <target name="sync">
    <echo>Synchronizing code changes for ${pkgname}...</echo>

    <echo>Building autoload map...</echo>
    <exec command="${build} autoload" dir="." passthru="true"/>

    <echo>Building yiilite.php...</echo>
    <exec command="${build} lite" dir="." passthru="true"/>
  </target>

  <target name="message">
    <echo>Extracting i18n messages...</echo>
    <exec command="${build} message ../framework/messages/config.php" dir="." passthru="true"/>
  </target>

  <!--
  <target name="pear" depends="clean,build">
    <echo>Generating pear package for ${phing.project.name}-${yii.release}</echo>
    <mkdir dir="${build.dist.dir}" />
    <yii-pear   pkgdir="${build.pear.src.dir}"
                channel="pear.php.net"
                version="${yii.release}"
                state="stable"
                category="framework"
                package="${phing.project.name}"
                summary="Yii PHP Framework"
                pkgdescription="Yii PHP Framework: Best for Web 2.0 Development"
                notes="http://www.yiiframework.com/files/CHANGELOG-${yii.release}.txt"
                license="BSD"
                />
    <exec command="pear package" dir="${build.pear.src.dir}" passthru="true" />
    <move file="${build.pear.src.dir}/${pearname}" tofile="${build.dist.dir}/${pearname}" />
  </target>
  -->

  <target name="clean">
    <echo>Cleaning up the build...</echo>
    <delete dir="${build.base.dir}"/>
  </target>

  <target name="help">
    <echo>

    Welcome to use Yii build script!
    --------------------------------
    You may use the following command format to build a target:

              phing   &lt;target name&gt;

    where &lt;target name&gt; can be one of the following:

268
    - sync    : synchronize yiilite.php and BaseYii.php
Qiang Xue committed
269 270 271 272 273 274 275 276
    - message : extract i18n messages of the framework
    - src     : build source release
    - doc     : build documentation release (Windows only)
    - clean   : clean up the build

    </echo>
  </target>
</project>