optim_to_opale.ant 6.75 KB
Newer Older
Jean-Baptiste Martin's avatar
Jean-Baptiste Martin committed
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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="myantce" default="main">
    <property name="in" location="${basedir}/input"/>
    <property name="out" location="${basedir}/output"/>
    <property name="tmp" location="${basedir}/tmp"/>
    <property name="xsl" location="${basedir}/xsl"/>
    <property name="lib" location="${basedir}/lib"/>
    <property name="log" location="${basedir}/log"/>
    <property name="optim_to_hdoc" location="${basedir}/../optim_to_hdoc"/>
    <property name="hdoc_to_opale" location="${basedir}/../hdoc_to_opale"/>
    <property name="optim_to_hdoc_in" location="${optim_to_hdoc}/input"/>
    <property name="hdoc_to_opale_in" location="${hdoc_to_opale}/input"/>
    <property name="optim_to_hdoc_out" location="${optim_to_hdoc}/output"/>
    <property name="hdoc_to_opale_out" location="${hdoc_to_opale}/output"/>
    <property name="optim_to_hdoc_ant" location="${optim_to_hdoc}/optim_to_hdoc.ant"/>
    
    <!-- Mandatory ressource to use if conditions -->
    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <fileset dir="${lib}"/>
        </classpath>
    </taskdef>
    
    
    <!-- CHECK FOR FAMILY OS -->
    <condition property="is_windows">
        <os family="windows"/>
    </condition>
    <condition property="is_unix">
        <os family="unix"/>
    </condition>
    
    
    <!-- Main target -->
    <target name="main">
        <antcall target="clean"/>
        
        
        
        <!-- Check that the input directory is not empty -->
        <if>
            <length length="0" when="greater">
                <fileset dir="${in}" followsymlinks="false"/>
            </length>
            <then>
                <!-- input Dir Not Empty -->
                <antcall target="add_log">
                    <param name="msg" value="input directory is not empty"/>
                </antcall>
                
                <antcall target="prepare_optim_to_hdoc"/>
                <antcall target="run_optim_to_hdoc"/>
                
                <antcall target="prepare_hdoc_to_opale"/>
                <antcall target="run_hdoc_to_opale"/>
                <antcall target="output_files"/>
            </then>
            
            <else>
                <!-- input Dir Empty -->
                <antcall target="add_log">
                    <param name="msg" value="input directory is empty"/>
                </antcall>
            </else>
        </if>
    </target>
    


<!-- optim_to_hdoc -->
    
    <!-- Moves files in optim_to_hdoc hierarchy -->
    <target name="prepare_optim_to_hdoc">
        <antcall target="add_log">
            <param name="msg" value="Copying input files into optim_to_hdoc input directory"/>
        </antcall>
        
        <copy todir="${optim_to_hdoc_in}">
            <fileset dir="${in}">
                <include name="*.scar"/>
            </fileset>
        </copy>
    </target>
    
    <!-- Simply run optim_to_hdoc script -->
    <target name="run_optim_to_hdoc">
        <antcall target="run_optim_to_hdoc_unix"/>
        <antcall target="run_optim_to_hdoc_windows"/>
    </target>
    
    <!-- Run optim_to_hdoc bat -->
    <target name="run_optim_to_hdoc_windows" if="${is_windows}">
        <antcall target="add_log">
            <param name="msg" value="Running optim_to_hdoc bat script"/>
        </antcall>
        <exec executable="cmd" dir="${optim_to_hdoc}">
            <arg value="/c"/>
            <arg value="${optim_to_hdoc}/run.bat"/>
        </exec>
    </target>
    
    <!-- Run optim_to_hdoc sh -->
    <target name="run_optim_to_hdoc_unix" if="${is_unix}">
        <antcall target="add_log">
            <param name="msg" value="Running optim_to_hdoc shell script"/>
        </antcall>
        <exec executable="/bin/bash" dir="${optim_to_hdoc}">
            <arg value="${optim_to_hdoc}/run.sh"/>
        </exec>
    </target>
    
    
    
    
    
    
<!-- hdoc_to_opale -->
    
    <!-- Moves files in hdoc_to_opale hierarchy -->
    <target name="prepare_hdoc_to_opale">
        <antcall target="add_log">
            <param name="msg" value="Copying optim_to_hdoc output files into hdoc_to_opale input directory"/>
        </antcall>
        
        <copy todir="${hdoc_to_opale_in}">
            <fileset dir="${optim_to_hdoc_out}">
                <include name="*.hdoc"/>
            </fileset>
        </copy>
    </target>
    
    <!-- Simply run hdoc_to_opale script -->
    <target name="run_hdoc_to_opale">
        <antcall target="run_hdoc_to_opale_unix"/>
        <antcall target="run_hdoc_to_opale_windows"/>
    </target>
    
    <!-- Run hdoc_to_opale bat -->
    <target name="run_hdoc_to_opale_windows" if="${is_windows}">
        <antcall target="add_log">
            <param name="msg" value="Running hdoc_to_opale bat script"/>
        </antcall>
        
        <exec executable="cmd" dir="${hdoc_to_opale}">
            <arg value="/c"/>
            <arg value="${hdoc_to_opale}/run.bat"/>
        </exec>
    </target>
    
    <!-- Run hdoc_to_opale sh -->
    <target name="run_hdoc_to_opale_unix" if="${is_unix}">
        <antcall target="add_log">
            <param name="msg" value="Running hdoc_to_opale shell script"/>
        </antcall>
        
        <exec executable="/bin/bash" dir="${hdoc_to_opale}">
            <arg value="${hdoc_to_opale}/run.sh"/>
        </exec>
    </target>
    
    <!-- Move files to the outut directory -->
    <target name="output_files">
        <antcall target="add_log">
            <param name="msg" value="Copying hdoc_to_opale output files into optim_to_opale output directory"/>
        </antcall>
        
        <copy todir="${out}">
            <fileset dir="${hdoc_to_opale_out}"/>
        </copy>
    </target>
    
    
    
    
    
 <!-- Some basic functions -->
    
    <!-- Print a line both on screen and in log/execution.log file -->
    <target name="add_log">
        <tstamp>
            <format property="now" pattern="HH:mm:ss:sss" locale="fr,FR"/>
        </tstamp>
       
        <echo message="[${now}] ${msg}&#xa;" file="${log}/execution.log" append="true"/>
        <echo message="${msg}"/>
    </target>
    
    <!-- Cleaning directories -->
    <target name="clean">
        <delete dir="${log}" failonerror="false"/>
        <mkdir dir="${log}"/>
        
        <antcall target="add_log">
            <param name="msg" value="Cleaning directories"/>
        </antcall>
        
        <delete dir="${tmp}" failonerror="false"/>
        <mkdir dir="${tmp}"/>
        <delete dir="${out}" failonerror="false"/>
        <mkdir dir="${out}"/>
Jean-Baptiste Martin's avatar
Jean-Baptiste Martin committed
201 202 203 204 205
        
        <delete dir="${optim_to_hdoc_in}" failonerror="false"/>
        <mkdir dir="${optim_to_hdoc_in}"/>
        <delete dir="${hdoc_to_opale_in}" failonerror="false"/>
        <mkdir dir="${hdoc_to_opale_in}"/>
Jean-Baptiste Martin's avatar
Jean-Baptiste Martin committed
206 207 208
    </target>
    
</project>