-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_algorithm.xml
More file actions
193 lines (165 loc) · 8.75 KB
/
Copy pathbuild_algorithm.xml
File metadata and controls
193 lines (165 loc) · 8.75 KB
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
<project name="build_algorithm" default="test">
<!--abstract tasks for algorithm, to be imported in algorithm build.xml-->
<property name="funz.properties" location="../funz-profile/funz.properties" />
<property file="${funz.properties}" />
<!-- verify that the ${funz.properties} file has been set -->
<fail message="Set the funz properties file ${funz.properties} from funz-profile">
<condition>
<not>
<and>
<available file="${funz.properties}" type="file" />
</and>
</not>
</condition>
</fail>
<property name="funz.release" value="v${core.version}" />
<echo message="********************************" />
<echo message=" Funz ${funz.release} ${algorithm.name} algorithm" />
<echo message="********************************" />
<property name="algorithm.properties" location="../funz-profile/algorithm.properties" />
<property file="${algorithm.properties}" />
<!-- verify that the ${algorithm.properties} file has been set -->
<fail message="Set the algorithm properties file ${algorithm.properties} from funz-profile">
<condition>
<not>
<and>
<available file="${algorithm.properties}" type="file" />
</and>
</not>
</condition>
</fail>
<path id="antcontrib.classpath">
<pathelement location="../funz-profile/lib/ant-contrib-0.6.jar" />
</path>
<taskdef name="for" taskname="for" classname="net.sf.antcontrib.logic.For" classpathref="antcontrib.classpath" />
<taskdef name="if" taskname="if" classname="net.sf.antcontrib.logic.IfTask" classpathref="antcontrib.classpath" />
<taskdef name="propertycopy" taskname="propertycopy" classname="net.sf.antcontrib.property.PropertyCopy" classpathref="antcontrib.classpath" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="antcontrib.classpath" />
<!-- get empty Funz (given version) -->
<import file="../funz-profile/proxy_conf.xml"/> <!-- fill with your conf if needed -->
<property name="funz-calculator.install.src" value="https://github.com/Funz/funz-calculator/releases/download/${funz.release}"/>
<property name="funz-client.install.src" value="https://github.com/Funz/funz-client/releases/download/${funz.release}"/>
<property name="plugin-R.install.src" value="https://github.com/Funz/plugin-R/releases/download/${funz.release}-0"/>
<target name="get-funzR" depends="proxy">
<if>
<available file="funz-calculator.zip" type="file" />
<then></then>
<else>
<get src="${funz-calculator.install.src}/funz-calculator.zip" dest="funz-calculator.zip"/>
</else>
</if>
<unzip src="funz-calculator.zip" dest="${funz.dir}" overwrite="true"/>
<if>
<available file="funz-client.zip" type="file" />
<then></then>
<else>
<get src="${funz-client.install.src}/funz-client.zip" dest="funz-client.zip"/>
</else>
</if>
<unzip src="funz-client.zip" dest="${funz.dir}" overwrite="true"/>
<chmod dir="${funz.dir}" perm="ugo+rx" includes="**/*.sh"/>
<chmod dir="${funz.dir}" perm="ugo+rx" includes="**/*.bat"/>
<if>
<available file="plugin-R.zip" type="file" />
<then></then>
<else>
<get src="${plugin-R.install.src}/plugin-R.zip" dest="plugin-R.zip"/>
</else>
</if>
<unzip src="plugin-R.zip" dest="${funz.dir}" overwrite="true"/>
<if><os family="unix"/><then>
<replace file="${funz.dir}/calculator.xml" token="/CALCULATOR" value="CODE name='R' command='./scripts/R.sh' /> </CALCULATOR" />
</then><else>
<replace file="${funz.dir}/calculator.xml" token="/CALCULATOR" value="CODE name='R' command='.\scripts\R.bat' /> </CALCULATOR" />
</else></if>
</target>
<!-- clean: remove all generated files -->
<target name="clean" description="clean up">
<delete dir="${dist.dir}" failonerror="false" />
<delete dir="${funz.dir}" failonerror="false" />
<delete dir="${install.dir}" />
</target>
<!-- copy resources in dist dir -->
<target name="libs">
<mkdir dir="${dist.lib.dir}" />
<copy todir="${dist.lib.dir}" failonerror="false">
<fileset dir="${lib.dir}">
<include name="*" />
<exclude name="Funz*" />
</fileset>
</copy>
</target>
<!-- dist: copy the algorithm files -->
<target name="dist-algorithm" depends="libs, get-funzR">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.doe.dir}" />
<copy todir="${dist.doe.dir}">
<fileset file="${doe.dir}/*" />
</copy>
</target>
<!-- install a copy of funz and a copy of the algorithm. Needed for test or (full) pack-->
<target name="install" depends="get-funzR, dist">
<copy todir="${install.dir}" includeemptydirs="yes">
<fileset dir="${funz.dir}" />
</copy>
<copy todir="${install.dir}" includeemptydirs="yes" overwrite="true">
<fileset dir="${dist.dir}" />
</copy>
<chmod dir="${install.dir}" perm="ugo+rx" includes="**/*.sh"/>
<chmod dir="${install.dir}" perm="ugo+rx" includes="**/*.bat"/>
</target>
<!-- launch tests for ascii algorithm -->
<target name="test-algorithm" >
<!-- convert C:\Users\... in C:/Users/... -->
<script language="javascript">
var before = project.getProperty("doe.dir");
project.setProperty("doe.dir.R", before.replaceAll("\\\\", "/"));
var before = project.getProperty("test.cases.dir");
project.setProperty("test.cases.dir.R", before.replaceAll("\\\\", "/"));
</script>
<fileset id="tests" dir="${test.cases.dir}" includes="*"/>
<pathconvert pathsep="${line.separator}" property="tests.list" refid="tests">
<map from="${test.cases.dir}/" to=""/>
</pathconvert>
<for list="${tests.list}" param="test.name" delimiter="${line.separator}">
<sequential>
<echo message="========================================="/>
<echo message="============= @{test.name} ============="/>
<echo message="========================================="/>
<record name="@{test.name}.log" action="start" />
<if><os family="unix"/><then>
<exec executable="/bin/bash" failonerror="false" resultproperty="@{test.name}.failed">
<arg value="R"/>
<arg value="-e"/>
<arg value="if (file.exists('.Rprofile')) source('.Rprofile'); if (!('templr' %in% installed.packages())) install.packages('templr'); source('../funz-profile/lib/report.R'); source('${test.cases.dir.R}/@{test.name}'); test('${doe.dir.R}/${algorithm.name}.R')"/>
</exec>
</then><else>
<exec executable="cmd.exe" failonerror="false" resultproperty="@{test.name}.failed">
<arg value="/c"/>
<arg value="R"/>
<arg value="-e"/>
<arg value="if (file.exists('.Rprofile')) source('.Rprofile'); if (!('templr' %in% installed.packages())) install.packages('templr'); source('../funz-profile/lib/report.R'); source('${test.cases.dir.R}/@{test.name}'); test('${doe.dir.R}/${algorithm.name}.R')"/>
</exec>
</else></if>
<record name="@{test.name}.log" action="stop"/>
<if>
<equals arg1="${@{test.name}.failed}" arg2="0" />
<then>
</then>
<else>
<property name="failed" value="1" />
</else>
</if>
</sequential>
</for>
<fail message="Test failure detected, check test results." if="failed" />
</target>
<!-- help -->
<target name="help" description="display the help on standard output">
<echo message="help : display this help" />
<echo message="clean : clean build, dist and temp directories" />
<echo message="dist : generate the distribution of the algorithm" />
<echo message="install : build working Funz (R plugin included) with this algorithm" />
<echo message="test : launch the algorithm's tests" />
</target>
</project>