Subversion Repositories DevTools

Rev

Rev 1750 | Rev 1754 | 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"/>
36
 
37
		<attribute	name="exceptions"		
38
					default="true"
39
					description="Optional flag, used to enable exception handling support. Defaults to true"/>
40
 
41
		<attribute	name="multithreaded"		
42
					default="true"
43
					description="Optional flag, used to enable multithreaded support. Defaults to true"/>
44
 
45
		<attribute	name="optimize"			
46
					default="speed"
47
					description="Optional flag, used to specify optimization. Defaults to 'speed', but is overridden to 'none' by debug buildtype."/>
48
 
49
		<attribute	name="outtype"			
50
					default="executable"
51
					description="Optional flag, used to indicate the type of package being built (static, shared, executable)"/>
52
 
53
		<attribute	name="subsystem"			
54
					default="console"
55
					description="Optional flag, used to indicate the nature of the subsystem under which the program will run. (gui, console, other)."/>
56
 
57
		<attribute	name="build" 
58
					default="${basedir}/build"
59
					description="The location of the project 'build' folder. Defaults to 'project basedir'/build. You do not normal need to provide this value."/>
60
 
61
		<attribute	name="objdir"			
62
					default="@{build}/obj"
63
					description="Optional value, used to nominate the build object directory base."/>
64
 
65
		<attribute	name="pkgdir"			
66
					default="@{build}/pkg"
67
					description="Optional value, used to nominate the build package directory."/>
68
 
69
		<element name="compiler-elements" optional="yes" implicit="yes" description="Any compiler specific parameters."/>
70
 
71
		<sequential>
72
			<echo taskname="ant-cppcompile-task">Compiling @{name} Version: @{version}</echo>
73
 
74
			<!-- Determine any compile type dependent flags
75
				 Including naming standards, optimizations, etc -->
76
			<if>
77
				<equals arg1="@{buildtype}" arg2="debug"/>
78
				<then>
79
					<property name="@{name}@{compiler}@{buildtype}-compile_type_symbol" value="D"/>
80
					<property name="@{name}@{compiler}@{buildtype}-debug_flag" value="true"/>
81
					<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="none"/>
82
				</then>
83
				<else>
84
					<property name="@{name}@{compiler}@{buildtype}-compile_type_symbol" value="P"/>
85
					<property name="@{name}@{compiler}@{buildtype}-debug_flag" value="false"/>
86
					<if>
87
						<equals arg1="@{optimize}" arg2=""/>
88
						<then>
89
							<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="speed"/>
90
						</then>
91
						<else>
92
							<property name="@{name}@{compiler}@{buildtype}-compile_optimize" value="@{optimize}"/>
93
						</else>
94
					</if>
95
				</else>
96
			</if>
97
 
98
			<!-- Identify the compile platform extension -->
99
			<condition property="compile.platform" value="win32">
100
				<os family="windows"/>
101
			</condition>
102
 
103
			<condition property="compile.platform" value="win32">
104
				<os family="dos"/>
105
			</condition>
106
 
107
			<condition property="compile.platform" value="sparc">
108
				<os name="SunOS"/>
109
			</condition>
110
 
111
			<!-- Type of target => executable,plugin,shared,static -->
112
			<if>
113
				<equals arg1="@{outtype}" arg2="executable"/>
114
				<then>
115
					<property name="targetfolder" value="bin.${compile.platform}"/>
116
				</then>
117
				<else>
118
					<property name="targetfolder" value="lib.${compile.platform}"/>
119
				</else>
120
			</if>
121
 
122
			<mkdir dir="${objdir}/@{buildtype}_@{compiler}"/>
123
			<mkdir dir="${objdir}/@{buildtype}_@{compiler}/@{targetname}"/>
124
			<mkdir dir="@{pkgdir}"/>
125
			<mkdir dir="@{pkgdir}/${targetfolder}"/>
126
 
127
			<echo taskname="ant-cppcompile-task">Compile @{name} into @{pkgdir}/${targetfolder}/@{targetname}${version}${@{name}@{compiler}@{buildtype}-compile_type_symbol}</echo>
128
			<echo taskname="ant-cppcompile-task">Using Compiler @{compiler} from @{compilerpath}</echo>
129
			<echo taskname="ant-cppcompile-task">Placing Objects in ${objdir}/@{buildtype}_@{compiler}/@{targetname}</echo>
130
			<echo taskname="ant-cppcompile-task">Use Compiler Includes from ${@{compiler}_include_@{buildtype}}</echo>
131
			<echo taskname="ant-cppcompile-task">Use Package Includes from @{pkgdir}/include</echo>
132
			<echo taskname="ant-cppcompile-task">Linking with Library ${@{compiler}_lib_@{buildtype}} Files: ${@{compiler}_libraries_@{buildtype}}</echo>
133
 
134
  			<cc name="${@{compiler}_compilername}" 
135
				path="@{compilerpath}"
136
				rtti="@{rtti}"
137
				exceptions="@{exceptions}"
138
				multithreaded="@{multithreaded}"
139
				optimize="${@{name}@{compiler}@{buildtype}-compile_optimize}"
140
				debug="${@{name}@{compiler}@{buildtype}-debug_flag}" 
141
				outtype="@{outtype}" 
142
				subsystem="@{subsystem}" 
143
				outfile="@{pkgdir}/${targetfolder}/@{targetname}${version}${@{name}@{compiler}@{buildtype}-compile_type_symbol}"
144
				objdir="${objdir}/@{buildtype}_@{compiler}/@{targetname}">
145
 
1752 mtynas 146
				<compiler refid="@{compiler}_compiler_@{buildtype}_@{subsystem}"/>
147
				<linker refid="@{compiler}_linker_@{buildtype}_@{subsystem}"/>
1748 mtynas 148
 
149
				<includepath path="${@{compiler}_include_@{buildtype}}"/>
150
				<includepath path="@{pkgdir}/include"/>
151
 
152
				<compiler-elements/>
153
 
154
  			</cc>
155
 
156
		</sequential>
157
	</macrodef>
158
 
159
</project>