Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e964f4d11dae09a6516675ac59739b42acb28aea (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
<?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">
	
	<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">
		<delete dir="${bin.path}"/>
		<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"/>
			</fileset>
			<fileset dir="${modellib.path}/model">
				<include name="TimingService.room"/>
				<include name="Types.room"/>
			</fileset>
		</copy>
	</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.core.genmodel/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.room/bin"/>
			<pathelement location="../../plugins/org.eclipse.etrice.core.config/bin"/>
			<fileset dir="${target.platform}/plugins/">
				<include name="org.eclipse.emf.ecore_2.8.0*.jar" />
				<include name="org.eclipse.emf.common_2.8.0*.jar" />
				<include name="org.eclipse.emf.ecore.xmi_2.8.0*.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.xtext.xtend2.lib_2.*.jar" />
				<include name="org.eclipse.xtext.xbase.lib_2.*.jar" />
				<include name="org.apache.log4j_1.2.15*.jar" />
				<include name="org.antlr.runtime_3.2.0*.jar" />
				<include name="javax.inject_1.0.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"/>
			<!-- 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="set_rp">
		<mkdir dir="${c-runtime.path}/bin"/>
		<exec dir="${c-runtime.path}/bin" executable="gcc">
			<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">
			<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">
			<arg value="-I../../src-gen/ChoicePointTest"/>
			<arg value="-I../src-gen/HandlerTest"/>
			<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">
			<arg value="-L../../../../runtime/org.eclipse.etrice.runtime.c/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">
			<arg value="-I../../src-gen/ChoicePointTest"/>
			<arg value="-I../../src-gen/HandlerTest"/>
			<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">
			<arg value="-L../../../../runtime/org.eclipse.etrice.runtime.c/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>
	</target>

	<!--
		run: runs all executables
	-->
	<target name="run" depends="build">
		<mkdir dir="tmp/log"/>
		<exec dir="./" resolveexecutable="true" executable="./bin/HandlerTest/HandlerTest.exe"/>
		<exec dir="./" resolveexecutable="true" executable="./bin/ChoicePointTest/ChoicePointTest.exe"/>
	</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.0*.jar" />
				<include name="org.eclipse.emf.ecore_2.8.0*.jar" />
				<include name="org.eclipse.emf.ecore.xmi_2.8.0*.jar" />
				<include name="org.eclipse.emf.common_2.8.0*.jar" />
			</fileset>
		</path>

		<java output="${output}/convert.txt" 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" 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>
	</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"/>
		<copy todir="${test.results}" >
			<fileset dir="./tmp">
				<include name="*.xml"/>
			</fileset>
		</copy>
	</target>
	
</project>

Back to the top