Subversion Repositories DevTools

Rev

Rev 1760 | Go to most recent revision | 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
 
37
		<attribute	name="usevcl"				
38
					default="false"
39
					description="Optional flag, used to include vcl libraries"/>
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"/>
82
				<then>
83
					<property name="@{name}@{compiler}@{buildtype}-compile_type_symbol" value="D"/>
84
					<property name="@{name}@{compiler}@{buildtype}-debug_flag" value="true"/>
85
					<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="none"/>
86
				</then>
87
				<else>
88
					<property name="@{name}@{compiler}@{buildtype}-compile_type_symbol" value="P"/>
89
					<property name="@{name}@{compiler}@{buildtype}-debug_flag" value="false"/>
90
					<if>
91
						<equals arg1="@{optimize}" arg2=""/>
92
						<then>
93
							<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="speed"/>
94
						</then>
95
						<else>
96
							<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="@{optimize}"/>
97
						</else>
98
					</if>
99
				</else>
100
			</if>
101
 
102
			<!-- Identify the compile platform extension -->
103
			<condition property="compile.platform" value="win32">
104
				<os family="windows"/>
105
			</condition>
106
 
107
			<condition property="compile.platform" value="win32">
108
				<os family="dos"/>
109
			</condition>
110
 
111
			<condition property="compile.platform" value="sparc">
112
				<os name="SunOS"/>
113
			</condition>
1760 crichaud 114
 
1748 mtynas 115
 
116
			<!-- Type of target => executable,plugin,shared,static -->
117
			<if>
118
				<equals arg1="@{outtype}" arg2="executable"/>
119
				<then>
1762 crichaud 120
					<property name="@{name}@{buildtype}--targetfolder" value="bin.${compile.platform}${@{name}@{compiler}@{buildtype}-compile_type_symbol}"/>
1760 crichaud 121
					<property name="@{name}@{compiler}@{outtype}@{buildtype}-output_name" value="@{targetname}"/>
1748 mtynas 122
				</then>
123
				<else>
1762 crichaud 124
					<property name="@{name}@{buildtype}--targetfolder" value="lib.${compile.platform}"/>
1760 crichaud 125
					<property name="@{name}@{compiler}@{outtype}@{buildtype}-output_name" value="@{targetname}@{version}${@{name}@{compiler}@{buildtype}-compile_type_symbol}"/>	
1748 mtynas 126
				</else>
127
			</if>
1758 crichaud 128
 
1760 crichaud 129
			<!-- Type of target => Linker Options for bcpp compiler according type executable,plugin,shared,static-->
130
 
131
			<if>
132
			<equals arg1="@{compiler}" arg2="bcpp"/>
133
			<then>
134
				<if>
135
				<equals arg1="@{outtype}" arg2="executable"/>
136
				<then>
137
				<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>
138
				</then>
139
				<else>
140
				<if>
141
					<equals arg1="@{outtype}" arg2="shared"/>
142
					<then>
143
						<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>	
144
					</then>
145
					<else>
146
						<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_none"/>
147
					</else>
148
				</if>
149
				</else>
150
				</if>
151
			</then>
152
			<else>
153
				<property name="@{buildtype}@{compiler}@{name}--linker" value="@{compiler}_linker_@{buildtype}_@{subsystem}"/>	
154
			</else>
155
			</if>
156
 
157
			<!-- Type of target => Linker Options with VCL-->
158
			<if>
159
				<equals arg1="@{usevcl}" arg2="true"/>
160
				<then>
161
					<property name="@{name}_@{compiler}--vcl" value="_vcl"/>
162
 
163
				</then>
164
				<else>
165
					<property name="@{name}_@{compiler}--vcl" value=""/>
166
 
167
				</else>
168
			</if>
169
 
1758 crichaud 170
 
1748 mtynas 171
			<mkdir dir="${objdir}/@{buildtype}_@{compiler}"/>
172
			<mkdir dir="${objdir}/@{buildtype}_@{compiler}/@{targetname}"/>
173
			<mkdir dir="@{pkgdir}"/>
1762 crichaud 174
			<mkdir dir="@{pkgdir}/${@{name}@{buildtype}--targetfolder}"/>
1748 mtynas 175
 
1762 crichaud 176
			<echo taskname="ant-cppcompile-task">Compile @{name} into @{pkgdir}/${@{name}@{buildtype}--targetfolder}/${@{name}@{compiler}@{outtype}@{buildtype}-output_name}</echo>
1748 mtynas 177
			<echo taskname="ant-cppcompile-task">Using Compiler @{compiler} from @{compilerpath}</echo>
178
			<echo taskname="ant-cppcompile-task">Placing Objects in ${objdir}/@{buildtype}_@{compiler}/@{targetname}</echo>
179
			<echo taskname="ant-cppcompile-task">Use Compiler Includes from ${@{compiler}_include_@{buildtype}}</echo>
180
			<echo taskname="ant-cppcompile-task">Use Package Includes from @{pkgdir}/include</echo>
181
			<echo taskname="ant-cppcompile-task">Linking with Library ${@{compiler}_lib_@{buildtype}} Files: ${@{compiler}_libraries_@{buildtype}}</echo>
1758 crichaud 182
 
1760 crichaud 183
			<echo taskname="ant-cppcompile-task">Linker   ${@{buildtype}@{compiler}@{name}--linker}${@{name}_@{compiler}--vcl}</echo>
1758 crichaud 184
			<echo taskname="ant-cppcompile-task">Compiler @{compiler}_compiler_@{buildtype}_@{subsystem}</echo>
185
			<echo taskname="ant-cppcompile-task">Output File Name ${@{name}@{compiler}@{outtype}@{buildtype}-output_name}</echo>
186
 
1760 crichaud 187
			<echo taskname="ant-cppcompile-task">Include Path: ${@{compiler}_include_@{buildtype}}</echo>
188
 
1758 crichaud 189
 
1748 mtynas 190
  			<cc name="${@{compiler}_compilername}" 
191
				path="@{compilerpath}"
192
				rtti="@{rtti}"
193
				exceptions="@{exceptions}"
194
				multithreaded="@{multithreaded}"
195
				optimize="${@{name}@{compiler}@{buildtype}-compile_optimize}"
196
				debug="${@{name}@{compiler}@{buildtype}-debug_flag}" 
197
				outtype="@{outtype}" 
198
				subsystem="@{subsystem}" 
1762 crichaud 199
				outfile="@{pkgdir}/${@{name}@{buildtype}--targetfolder}/${@{name}@{compiler}@{outtype}@{buildtype}-output_name}"
1748 mtynas 200
				objdir="${objdir}/@{buildtype}_@{compiler}/@{targetname}">
201
 
1752 mtynas 202
				<compiler refid="@{compiler}_compiler_@{buildtype}_@{subsystem}"/>
1760 crichaud 203
				<linker refid="${@{buildtype}@{compiler}@{name}--linker}${@{name}_@{compiler}--vcl}"/>
1758 crichaud 204
 
1760 crichaud 205
 
1748 mtynas 206
				<includepath path="${@{compiler}_include_@{buildtype}}"/>
207
				<includepath path="@{pkgdir}/include"/>
208
 
209
				<compiler-elements/>
210
 
211
  			</cc>
212
 
213
		</sequential>
214
	</macrodef>
215
 
216
</project>