Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 32004214af6afd8ae172c8d0646451f5ef3327f2 (plain) (blame)
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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?xml version="1.0"?>
<!--
	Ant makefile for building and running of tests.
	This includes invocation of the Java code generator and conversion of the etunit
	results into xunit xml.
	
	To work locally you should define in your environment
	ETRICE_TARGET_PLATFORM=path to the eclipse folder of your Juno installation
	ETRICE_C_RUNTIME=path to the org.eclipse.etrice.runtime.c folder (relative path doesn't work)
	
	@author Henrik Rentz-Reichert
-->
<project name="project" default="all">
	
	<property name="c.tests.model.path" value="./models"/>
	<property name="modellib.path" value="../../runtime/org.eclipse.etrice.modellib.c"/>
	<property name="runtime.path" value="../../runtime/org.eclipse.etrice.runtime.c"/>
	<property name="bin.path" value="./bin"/>
	<property name="xml.output" value="./tmp"/>
	<property name="output" value="./output"/>
	<property environment="env"/>

	
	<!--
		all: copies the models, generates, compiles, runs, converts and copies the results
	-->
	<target name="all" depends="convert,copy_results">
		<echo>done with org.eclipse.etrice.generator.c.tests</echo>
	</target>

	<!--
		set_tp: get the target.platform property from the environment var ETRICE_TARGET_PLATFORM if not set already
	-->
	<target name="set_tp" unless="target.platform">
		<echo>using local target platform</echo>
		<property name="target.platform" value="${env.ETRICE_TARGET_PLATFORM}"/>
	</target>

	<!--
		set_tr: sets the test.result property if not set already
	-->
	<target name="set_tr" unless="test.results">
		<echo>using local test result folder</echo>
		<property name="test.results" value="./results"/>
	</target>

	<!--
		set_rp: sets the runtime.path from the ETRICE_C_RUNTIME environment variable property if not set already
	-->
	<target name="set_rp" unless="c-runtime.path">
		<echo>using local runtime folder</echo>
		<property name="c-runtime.path" value="${env.ETRICE_C_RUNTIME}"/>
	</target>
	
	<!--
		clean: deletes all folders created by this script
	-->
	<target name="clean" depends="set_tr,set_rp">
		<delete dir="${bin.path}"/>
		<delete dir="${c-runtime.path}/bin"/>
		<delete dir="models"/>
		<delete dir="${output}"/>
		<delete dir="${test.results}"/>
		<delete dir="src-gen"/>
		<delete dir="tmp"/>
	</target>
	
	<!--
		copy_models: copies the models from their original folders to the build location
	-->
	<target name="copy_models">
		<copy todir="models" >
			<fileset dir="../org.eclipse.etrice.generator.common.tests/models">
				<include name="*.room"/>
				<include name="*.config"/>
			</fileset>
			<fileset dir="${modellib.path}/model">
				<include name="TimingService.room"/>
				<include name="Types.room"/>
				<include name="Language.room"/>
			</fileset>
		</copy>
		<move file="models/StaticConfigTest_C.room" toFile="models/StaticConfigTest.room"/>
	</target>
	
	<!--
		generate: invokes the Java generator for the ROOM models
	-->
	<target name="generate" depends="set_tp,copy_models">
		<mkdir dir="${output}"/>
		<path id="clspath">
			<pathelement location="../../plugins/org.eclipse.etrice.generator.c/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.generator.doc/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.generator/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.generator.config/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.room/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.etphys/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.etmap/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.config/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.genmodel/bin"/>
			<fileset dir="${target.platform}/plugins/">
				<include name="org.eclipse.emf.ecore_2.8*.jar" />
				<include name="org.eclipse.emf.common_2.8*.jar" />
				<include name="org.eclipse.emf.ecore.xmi_2.8*.jar" />
				<include name="org.eclipse.xtext_2.*.jar" />
				<include name="com.google.inject_*.jar" />
				<include name="com.google.guava_10.*.jar" />
				<include name="org.eclipse.equinox.common_3.6.*.jar" />
				<include name="org.eclipse.xtext.util_2.*.jar" />
				<include name="org.eclipse.xtend.lib_2.*.jar" />
				<include name="org.eclipse.xtext.xbase.lib_2.*.jar" />
				<include name="org.apache.log4j_1.2*.jar" />
				<include name="org.antlr.runtime_3.2*.jar" />
				<include name="javax.inject_1.0*.jar" />
			</fileset>
		</path>

		<java output="${output}/generate.txt" classname="org.eclipse.etrice.generator.c.Main" fork="true" failonerror="true">
			<arg value="${c.tests.model.path}/ChoicePointTest.room"/>
			<arg value="${c.tests.model.path}/HandlerTest.room"/>
			<arg value="${c.tests.model.path}/SendingDataTestC.room"/>
			<arg value="${c.tests.model.path}/StaticConfigTest.room"/>
			<arg value="${c.tests.model.path}/StaticConfigTest.config"/>
			
			<!-- modelib.c -->
			<!-- not needed yet
				<arg value="${modellib.path}/model/TimingService.room"/>
			-->
			<arg value="${modellib.path}/model/Types.room"/>
			<classpath refid="clspath"/>
		</java>
	</target>
	
	<!--
		compile_runtime: compiles the C runtime library
	-->
	<target name="compile_runtime" depends="clean,set_rp">
		<mkdir dir="${c-runtime.path}/bin"/>
		<mkdir dir="${output}"/>
		<exec dir="${c-runtime.path}/bin" executable="gcc" failonerror="true" output="${output}/compile_runtime.txt">
			<arg value="-I${c-runtime.path}/src/common"/>
			<arg value="-I${c-runtime.path}/src/config"/>
			<arg value="-I${c-runtime.path}/src/platforms/generic"/>
			<arg value="-c"/>
			<arg value="-g3"/>
			<arg value="-O0"/>
			<arg value="-Wall"/>
			<arg value="../src/common/debugging/etMSCLogger.c"/>
			<arg value="../src/common/etUnit/etUnit.c"/>
			<arg value="../src/common/messaging/etMessage.c"/>
			<arg value="../src/common/messaging/etMessageQueue.c"/>
			<arg value="../src/common/messaging/etMessageService.c"/>
			<arg value="../src/common/modelbase/etActor.c"/>
			<arg value="../src/common/modelbase/etPort.c"/>
			<arg value="../src/platforms/generic/etLogger.c"/>
			<arg value="../src/platforms/generic/etPlatform.c"/>
			<arg value="../src/platforms/generic/etTimer.c"/>
		</exec>
		<exec dir="${c-runtime.path}/bin" executable="ar" failonerror="true" output="${output}/compile_runtime.txt" append="true">
			<arg value="-r"/>
			<arg value="liborg.eclipse.etrice.runtime.c.a"/>
			<arg value="etMSCLogger.o"/>
			<arg value="etUnit.o"/>
			<arg value="etMessage.o"/>
			<arg value="etMessageQueue.o"/>
			<arg value="etMessageService.o"/>
			<arg value="etActor.o"/>
			<arg value="etPort.o"/>
			<arg value="etLogger.o"/>
			<arg value="etPlatform.o"/>
			<arg value="etTimer.o"/>
		</exec>
	</target>
	
	<!--
		compile: compiles the generated C sources
	-->
	<target name="build" depends="set_rp,compile_runtime,generate">

		<!-- compile and link HandlerTest -->
		<mkdir dir="bin/HandlerTest"/>
		<exec dir="bin/HandlerTest" executable="gcc" failonerror="true" output="${output}/build.txt">
			<arg value="-I../../src-gen/ChoicePointTest"/>
			<arg value="-I../../src-gen/HandlerTest"/>
			<arg value="-I../../src-gen/SendingDataTestC"/>
			<arg value="-I../../src-gen/StaticConfigTest"/>
			<arg value="-I${c-runtime.path}/src/common"/>
			<arg value="-I${c-runtime.path}/src/config"/>
			<arg value="-I${c-runtime.path}/src/platforms/generic"/>
			<arg value="-c"/>
			<arg value="-g3"/>
			<arg value="-O0"/>
			<arg value="-Wall"/>
			<arg value="../../src-gen/HandlerTest/HandlerTest_Top.c"/>
			<arg value="../../src-gen/HandlerTest/HandlerUser.c"/>
			<arg value="../../src-gen/HandlerTest/SubSystem_HandlerTest.c"/>
			<arg value="../../src-gen/HandlerTest/SubSystem_HandlerTest_Runner.c"/>
			<arg value="../../src-gen/HandlerTest/Tester.c"/>
			<arg value="../../src-gen/HandlerTest/TestProtocol.c"/>
		</exec>
		<exec dir="bin/HandlerTest" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-L${c-runtime.path}/bin"/>
			<arg value="-oHandlerTest.exe"/>
			<arg value="HandlerTest_Top.o"/>
			<arg value="HandlerUser.o"/>
			<arg value="SubSystem_HandlerTest.o"/>
			<arg value="Tester.o"/>
			<arg value="TestProtocol.o"/>
			<arg value="SubSystem_HandlerTest_Runner.o"/>
			
			<!-- library has to be in the last position -->
			<arg value="-lorg.eclipse.etrice.runtime.c"/>
		</exec>
		
		<!-- compile and link ChoicepointTest -->
		<mkdir dir="bin/ChoicePointTest"/>
		<exec dir="bin/ChoicePointTest" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-I../../src-gen/ChoicePointTest"/>
			<arg value="-I../../src-gen/HandlerTest"/>
			<arg value="-I../../src-gen/SendingDataTestC"/>
			<arg value="-I../../src-gen/StaticConfigTest"/>
			<arg value="-I${c-runtime.path}/src/common"/>
			<arg value="-I${c-runtime.path}/src/config"/>
			<arg value="-I${c-runtime.path}/src/platforms/generic"/>
			<arg value="-c"/>
			<arg value="-g3"/>
			<arg value="-O0"/>
			<arg value="-Wall"/>
			<arg value="../../src-gen/ChoicePointTest/CPTest_Top.c"/>
			<arg value="../../src-gen/ChoicePointTest/CPTester.c"/>
			<arg value="../../src-gen/ChoicePointTest/CPUser.c"/>
			<arg value="../../src-gen/ChoicePointTest/SubSystem_CPTest.c"/>
			<arg value="../../src-gen/ChoicePointTest/SubSystem_CPTest_Runner.c"/>
			<arg value="../../src-gen/ChoicePointTest/TestProtocol.c"/>
		</exec>
		<exec dir="bin/ChoicePointTest" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-L${c-runtime.path}/bin"/>
			<arg value="-oChoicePointTest.exe"/>
			<arg value="CPTest_Top.o"/>
			<arg value="CPTester.o"/>
			<arg value="CPUser.o"/>
			<arg value="SubSystem_CPTest.o"/>
			<arg value="SubSystem_CPTest_Runner.o"/>
			<arg value="TestProtocol.o"/>
			
			<!-- library has to be in the last position -->
			<arg value="-lorg.eclipse.etrice.runtime.c"/>
		</exec>
		
		<!-- compile and link SendingDataTestC -->
		<mkdir dir="bin/SendingDataTestC"/>
		<exec dir="bin/SendingDataTestC" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-I../../src-gen/ChoicePointTest"/>
			<arg value="-I../../src-gen/HandlerTest"/>
			<arg value="-I../../src-gen/SendingDataTestC"/>
			<arg value="-I../../src-gen/StaticConfigTest"/>
			<arg value="-I${c-runtime.path}/src/common"/>
			<arg value="-I${c-runtime.path}/src/config"/>
			<arg value="-I${c-runtime.path}/src/platforms/generic"/>
			<arg value="-c"/>
			<arg value="-g3"/>
			<arg value="-O0"/>
			<arg value="-Wall"/>
			<arg value="../../src-gen/SendingDataTestC/MrPing.c"/>
			<arg value="../../src-gen/SendingDataTestC/MrPong.c"/>
			<arg value="../../src-gen/SendingDataTestC/PingPongData.c"/>
			<arg value="../../src-gen/SendingDataTestC/PingPongDataDeep.c"/>
			<arg value="../../src-gen/SendingDataTestC/PingPongDataDerived.c"/>
			<arg value="../../src-gen/SendingDataTestC/PingPongProtocol.c"/>
			<arg value="../../src-gen/SendingDataTestC/SendingDataTop.c"/>
			<arg value="../../src-gen/SendingDataTestC/SubSys_SendingData.c"/>
			<arg value="../../src-gen/SendingDataTestC/SubSys_SendingData_Runner.c"/>
		</exec>
		<exec dir="bin/SendingDataTestC" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-L${c-runtime.path}/bin"/>
			<arg value="-oSendingDataTestC.exe"/>
			<arg value="MrPing.o"/>
			<arg value="MrPong.o"/>
			<arg value="PingPongData.o"/>
			<arg value="PingPongDataDeep.o"/>
			<arg value="PingPongDataDerived.o"/>
			<arg value="PingPongProtocol.o"/>
			<arg value="SendingDataTop.o"/>
			<arg value="SubSys_SendingData.o"/>
			<arg value="SubSys_SendingData_Runner.o"/>
			
			<!-- library has to be in the last position -->
			<arg value="-lorg.eclipse.etrice.runtime.c"/>
		</exec>
		
		<!-- compile and link StaticConfigTest-->
		<mkdir dir="bin/StaticConfigTest"/>
		<exec dir="bin/StaticConfigTest" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-I../../src-gen/ChoicePointTest"/>
			<arg value="-I../../src-gen/HandlerTest"/>
			<arg value="-I../../src-gen/SendingDataTestC"/>
			<arg value="-I../../src-gen/StaticConfigTest"/>
			<arg value="-I${c-runtime.path}/src/common"/>
			<arg value="-I${c-runtime.path}/src/config"/>
			<arg value="-I${c-runtime.path}/src/platforms/generic"/>
			<arg value="-c"/>
			<arg value="-g3"/>
			<arg value="-O0"/>
			<arg value="-Wall"/>
			<arg value="../../src-gen/StaticConfigTest/Tester_ac.c"/>
			<arg value="../../src-gen/StaticConfigTest/Testee_1_ac.c"/>
			<arg value="../../src-gen/StaticConfigTest/Testee_2_ac.c"/>
			<arg value="../../src-gen/StaticConfigTest/Testee_Super2_ac.c"/>
			<arg value="../../src-gen/StaticConfigTest/Data_1_dc.c"/>
			<arg value="../../src-gen/StaticConfigTest/Data_Super1_dc.c"/>
			<arg value="../../src-gen/StaticConfigTest/Data_2_dc.c"/>
			<arg value="../../src-gen/StaticConfigTest/Data_3_dc.c"/>
			<arg value="../../src-gen/StaticConfigTest/TestProtocolAttributes.c"/>
			<arg value="../../src-gen/StaticConfigTest/TestProtocolWithDataClass.c"/>
			<arg value="../../src-gen/StaticConfigTest/Top_ac.c"/>
			<arg value="../../src-gen/StaticConfigTest/SubSystem_StaticConfigTest.c"/>
			<arg value="../../src-gen/StaticConfigTest/SubSystem_StaticConfigTest_Runner.c"/>
		</exec>
		<exec dir="bin/StaticConfigTest" executable="gcc" failonerror="true" output="${output}/build.txt" append="true">
			<arg value="-L../../../../runtime/org.eclipse.etrice.runtime.c/bin"/>
			<arg value="-oStaticConfigTest.exe"/>
			<arg value="Tester_ac.o"/>
			<arg value="Testee_1_ac.o"/>
			<arg value="Testee_2_ac.o"/>
			<arg value="Testee_Super2_ac.o"/>
			<arg value="Data_1_dc.o"/>
			<arg value="Data_Super1_dc.o"/>
			<arg value="Data_2_dc.o"/>
			<arg value="Data_3_dc.o"/>
			<arg value="TestProtocolAttributes.o"/>
			<arg value="TestProtocolWithDataClass.o"/>
			<arg value="Top_ac.o"/>
			<arg value="SubSystem_StaticConfigTest.o"/>
			<arg value="SubSystem_StaticConfigTest_Runner.o"/>
			
			<!-- library has to be in the last position -->
			<arg value="-lorg.eclipse.etrice.runtime.c"/>
		</exec>
	</target>

	<!--
		run: runs all executables
	-->
	<target name="run" depends="build">
		<mkdir dir="tmp/log"/>
		<echo>start HandlerTest</echo>
		<exec dir="./" resolveexecutable="true" executable="./bin/HandlerTest/HandlerTest.exe"/>
		<echo>end   HandlerTest</echo>
		<echo>start ChoicePointTest</echo>
		<exec dir="./" resolveexecutable="true" executable="./bin/ChoicePointTest/ChoicePointTest.exe"/>
		<echo>end   ChoicePointTest</echo>
		<echo>start SendingDataTestJava</echo>
		<exec dir="./" resolveexecutable="true" executable="./bin/SendingDataTestC/SendingDataTestC.exe"/>
		<echo>end   SendingDataTestJava</echo>
		<echo>start StaticConfigTest</echo>
		<exec dir="./" resolveexecutable="true" executable="./bin/StaticConfigTest/StaticConfigTest.exe"/>
		<echo>end   StaticConfigTest</echo>
	</target>
	
	<!--
		convert: converts etu- into xunit xml-format
	-->
	<target name="convert" depends="run,set_tp">
		<path id="clspath">
			<pathelement location="../../plugins/org.eclipse.etrice.etunit.converter/bin"/>
			<fileset dir="${target.platform}/plugins/">
				<include name="org.eclipse.core.runtime_3.8*.jar" />
				<include name="org.eclipse.emf.ecore_2.8*.jar" />
				<include name="org.eclipse.emf.ecore.xmi_2.8*.jar" />
				<include name="org.eclipse.emf.common_2.8*.jar" />
			</fileset>
		</path>

		<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
			<arg value="-suite"/>
			<arg value="org.eclipse.etrice.generator.c.tests.ChoicePointTest"/>
			<arg value="./tmp/ChoicePointTest.etu"/>
			<classpath refid="clspath"/>
		</java>

		<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
			<arg value="-suite"/>
			<arg value="org.eclipse.etrice.generator.c.tests.HandlerTest"/>
			<arg value="./tmp/HandlerTest.etu"/>
			<classpath refid="clspath"/>
		</java>

		<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
			<arg value="-suite"/>
			<arg value="org.eclipse.etrice.generator.c.tests.SendingDataTestC"/>
			<arg value="./tmp/SendingDataTestC.etu"/>
			<classpath refid="clspath"/>
		</java>
		
		<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
			<arg value="-suite"/>
			<arg value="org.eclipse.etrice.generator.c.tests.StaticConfigTest"/>
			<arg value="./tmp/StaticConfigTest.etu"/>
			<classpath refid="clspath"/>
		</java>
	</target>
	
	<!--
		copy_results: copies the *.xml results to their final destination
	-->
	<target name="copy_results" depends="set_tr">
		<move file="./tmp/HandlerTest.xml" tofile="./tmp/CHandlerTest.xml"/>
		<move file="./tmp/ChoicePointTest.xml" tofile="./tmp/CChoicePointTest.xml"/>
		<move file="./tmp/SendingDataTestC.xml" tofile="./tmp/CSendingDataTest.xml"/>
		<move file="./tmp/StaticConfigTest.xml" tofile="./tmp/StaticConfigTest.xml"/>
		<copy todir="${test.results}" >
			<fileset dir="./tmp">
				<include name="*.xml"/>
			</fileset>
		</copy>
	</target>
	
</project>

Back to the top