Subversion Repositories DevTools

Rev

Rev 1762 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1748 mtynas 1
<project name="ant-cppcompile-task">
2
 
3
	<!-- 
4
 
5
		This macrodef is used to streamline and manage a common build framework.
6
 
7
		Many of the options listed below are documented within the cpptasks documentation.
8
	-->
9
 
10
	<macrodef name="cppcompile">
11
 
12
		<attribute	name="name"
13
					description="The logical name of the package to be built. Typically the ant.project.name"/>
14
 
15
		<attribute	name="version"
16
					description="The version of the package to be built. This may be the logical version rather than the released package version."/>
17
 
18
		<attribute	name="compiler"			
19
					description="The compiler to be used (bcpp, msvc, suncc). Requires the associated ant-???? package where ???? is the compiler."/>
20
 
21
		<attribute	name="targetname"		
22
					default="@{name}"
23
					description="Optional target package name, which may include some target based identity, if different from the project name. Default to package 'name'"/>
24
 
25
		<attribute	name="buildtype"			
26
					default="release"
27
					description="Optional type of build, whether 'debug' or 'release'. Defaults to 'release'"/>
28
 
29
		<attribute	name="compilerpath"		
30
					default="$${@{compiler}_bin}"
31
					description="Optional compiler path override. Normally defined within the ant-???? compiler package."/>
32
 
33
		<attribute	name="rtti"				
34
					default="true"
35
					description="Optional flag, used to enable Run-Time Type Information"/>
1760 crichaud 36
 
1764 crichaud 37
		<attribute	name="buildproperties"				
38
					default=""
39
					description="Optional flag, used to add 'database', or 'vcl' libraries when needed"/>
1760 crichaud 40
 
1748 mtynas 41
		<attribute	name="exceptions"		
42
					default="true"
43
					description="Optional flag, used to enable exception handling support. Defaults to true"/>
44
 
45
		<attribute	name="multithreaded"		
46
					default="true"
47
					description="Optional flag, used to enable multithreaded support. Defaults to true"/>
48
 
49
		<attribute	name="optimize"			
50
					default="speed"
51
					description="Optional flag, used to specify optimization. Defaults to 'speed', but is overridden to 'none' by debug buildtype."/>
52
 
53
		<attribute	name="outtype"			
54
					default="executable"
55
					description="Optional flag, used to indicate the type of package being built (static, shared, executable)"/>
56
 
57
		<attribute	name="subsystem"			
58
					default="console"
59
					description="Optional flag, used to indicate the nature of the subsystem under which the program will run. (gui, console, other)."/>
60
 
61
		<attribute	name="build" 
62
					default="${basedir}/build"
63
					description="The location of the project 'build' folder. Defaults to 'project basedir'/build. You do not normal need to provide this value."/>
64
 
65
		<attribute	name="objdir"			
66
					default="@{build}/obj"
67
					description="Optional value, used to nominate the build object directory base."/>
68
 
69
		<attribute	name="pkgdir"			
70
					default="@{build}/pkg"
71
					description="Optional value, used to nominate the build package directory."/>
72
 
73
		<element name="compiler-elements" optional="yes" implicit="yes" description="Any compiler specific parameters."/>
74
 
75
		<sequential>
76
			<echo taskname="ant-cppcompile-task">Compiling @{name} Version: @{version}</echo>
77
 
78
			<!-- Determine any compile type dependent flags
79
				 Including naming standards, optimizations, etc -->
80
			<if>
81
				<equals arg1="@{buildtype}" arg2="debug"/>
1764 crichaud 82
				<then>
83
					<property name="debug_build" value="true"/>
1748 mtynas 84
					<property name="@{name}@{compiler}@{buildtype}-compile_type_symbol" value="D"/>
85
					<property name="@{name}@{compiler}@{buildtype}-debug_flag" value="true"/>
86
					<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="none"/>
87
				</then>
1764 crichaud 88
				<else>
89
					<property name="release_build" value="true"/>
1748 mtynas 90
					<property name="@{name}@{compiler}@{buildtype}-compile_type_symbol" value="P"/>
91
					<property name="@{name}@{compiler}@{buildtype}-debug_flag" value="false"/>
92
					<if>
93
						<equals arg1="@{optimize}" arg2=""/>
94
						<then>
95
							<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="speed"/>
96
						</then>
97
						<else>
98
							<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="@{optimize}"/>
99
						</else>
100
					</if>
101
				</else>
102
			</if>
103
 
104
			<!-- Identify the compile platform extension -->
105
			<condition property="compile.platform" value="win32">
106
				<os family="windows"/>
107
			</condition>
108
 
109
			<condition property="compile.platform" value="win32">
110
				<os family="dos"/>
111
			</condition>
112
 
113
			<condition property="compile.platform" value="sparc">
114
				<os name="SunOS"/>
115
			</condition>
1760 crichaud 116
 
1748 mtynas 117
 
118
			<!-- Type of target => executable,plugin,shared,static -->
119
			<if>
120
				<equals arg1="@{outtype}" arg2="executable"/>
121
				<then>
1762 crichaud 122
					<property name="@{name}@{buildtype}--targetfolder" value="bin.${compile.platform}${@{name}@{compiler}@{buildtype}-compile_type_symbol}"/>
1760 crichaud 123
					<property name="@{name}@{compiler}@{outtype}@{buildtype}-output_name" value="@{targetname}"/>
1748 mtynas 124
				</then>
125
				<else>
1762 crichaud 126
					<property name="@{name}@{buildtype}--targetfolder" value="lib.${compile.platform}"/>
1760 crichaud 127
					<property name="@{name}@{compiler}@{outtype}@{buildtype}-output_name" value="@{targetname}@{version}${@{name}@{compiler}@{buildtype}-compile_type_symbol}"/>	
1748 mtynas 128
				</else>
129
			</if>
1758 crichaud 130
 
1760 crichaud 131
			<!-- Type of target => Linker Options for bcpp compiler according type executable,plugin,shared,static-->
132
 
133
			<if>
134
			<equals arg1="@{compiler}" arg2="bcpp"/>
135
			<then>
1764 crichaud 136
				<if><equals arg1="@{outtype}" arg2="executable"/>
1760 crichaud 137
					<then>
1764 crichaud 138
						<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>
1760 crichaud 139
					</then>
1764 crichaud 140
				<else>
141
					<if><equals arg1="@{outtype}" arg2="shared"/>
142
						<then>
143
							<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>	
144
						</then>
1760 crichaud 145
					<else>
1764 crichaud 146
						<if><equals arg1="@{outtype}" arg2="runtime-package"/>
147
							<then>
148
								<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>	
149
							</then>
150
						<else>
151
							<if><equals arg1="@{outtype}" arg2="designtime-package"/>
152
								<then>
153
									<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>	
154
								</then>
155
							<else>
156
								<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_none"/>
157
							</else>
158
							</if>
159
						</else>
160
						</if>
1760 crichaud 161
					</else>
1764 crichaud 162
					</if>
1760 crichaud 163
				</else>
164
				</if>
165
			</then>
166
			<else>
167
				<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>	
168
			</else>
169
			</if>
170
 
1764 crichaud 171
			<!-- libraries to add to the linker according the buildproperties attribute -->		
172
			<for list="@{buildproperties}" delimiter="," param="bproperties">
173
				<sequential>
174
					<echo>BUILD PROPERTIES @{bproperties}</echo>		
175
					<property name="@{compiler}_properties_@{bproperties}" value="true"/>	
176
				</sequential>
177
            		</for>
1758 crichaud 178
 
1748 mtynas 179
			<mkdir dir="${objdir}/@{buildtype}_@{compiler}"/>
180
			<mkdir dir="${objdir}/@{buildtype}_@{compiler}/@{targetname}"/>
181
			<mkdir dir="@{pkgdir}"/>
1762 crichaud 182
			<mkdir dir="@{pkgdir}/${@{name}@{buildtype}--targetfolder}"/>
1748 mtynas 183
 
1762 crichaud 184
			<echo taskname="ant-cppcompile-task">Compile @{name} into @{pkgdir}/${@{name}@{buildtype}--targetfolder}/${@{name}@{compiler}@{outtype}@{buildtype}-output_name}</echo>
1764 crichaud 185
			<echo taskname="ant-cppcompile-task">Using Compiler @{compiler} (${@{compiler}_compilername}) from @{compilerpath}</echo>
186
			<echo taskname="ant-cppcompile-task">Placing Objects in ${objdir}\@{buildtype}_@{compiler}\@{targetname}</echo>
1748 mtynas 187
			<echo taskname="ant-cppcompile-task">Use Compiler Includes from ${@{compiler}_include_@{buildtype}}</echo>
188
			<echo taskname="ant-cppcompile-task">Use Package Includes from @{pkgdir}/include</echo>
1764 crichaud 189
			<echo taskname="ant-cppcompile-task">Linking with Library ${@{compiler}_lib_@{buildtype}} Files: ${@{compiler}_libraries_@{buildtype}}</echo>
190
 
1758 crichaud 191
			<echo taskname="ant-cppcompile-task">Compiler @{compiler}_compiler_@{buildtype}_@{subsystem}</echo>
192
			<echo taskname="ant-cppcompile-task">Output File Name ${@{name}@{compiler}@{outtype}@{buildtype}-output_name}</echo>
193
 
1760 crichaud 194
			<echo taskname="ant-cppcompile-task">Include Path: ${@{compiler}_include_@{buildtype}}</echo>
195
 
1764 crichaud 196
 
197
			<if>
198
				<equals arg1="@{outtype}" arg2="static"/>
199
				<then>
200
  					<cc name="${@{compiler}_compilername}" 
201
						path="@{compilerpath}"
202
						rtti="@{rtti}"
203
						exceptions="@{exceptions}"
204
						multithreaded="@{multithreaded}"
205
						optimize="${@{name}@{compiler}@{buildtype}-compile_optimize}"
206
						debug="${@{name}@{compiler}@{buildtype}-debug_flag}" 
207
						outtype="@{outtype}" 
208
						subsystem="@{subsystem}" 
209
						outfile="@{pkgdir}\${@{name}@{buildtype}--targetfolder}\${@{name}@{compiler}@{outtype}@{buildtype}-output_name}"
210
						objdir="${objdir}\@{buildtype}_@{compiler}\@{targetname}">
211
 
212
						<compiler refid="@{compiler}_compiler_@{buildtype}_@{subsystem}"/>
213
 
214
						<includepath path="${@{compiler}_include_@{buildtype}}"/>
215
						<includepath path="@{pkgdir}\include"/>
216
 
217
						<compiler-elements/>
218
 
219
  					</cc>
220
				</then>
221
				<else>
222
  					<cc name="${@{compiler}_compilername}" 
223
						path="@{compilerpath}"
224
						rtti="@{rtti}"
225
						exceptions="@{exceptions}"
226
						multithreaded="@{multithreaded}"
227
						optimize="${@{name}@{compiler}@{buildtype}-compile_optimize}"
228
						debug="${@{name}@{compiler}@{buildtype}-debug_flag}" 
229
						outtype="@{outtype}" 
230
						subsystem="@{subsystem}" 
231
						outfile="@{pkgdir}\${@{name}@{buildtype}--targetfolder}\${@{name}@{compiler}@{outtype}@{buildtype}-output_name}"
232
						objdir="${objdir}\@{buildtype}_@{compiler}\@{targetname}">
233
 
234
						<compiler refid="@{compiler}_compiler_@{buildtype}_@{subsystem}"/>
235
						<linker refid="${@{buildtype}@{compiler}@{name}--linker}"/>					
236
 
237
						<includepath path="${@{compiler}_include_@{buildtype}}"/>
238
						<includepath path="@{pkgdir}\include"/>
239
 
240
						<compiler-elements/>
241
 
242
  					</cc>
243
				</else>
244
			</if>
245
 
1748 mtynas 246
		</sequential>
247
	</macrodef>
248
 
249
</project>