Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 07e2df06e0bb982cf6da39589609c83c797ca2fb (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
<?xml version="1.0"?>
<!--
	Ant makefile for building and running of tests.

	Includes common.xml from org.eclipse.etrice.generator.common.tests
-->
<project name="org.eclipse.etrice.generator.c.tests" basedir="." default="all">

	<target name="testing" depends="common.testing">

		<!-- add test here, testid==testSuiteFileName -->
		<test testid="StaticConfigTest" models="${models.path}/staticConfig/StaticConfigTest.etmap ${models.path}/staticConfig/StaticConfigTest.room ${models.path}/staticConfig/StaticConfigTest.config ${models.path}/TimingService.room" />

		<!-- fail on build server -->
		<!--<test testid="SendingDataTestC" models="${models.path}/sendingData/SendingDataTestC.room ${models.path}/GenericPhysical.etphys" />-->
		<echo>done with ${ant.project.name}</echo>
	</target>

	<target name="copyModels" depends="common.copyModels">
		<copy todir="${models.path}">
			<fileset dir="./targetModels"/>
		</copy>
		<move file="${models.path}/staticConfig/StaticConfigTest_C.room" toFile="${models.path}/staticConfig//StaticConfigTest.room" />
	</target>

	<!-- ################################################################ -->

	<import file="../org.eclipse.etrice.generator.common.tests/common.xml" as="common"/>

	<property name="modellib.path" value="../../runtime/org.eclipse.etrice.modellib.c" />
	<property name="runtime.path" value="../../runtime/org.eclipse.etrice.runtime.c" />

	<target name="set_local_rt" unless="runtime.platform">
		<!-- <property name="runtime.platform" value="MT_POSIX_GENERIC_GCC"/> -->
		<property name="runtime.platform" value="MT_WIN_MinGW"/>
		<echo>    runtime.platform = ${runtime.platform}        	</echo>
	</target>
	<target name="setVars" depends="set_local_rt,common.setVars"/>

	<target name="all" depends="clean,copyModels,testing"></target>

	<!-- test := generate 1 executable, build, run, process results -->
	<macrodef name="test">
		<attribute name="testId"/>
		<attribute name="models"/>
		<sequential>
			<standaloneGenerator testId="@{testId}" models="@{models}"/>
			<build testId="@{testId}"/>
			<run testId="@{testId}"/>
			<convert testId="@{testId}"/>
			<copyResult testId="@{testId}" targetId="C_${runtime.platform}_"/>
		</sequential>
	</macrodef>

	<macrodef name="standaloneGenerator">
		<attribute name="testId"/>
		<attribute name="models"/>
		<sequential>
			<mkdir dir="${output}"/>
			<java output="${output}/generate.txt" error="${output}/generate_err.txt" classname="org.eclipse.etrice.generator.c.Main" fork="true" failonerror="true">
				<arg line="@{models}"/>
				<arg value="-genDir"/><arg value="src-gen/@{testId}"/>
				<arg value="-msc_instr"/>
				<classpath refid="etrice.clspath"/>
			</java>
		</sequential>
	</macrodef>

	<!--
		build: compiles and links the generated C sources
	-->
	<macrodef name="build">
		<attribute name="testId"/>
		<sequential>
			<mkdir dir="${bin.path}"/>
			<mkdir dir="${output}"/>
			<exec executable="make" failonerror="true" output="${output}/build.txt">
				<arg line="all"/>
				<arg line="APP_TARGET=@{testId}.exe"/>
				<arg line="APP_BUILD_DIR=${bin.path}"/>
				<arg line="APP_SRCDIRS_REC='./src-gen/@{testId} ./src/@{testId}'"/>
				<arg line="RUNTIME_ROOTDIR=${runtime.path}"/>
				<arg line="MODELLIB_ROOTDIR=${modellib.path}"/>
				<arg line="TARGET_PLATFORM=${runtime.platform}"/>
			</exec>
		</sequential>
	</macrodef>

	<macrodef name="run">
		<attribute name="testId"/>
		<sequential>
			<mkdir dir="${output}"/>
			<mkdir dir="${testlog.path}"/>
			<exec dir="./" output="${output}/run.txt" resolveexecutable="true" executable="${bin.path}/@{testId}.exe" timeout="${run.msTimout}">
				<arg value="-run_as_test"/>
			</exec>
		</sequential>
	</macrodef>

</project>

Back to the top