summaryrefslogtreecommitdiffstats
path: root/cpp/das/antscripts/compile-targets.xml
blob: 6c9a1b0e6dc316483a6513dc1694be2d6b89d77e (plain)
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<?xml version="1.0" encoding="UTF-8"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
     http://www.apache.org/licenses/LICENSE-2.0
     
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<project name='compiler-targets'>

  <import file="./system.xml"/>

  <!--
    Do a cpp compilation.
    Inherits from "Tuscany-BaseCompiler", which has an include path of:
        ${tuscanyDAS.root.src.dir}/core/src
    @param objdir - directory where the object files will be written
    @param srcdir - directory where the source files are located.
    @param infiles - a space seperated list of the files to compile
    @param custom-cc-elements - any extra cpp elements, may also be extra <includepath> elements
  -->
  <macrodef name="cpp-compile">
    <attribute name="objdir" default="."/>
    <attribute name="srcdir" default="."/>
    <attribute name="infiles" default="*.cpp"/>
    <element name="custom-cc-elements" optional="true"/>
    <sequential>
      <mkdir dir='@{objdir}'/>
      <cc subsystem='console'
          objdir='@{objdir}'
          debug='${debug.compile}'>
            <compiler refid='${compiler.name}-Compiler'/>
            <fileset dir='@{srcdir}' includes='@{infiles}'/>
            <custom-cc-elements/>
      </cc>

    </sequential>
  </macrodef>

  <!--
    Do a cpp link which results in either a library (linktype of plugin, shared, or static)
    or an executable (linktype of executable).
    Inherits from "Tuscany-BaseLinker"
    @param outfile - name of the library to create, OS prefixes and suffixes will be added
    @param destdir - directory where the library will be written
    @param infiles - a space seperated list of the object files to link
    @param linktype - executable, plugin, shared, static
    @param custom-ld-elements - any extra cpp elements, may also be extra <libset> elements
  -->
  <macrodef name="cpp-link">
    <attribute name="outfile" default="out"/>
    <attribute name="outdir" default="."/>
    <attribute name="indir" default="${env}"/>
    <attribute name="infiles" default="*${object.ext}"/>
    <attribute name="linktype" default="shared"/>
    <element name="custom-ld-elements" optional="true"/>
    <sequential>
      <mkdir dir='@{outdir}'/>
      <cc link='@{linktype}'
          subsystem='console'
          outfile='@{outdir}/@{outfile}'
          debug='${debug.compile}'>
            <linker refid='${compiler.name}-Linker'/>
            <fileset dir='@{indir}' includes='@{infiles}'/>
            <custom-ld-elements/>
      </cc>
  <!--<cpp-embed-manifest dir="@{outdir}" file="@{outfile}" outtype="@{outtype}"/>-->
    </sequential>
  </macrodef>

  <!--
    Do a cpp build which compiles and links, resulting in either a library (linktype
    of plugin, shared, or static) or an executable (linktype of executable).
    Inherits from both "Tuscany-BaseCompiler" and "Tuscany-BaseLinker"
    @param srcdir  - directory where the source files are located.
    @param infiles - a space seperated list of the source files to compile and link
    @param outdir  - directory where the output file will be written
    @param outfile - name of the library or binary to create, OS prefixes and suffixes may be added
    @param outtype - executable, plugin, shared, static
    @param custom-build-elements - any extra elements needed for compiling or linking
                                   may also be extra <includepath> or <libset> elements
  -->
  <macrodef name="cpp-build">
    <attribute name="srcdir" default="."/>
    <attribute name="infiles" default="**/*.cpp"/>
    <attribute name="outdir" default="."/>
    <attribute name="outfile" default="out"/>
    <attribute name="outtype" default="shared"/>
    <element name="custom-build-elements" optional="true"/>
    <sequential>
      <mkdir dir='@{outdir}'/>
      <cc outtype='@{outtype}'
          subsystem='console'
          objdir='@{outdir}'
          outfile='@{outdir}/@{outfile}'
          debug='${debug.compile}'>
            <compiler refid='${compiler.name}-Compiler'/>
            <linker refid='${compiler.name}-Linker'/>
            <fileset dir='@{srcdir}' includes='@{infiles}'/>
<compilerarg value="/D_VC80_UPGRADE=0x0600"/>
            <custom-build-elements/>
      </cc>
  <!--<cpp-embed-manifest dir="@{outdir}" file="@{outfile}" outtype="@{outtype}"/>-->
    </sequential>
  </macrodef>

  <!--
    Install a single file
    @param file - file to install
    @param srcdir - directory of file to install
    @param destdir - Where to install the file
    @param executable - set permissions to executable, defaults true
  -->
  <macrodef name="cpp-install-file">
    <attribute name="srcfile"/>
    <attribute name="srcdir" default="."/>
    <attribute name="destfile" default="@{srcfile}"/>
    <attribute name="destdir"/>
    <attribute name="executable" default="true"/>
    <sequential>
      <mkdir dir="@{destdir}"/>
      <copy file="@{srcdir}/@{srcfile}" tofile="@{destdir}/@{destfile}" overwrite='true'/>
      <if>
        <equals arg1="@{executable}" arg2="true"/>
        <then>
          <chmod file="@{destdir}/@{destfile}" perm="755"/>
        </then>
      </if>
    </sequential>
  </macrodef>

  <!--
    Install multiple files
    @param files - space seperated list of files to install
    @param srcdir - location of files to install
    @param destdir - Where to install files
    @param executable - set permissions to executable, defaults false
  -->
  <macrodef name="cpp-install-files">
    <attribute name="files" default="*.*"/>
    <attribute name="srcdir" default="."/>
    <attribute name="destdir"/>
    <attribute name="executable" default="false"/>
    <sequential>
      <mkdir dir="@{destdir}"/>
      <copy todir="@{destdir}" overwrite='true'>
        <fileset dir="@{srcdir}" includes="@{files}"/>
      </copy>
      <if>
        <equals arg1="@{executable}" arg2="true"/>
        <then>
          <chmod file="@{destdir}/@{files}" perm="755"/>
        </then>
      </if>
    </sequential>
  </macrodef>

  <!--
    Install a library
    @param lib - library to install
    @param srcdir - directory of file to install
    @param destdir - Where to install the file
    @param executable - set permissions to executable, defaults true
  -->
  <macrodef name="cpp-install-lib">
    <attribute name="lib"/>
    <attribute name="srcdir" default="."/>
    <attribute name="destrootdir"/>
    <attribute name="version" default="${tuscanyDAS.library.version}"/>
    <sequential>
      <cpp-install-file
          srcfile="${lib.prefix}@{lib}${lib.ext}"
          srcdir="@{srcdir}"
          destfile="${lib.prefix}@{lib}${lib.ext}@{version}"
          destdir="@{destrootdir}/lib"/>
      <if>
        <os family="windows"/>
        <then>
          <cpp-install-file
              srcfile="${lib.prefix}@{lib}${dll.ext}"
              srcdir="@{srcdir}"
              destfile="${lib.prefix}@{lib}${dll.ext}@{version}"
              destdir="@{destrootdir}/bin"/>
        </then>
      </if>
    </sequential>
  </macrodef>


   


  <!--
    Create a symlink on unix and mac only
    @param lib - library file to install
    @param srclibdir - location of library files to install
    @param destlibdir - Where to install library files
  -->
  <macrodef name="cpp-symlink">
    <attribute name="linkdir" default=""/>
    <attribute name="resourcedir" default="."/>
    <attribute name="link"/>
    <attribute name="resource"/>
    <sequential>
      <if>
        <or>
          <os family="unix"/>
          <os family="mac"/>
        </or>
        <then>
          <mkdir dir="@{linkdir}"/>
          <symlink
              link="@{linkdir}/@{link}"
              resource="@{resourcedir}/@{resource}"
              overwrite="true"/>
        </then>
      </if>
    </sequential>
  </macrodef>

  <!--
    Delete files from a directory, and possible delete the directory
    @param files - space seperated list of files to delete
    @param headerdir - directory where files to delete are
    @param quiet - verbosity, "true" or "false"
    @param rmdir - delete the directory after deleting files, "true" or "false"
    @param custom-delete-elements - anything else you need done additionally
  -->
  <macrodef name="cpp-clean-files">
    <attribute name="files" default="*.*"/>
    <attribute name="dir" default="."/>
    <attribute name="quiet" default="true"/>
    <attribute name="rmdir" default="false"/>
    <element name="custom-delete-elements" optional="true"/>
    <sequential>
      <delete quiet="@{quiet}">
        <fileset dir="@{dir}" includes="@{files}"/>
      </delete>
      <if>
        <equals arg1="@{rmdir}" arg2="true"/>
        <then>
          <delete dir="@{dir}"/>
        </then>
      </if>
      <custom-delete-elements/>
    </sequential>
  </macrodef>

  <!--
    Embed the manifest in the library or executable on Windows only
    Uses the Microsoft manifest tool "mt"
    @param dir - the directory where the lib/exe resides
    @param file - the filename with no suffixes or prefixes
    @param outtype - the outtype that's passed to the cc task, used to create the filename
    -->
  <macrodef name="cpp-embed-manifest">
    <attribute name="dir"/>
    <attribute name="file"/>
    <attribute name="outtype"/>
      <sequential>
      <if>
        <os family="windows"/>
        <then>
          <if>
            <equals arg1="@{outtype}" arg2="executable"/>
            <then>
              <property name="file.name" value="@{file}${exe.ext}"/>
            </then>
          </if>
          <property name="file.name" value="${lib.prefix}@{file}${dll.ext}"/>

          <exec executable="mt">
            <arg line="-manifest @{dir}/${file.name}.manifest -outputresource:@{dir}/${file.name};2"/>
          </exec>
        </then>
      </if>
    </sequential>
  </macrodef>
	
  <!--
    Delete a library from a root library directory, and possible delete the directory
    On windows, it will delete both bin/<library>.dll and lib/<library>.lib
    On Unix, it will delete lib/<library>
    @param lib - library to delete
    @param librootdir - directory where the library to delete is located
    @param quiet - verbosity, "true" or "false"
  -->
  <macrodef name="cpp-clean-lib">
  	<attribute name="lib"/>
  	<attribute name="librootdir"/>
    <attribute name="quiet" default="true"/>
  	<attribute name="version" default="${tuscanyDAS.library.version}"/>
  	<sequential>
      <delete quiet="@{quiet}" file="@{librootdir}/lib/${lib.prefix}@{lib}${lib.ext}@{version}"/>
      <if>
        <os family="windows"/>
        <then>
          <delete quiet="@{quiet}" file="@{librootdir}/bin/${lib.prefix}@{lib}${dll.ext}@{version}"/>
        </then>
      </if>
  	</sequential>
  </macrodef>

</project>