bootstrap.xml
author Simon Howkins <simonh@symbian.org>
Wed, 14 Jul 2010 16:18:17 +0100
changeset 80 9fa808ef1682
parent 79 c60c76df3628
child 82 71371cd49800
permissions -rw-r--r--
Stopped bootstrap reporting that it will substitute a build drive, thereby scaring the living daylights out of innocent users, when it won't any way (because this is the bootstrap).

<?xml version="1.0" encoding="UTF-8"?>
<project name="SF-BOOTSTRAP" default="bootstrap" xmlns:hlm="http://www.nokia.com/helium">
  
  <property environment="env"/>
  
  <dirname property="sf.bootstrap.dir" file="${ant.file.SF-CONFIG}"/>
  
  <property name="build.drive" value="Setting this property stops helium reporting that it will use the Z: drive when it won't."/>
  <import file="${helium.dir}/helium.ant.xml" /> 
  
  <!-- target dir -->
  <property name="bootstrap.base.dir" value="D:\fbf_project"/> <!-- old name -->
  <property name="sf.target.dir" value="${bootstrap.base.dir}"/>
  
  <!-- config -->
  <property name="sf.config.repo" value=""/>
  <property name="sf.config.rev" value="default"/>
  <property name="sf.config.dir" value=""/>

  <!-- project -->
  <property name="sf.project.repo" value=""/>
  <property name="sf.project.rev" value="default"/>
  <property name="sf.project.dir" value=""/>

  <!-- Sanity check the supplied properties -->
  <fail message="Must specify property sf.config.repo or sf.config.dir">
    <condition>
      <and>
        <equals arg1="${sf.config.repo}" arg2=""/>
        <equals arg1="${sf.config.dir}" arg2=""/>
      </and>
    </condition>
  </fail>
  <fail message="Must specify property sf.project.repo or sf.project.dir">
    <condition>
      <and>
        <equals arg1="${sf.project.repo}" arg2=""/>
        <equals arg1="${sf.project.dir}" arg2=""/>
      </and>
    </condition>
  </fail>
  
  <target name="bootstrap" depends="init,get-sf-config,get-sf-project" description="Target for executing the bootstrap">
    <stopwatch name="bootstrap" action="elapsed"/>
  </target>

  <target name="init">
    <stopwatch name="bootstrap"/>

    <mkdir dir="${sf.target.dir}" />
    <mkdir dir="${sf.target.dir}/build" />

    <echo message="config: repo=${sf.config.repo} rev=${sf.config.rev}"/>
    <echo message="project: repo=${sf.project.repo} rev=${sf.project.rev}"/>
  </target>
  
  <target name="clean-env">
    <echo message="cleaning up the environment" />
    <delete dir="${sf.target.dir}/" />
  </target>

  <target name="get-sf-config">
    <antcall target="get-repo">
      <param name="stopwatch.name" value="get-sf-config"/>
      <param name="subdir.name" value="sf-config"/>
      <param name="repo.dir" value="${sf.config.dir}"/>
      <param name="repo.url" value="${sf.config.repo}"/>
      <param name="repo.rev" value="${sf.config.rev}"/>
    </antcall>
  </target>

  <target name="get-sf-project">
    <antcall target="get-repo">
      <param name="stopwatch.name" value="get-sf-project"/>
      <param name="subdir.name" value="build/config"/>
      <param name="repo.dir" value="${sf.project.dir}"/>
      <param name="repo.url" value="${sf.project.repo}"/>
      <param name="repo.rev" value="${sf.project.rev}"/>
    </antcall>
  </target>

  <target name="get-repo">
    <stopwatch name="${stopwatch.name}"/>
    <if>
      <not>
        <equals arg1="${repo.dir}" arg2=""/>
      </not>
      <then>
        <echo message="Getting FBF configuration from dir ${repo.dir}"/>
        <copy todir="${sf.target.dir}/${subdir.name}">
          <fileset dir="${repo.dir}"/>
        </copy>
      </then>
      <else>
        <echo message="Getting ${repo.url}"/>
        <if>
          <available file="${sf.target.dir}/${subdir.name}/.hg" type="dir"/>
          <then>
            <echo message="Updating ${sf.target.dir}/${subdir.name}"/>
            <exec executable="hg" dir="${sf.target.dir}/${subdir.name}">
              <arg value="pull"/>
              <arg value="${repo.url}"/>
            </exec>
            <exec executable="hg" dir="${sf.target.dir}/${subdir.name}">
              <arg value="up"/>
              <arg value="${repo.rev}"/>
              <arg value="-C"/>
            </exec>
          </then>
          <else>
            <echo message="Cloning ${repo.url}#${repo.rev} to ${sf.target.dir}/${subdir.name}"/>
            <trycatch>
              <try>
                <exec failonerror="true" executable="hg" dir="${sf.target.dir}">
                  <arg value="clone"/>
                  <arg value="-r${repo.rev}"/>
                  <arg value="${repo.url}"/>
                  <arg value="${subdir.name}"/>
                </exec>
              </try>
              <catch>
                <echo message="Clone failed, retry in 10 seconds"/>
                <sleep seconds="10"/>
                <delete dir="${sf.target.dir}/${subdir.name}" quiet="true"/>
                <echo message="Cloning ${repo.url}#${repo.rev} to ${sf.target.dir}/${subdir.name}"/>
                <trycatch>
                  <try>  
                    <exec failonerror="true" executable="hg" dir="${sf.target.dir}">
                      <arg value="clone"/>
                      <arg value="-r${repo.rev}"/>
                      <arg value="${repo.url}"/>
                      <arg value="${subdir.name}"/>
                    </exec>
                  </try>
                  <catch>
                    <echo message="Clone failed, retry in 10 seconds"/>
                    <sleep seconds="10"/>
                    <delete dir="${sf.target.dir}/${subdir.name}" quiet="true"/>
                    <echo message="Cloning ${repo.url}#${repo.rev} to ${sf.target.dir}/${subdir.name}"/>
                    <exec failonerror="true" executable="hg" dir="${sf.target.dir}">
                      <arg value="clone"/>
                      <arg value="-r${repo.rev}"/>
                      <arg value="${repo.url}"/>
                      <arg value="${subdir.name}"/>
                    </exec>
                  </catch>
                </trycatch>
              </catch>
            </trycatch>
          </else>
        </if>
      </else>
    </if>
    <stopwatch name="${stopwatch.name}" action="elapsed"/>
  </target>

</project>