-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
932 lines (776 loc) · 34.9 KB
/
build.xml
File metadata and controls
932 lines (776 loc) · 34.9 KB
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
<project name="Common Source" default="dist" basedir=".">
<!--
This documents this build.xml file and explains the properties
file associated with each project. Each pascal project contains
a project.properties which defines information on how to build and
how to build the application.
PRE_REQUISITES:
General:
-> pasdoc installed and in your path environment
-> fpc installed and in your path environment
-> pdflatex installed and in your path environment
-> ant-contrib.jar 1.0 or later installed in your lib directory of ant
Turbo Pascal target:
-> tpc.exe 7.0 installed and in your path environment
-> The path of the location of files must be a short as possible and must not contain long file names,
otherwise execution errors shall occur.
-> Total length of unit directory location is 127 characters, same thing for includie directories otherwise compilation shall fail.
(To partially resolve the issues with this, the paths are made relative when compiling using this target)
Delphi target:
-> dcc32.exe installed and in your path environment
The following variables can be used in project.properties and will
be replaced at runtime with the correct information:
package.os = Shall be replaced by a target os (win32,dos,go32v2,os2,linux)
package.compiler = Shall be replaced by target compiler (fpc,delphi,tp)
package.compiler.version = Shall be replaced by target compiler version
These can be used to add specific path directories.
The following targets exists:
all Build and test everything; create a distribution, optionally install using freepascal
clean Delete all generated files and directories.
dist Produce the distributables
distclean Clean up the distribution files only.
docs Generate all documentation.
init Initialize the build: create directories, call <tstamp> and other common actions.
test Run the unit tests using freepascal in path
build Build using freepascal compiler in path
build-tpc Build using turbo pascal compiler
test-tpc Run unitary tests using turbo pascal compiler units
build-dcc Build using delphi compiler
test-dcc Run unitary tests using delphi compiler units
help
Cross-compilation support (using freepascal)
-> build-cross : Depends on the values in project.properties, builds cross-binaries
-> dist-cross : Depends on the values in project.properties, builds cross-binaries and cross zip files
-->
<description>Common utilities build system</description>
<!-- Internal properties -->
<!-- set global properties for this build -->
<property name="src" value="src"/>
<property name="bin" value="bin"/>
<property name="dist" value="dist"/>
<property name="test" value="test"/>
<property name="docs" value="doc"/>
<property name="lib" value="lib"/>
<property name="res" value="res"/>
<property name="general_delete_file_patterns"
value="**/*.aux **/*.log **/*.out **/*.toc **/*.tex **/*.tmp" />
<property name="build_delete_file_patterns"
value="**/*.bak **/*.dcu **/*.ppu **/*.ppw **/*.ppa **/*.ow **/*.oo2 **/*.ppo **/*.ol **/*.o **/*.obj **/*.aw **/*.tpw **/*.tpp **/*.tpu **/*.TPW **/*.TPP **/*.TPU" />
<property file="project.properties" />
<target name="init">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<!-- Create the target directories if they do not exist -->
<mkdir dir="${dist}"/>
<mkdir dir="${src}"/>
<mkdir dir="${bin}"/>
<mkdir dir="${lib}"/>
<mkdir dir="${docs}"/>
<mkdir dir="${docs}${file.separator}pasdoc/html"/>
<mkdir dir="${test}"/>
<property name="build.resolved" location="${bin}" />
<property name="build.relative" value=".${file.separator}${bin}" />
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="dir.units" value="" />
<property name="dir.includes" value="" />
<property name="dir.objects" value="" />
<property name="defines" value="" />
<filelist id="dirlist" dir="." files="${package.dir.units}" />
<pathconvert pathsep=" " property="package.dir.units.native" refid="dirlist">
</pathconvert>
<filelist id="dirlist.relative" dir="." files="${package.dir.units.native}" />
<pathconvert pathsep=" " property="package.dir.units.relative" refid="dirlist.relative">
<globmapper from="${basedir}${file.separator}*" to=".${file.separator}*" />
</pathconvert>
<!--
<echo message="${package.dir.units}" file="data.tmp" />
<replace file="data.tmp" token="/" value="${file.separator}" />
<loadfile property="package.dir.units.native" srcFile="data.tmp">
</loadfile>
-->
<filelist id="filelist" dir="." files="${package.file}" />
<pathconvert pathsep=" " property="package.file.native" refid="filelist">
</pathconvert>
<filelist id="filelist.relative" dir="." files="${package.file}" />
<pathconvert pathsep=" " property="package.file.native.relative" refid="filelist.relative">
<globmapper from="${basedir}${file.separator}*" to=".${file.separator}*" />
</pathconvert>
<filelist id="tstdirlist" dir="." files="${package.dir.tests}" />
<pathconvert pathsep=" " property="package.dir.tests.native" refid="tstdirlist">
</pathconvert>
<filelist id="tstdirlist.relative" dir="." files="${package.dir.tests.native}" />
<pathconvert pathsep=" " property="package.dir.tests.relative" refid="tstdirlist.relative">
<globmapper from="${basedir}${file.separator}*" to=".${file.separator}*" />
</pathconvert>
<!--
<echo message="${package.dir.tests}" file="data.tmp" />
<replace file="data.tmp" token="/" value="${file.separator}" />
<loadfile property="package.dir.tests.native" srcFile="data.tmp">
</loadfile>
-->
<filelist id="tstfilelist" dir="." files="${package.dir.tests}${file.separator}testit.pas" />
<pathconvert pathsep=" " property="package.file.tests.native" refid="tstfilelist">
</pathconvert>
</target>
<target name="all-win32" depends="init">
<antcall target="all" />
<antcall target="build-tpc" />
<antcall target="dist" />
<antcall target="build-dcc" />
<antcall target="dist" />
<antcall target="build-tpc" />
<antcall target="test-tpc" />
<antcall target="build-dcc" />
<antcall target="test-dcc" />
</target>
<target name="all" depends="init">
<echo>Building full targets...</echo>
<antcall target="docs" />
<antcall target="build" />
<antcall target="dist" />
<antcall target="dist-cross" />
<antcall target="build" />
<antcall target="test" />
</target>
<target name="help" depends="init">
<echo level="info">
all Build and test everything; create a distribution
clean Delete all generated files and directories.
dist Produce the distributables
distclean Clean up the distribution files only.
docs Generate all documentation.
init Initialize the build: create directories
test Run the unit tests using freepascal in path
build Build using freepascal compiler in path
build-tpc Build using turbo pascal compiler
test-tpc Run unitary tests using turbo pascal compiler units
build-dcc Build using delphi compiler
test-dcc Run unitary tests using delphi compiler units
help
Cross-compilation support (using freepascal)
build-cross Depends on the values in project.properties, builds cross-binaries
dist-cross Depends on the values in project.properties, builds cross-binaries and cross zip files
</echo>
</target>
<target name="build" depends="init" description="Compile the source " >
<clean />
<fpc-compile executable="fpc"
compile-defines="${package.defines}"
compile-units="${package.dir.units}"
compile-file="${package.file}"
create-config="true"
/>
</target>
<target name="test" depends="init" description="Run the unitary tests " >
<!-- Compile the unitary tests -->
<fpc-compile executable="fpc"
compile-defines="${package.defines}"
compile-units="${package.dir.tests} ${package.dir.units}"
compile-file="${package.dir.tests}${file.separator}testit.pas"
create-config="false"
/>
<!-- Run the unitary tests -->
<copy overwrite="true" todir="${build.resolved}">
<fileset dir="${package.dir.tests}">
<include name="**/*"/>
</fileset>
</copy>
<exec executable="${build.resolved}${file.separator}testit" dir="${build.resolved}" failonerror="true">
<arg line="" />
</exec>
</target>
<target name="build-cross" depends="init" description="Compile the source " >
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<for list="${package.cross.binaries}" param="executable" delimiter=" " trim="true">
<sequential>
<clean />
<fpc-compile executable="@{executable}"
compile-defines="${package.defines}"
compile-units="${package.dir.units}"
compile-file="${package.file}"
create-config="false"
/>
</sequential>
</for>
</target>
<target name="dist-cross" depends="init" description="Compile the source " >
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<!-- Complicated algorithm:
-> We have two lists, one with the executable of the compilers stored in package.cross.binaries
the other one in package.cross.targets which lists the actual target names.
-> So we first create a properties target1..targetN with each of them having the
target name, and then we use each of these properties to pass it to the
dist-bin to create the correct package.
-->
<var name="counter" value="1"/>
<var name="package.internal.arch" />
<for list="${package.cross.targets}" param="target" delimiter=" " trim="true">
<sequential>
<math result="counter" operand1="${counter}" operation="+" operand2="1" datatype="int"/>
<var name="target${counter}" value="@{target}" />
</sequential>
</for>
<var name="counter" value="1"/>
<for list="${package.cross.binaries}" param="executable" delimiter=" " trim="true">
<sequential>
<math result="counter" operand1="${counter}" operation="+" operand2="1" datatype="int"/>
<clean />
<fpc-compile executable="@{executable}"
compile-defines="${package.defines}"
compile-units="${package.dir.units}"
compile-file="${package.file}"
create-config="false"
/>
<!-- Get the properties -->
<propertycopy override="true" name="prop" from="target${counter}"/>
<var file="package.properties" />
<!-- Set package,internal.arch to correct string depending on the compiler type -->
<condition property="package.internal.arch${counter}" else="${prop}" value="${prop}-${package.compiler}${package.compiler.version}">
<istrue value="${package.library}"/>
</condition>
<!-- Get the properties -->
<propertycopy override="true" name="package.internal.arch" from="package.internal.arch${counter}"/>
<dist-bin
package-name="${package.name}"
package-title="${package.title}"
package-version="${package.version}"
package-arch="${package.internal.arch}"
package-documents="${package.documents}"
package-binaries="${package.binaries}"
package-url="${package.url}"
/>
</sequential>
</for>
</target>
<target name="build-dcc" depends="init" description="Compile the source using Delphi compiler" >
<clean />
<dcc-compile
compile-defines="${package.defines}"
compile-units="${package.dir.units.relative}"
compile-file="${package.file.native}"
create-config="true"
/>
</target>
<target name="test-dcc" depends="init" description="Run the delphi compiled unitary tests" >
<!-- Compile the unitary tests -->
<dcc-compile
compile-defines="${package.defines}"
compile-units="${package.dir.tests.native} ${package.dir.units.relative}"
compile-file="${package.file.tests.native}"
create-config="false"
/>
<!-- Run the unitary tests -->
<copy overwrite="true" todir="${build.resolved}">
<fileset dir="${package.dir.tests}">
<include name="**/*"/>
</fileset>
</copy>
<exec executable="${build.resolved}${file.separator}testit" dir="${build.resolved}" failonerror="true">
<arg line="" />
</exec>
</target>
<target name="distclean" depends="init" description="Clean the distribution files">
<delete>
<fileset dir="${dist}" includes="*.*"/>
</delete>
</target>
<target name="build-tpc" depends="init" description="Compile the source using Turbo Pascal compiler" >
<clean />
<tpc-compile
compile-defines="${package.defines}"
compile-units="${package.dir.units.relative}"
compile-file="${package.file.native.relative}"
/>
</target>
<target name="test-tpc" depends="init" description="Run the turbo pascal compiled unitary tests" >
<clean />
<!-- Compile the unitary tests -->
<tpc-compile
compile-defines="${package.defines}"
compile-units="${package.dir.tests.relative} ${package.dir.units.relative}"
compile-file="${package.file.tests.native}"
/>
<!-- Run the unitary tests -->
<copy overwrite="true" todir="${build.resolved}">
<fileset dir="${package.dir.tests}">
<include name="**/*"/>
</fileset>
</copy>
<exec executable="${build.resolved}${file.separator}testit" dir="${build.resolved}" failonerror="true">
<arg line="" />
</exec>
</target>
<!-- Prepare a distribution zip file. Requires package.properties to be present and valid -->
<target name="dist" depends="init" description="Generate the distribution" >
<property file="package.properties" />
<!-- Create the distribution packages -->
<tstamp>
<format property="current_day" pattern="dd" />
<format property="current_month" pattern="MM" />
<format property="current_year" pattern="yyyy" />
</tstamp>
<copy overwrite="true" file="master_pad_file.xml" tofile="pad_file.xml" />
<replace file="pad_file.xml">
<replacefilter
token="<Primary_Download_URL>"
value="<Primary_Download_URL>${package.url}${package.name}-${package.version}-src.zip"/>
<replacefilter
token="<Program_Version>"
value="<Program_Version>${package.version}"/>
<replacefilter
token="<Program_Release_Month>"
value="<Program_Release_Month>${current_month}"/>
<replacefilter
token="<Program_Release_Year>"
value="<Program_Release_Year>${current_year}"/>
<replacefilter
token="<Program_Release_Day>"
value="<Program_Release_Day>${current_day}"/>
<replacefilter
token="<Program_Name>"
value="<Program_Name>${package.title}"/>
</replace>
<!-- Create the source package that contains the following information
- test directory
- tst directory
- docs directory
- src directory
-->
<zip destfile=".${file.separator}${dist}${file.separator}${package.name}-${package.version}-src.zip" comment="${package.title} source package, version ${package.version}">
<zipfileset dir="${basedir}" includes="pad_file.xml tpc.cfg dcc32.cfg fpc.cfg ${src}/** ${docs}/pasdoc/** ${docs}/javadoc/** ${docs}/doxygen/** ${package.documents} ${test}/** ${bin} ${lib}" prefix="${package.name}" />
</zip>
<!-- Set package,internal.arch to correct string depending on the compiler type -->
<condition property="package.internal.arch" else="${package.cpu}-${package.os}" value="${package.cpu}-${package.os}-${package.compiler}${package.compiler.version}">
<istrue value="${package.library}"/>
</condition>
<dist-bin
package-name="${package.name}"
package-title="${package.title}"
package-version="${package.version}"
package-arch="${package.internal.arch}"
package-documents="${package.documents}"
package-binaries="${package.binaries}"
package-url="${package.url}"
/>
</target>
<target name="docs" description="Create the automated pascal documentation" depends="init">
<filelist id="doclist" dir="." files="${package.todocument}" />
<pathconvert pathsep=" " property="package.todocument.native" refid="doclist">
</pathconvert>
<echo file="files.tmp">${package.todocument.native}</echo>
<replace file="files.tmp"
token=" "
value="${line.separator}" />
<delete file="{$docs}/pasdoc/${package.name}.pdf" />
<exec executable="pasdoc" dir="${basedir}" searchpath="true" failonerror="true">
<arg line="--staronly --title "${package.title}" --sort=functions,non-record-fields,methods,properties --format html -D PASDOC -I ${src} --output .\${docs}\pasdoc\html -S files.tmp" />
</exec>
<exec executable="pasdoc" dir="${basedir}" searchpath="true" failonerror="true">
<arg line="--staronly --title "${package.title}" --sort=functions,non-record-fields,methods,properties --format latex -D PASDOC -I ${src} --output .\${docs}\pasdoc -S files.tmp" />
</exec>
<exec executable="pdflatex" dir="${basedir}" searchpath="true" failonerror="true">
<arg line="./${docs}/pasdoc/docs.tex --output-directory=./${docs}/pasdoc" />
</exec>
<exec executable="pdflatex" dir="${basedir}" searchpath="true">
<arg line="./${docs}/pasdoc/docs.tex --output-directory=./${docs}/pasdoc" />
</exec>
<exec executable="pdflatex" dir="${basedir}" searchpath="true">
<arg line="./${docs}/pasdoc/docs.tex --output-directory=./${docs}/pasdoc" />
</exec>
<move file="./${docs}/pasdoc/docs.pdf" tofile="./${docs}/pasdoc/${package.name}.pdf" />
<delete>
<fileset dir="${docs}" includes="${general_delete_file_patterns}"/>
</delete>
<delete file="files.tmp" />
</target>
<target name="clean" description="clean up" depends="init">
<clean />
</target>
<!-- Write the data output of a package information -->
<macrodef name="package-write" description="Write information on a package">
<attribute name="package.os" default="" description="The operating system target" />
<attribute name="package.compiler" description="The package target compiler type" />
<attribute name="package.compiler.version" description="The package target compiler version" />
<attribute name="package.cpu" description="The package CPU target compiler" />
<sequential>
<propertyfile
file="package.properties" comment=" Auto-generated package properties for compilation">
<entry key="package.os" value="@{package.os}"/>
<entry key="package.cpu" value="@{package.cpu}"/>
<entry key="package.compiler" value="@{package.compiler}"/>
<entry key="package.compiler.version" value="@{package.compiler.version}"/>
</propertyfile>
</sequential>
</macrodef>
<!-- Compile the data using the Delphi compiler
output variables:
package.os
package.compiler
package.cpu
-->
<macrodef name="dcc-compile" description="Delphi compiler execution macro" backtrace="true">
<attribute name="arguments" default="" description="Extra arguments to pass to compiler" />
<attribute name="compile-defines" description="Defines list" />
<attribute name="compile-units" description="Units and include search path" />
<attribute name="compile-file" description="Main file to compile" />
<attribute name="create-config" description="Create a Delphi configuration file (boolean)" />
<sequential>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<local name="current_tstamp" />
<var name="dir.units" value="" />
<var name="dir.includes" value="" />
<var name="dir.objects" value="" />
<var name="defines" value="" />
<local name="package.os" />
<local name="package.compiler.version" />
<local name="package.cpu" />
<local name="package.compiler" />
<property name="package.compiler" value="delphi" />
<property name="package.os" value="win32" />
<property name="package.cpu" value="x86" />
<!-- Get the target operating system -->
<exec executable="dcc32" dir="${basedir}" searchpath="true" output="target.tmp" >
<arg line="--version" />
</exec>
<loadfile property="package.compiler.version" srcFile="target.tmp">
<filterchain>
<headfilter lines="1"/>
<striplinebreaks/>
<tokenfilter>
<replaceregex pattern="[A-Za-z \)\(]+" flags="g" replace=""/>
</tokenfilter>
</filterchain>
</loadfile>
<delete file="target.tmp" />
<for list="@{compile-units}" param="dir" delimiter=" ">
<sequential>
<var name="dir.units" value= "${dir.units}@{dir};" />
<var name="dir.includes" value= "${dir.includes}@{dir};" />
<var name="dir.objects" value= "${dir.objects}@{dir};" />
</sequential>
</for>
<for list="@{compile-defines}" param="defs" delimiter=" ">
<sequential>
<var name="defines" value= "${defines} -D@{defs}" />
</sequential>
</for>
<!-- The information on the compiler used is written to a temporary file -->
<package-write
package.os="${package.os}"
package.compiler="${package.compiler}"
package.compiler.version="${package.compiler.version}"
package.cpu="${package.cpu}"
/>
<tstamp>
<format property="current_tstamp" pattern="yyyy-MM-dd" />
</tstamp>
<echo file="${src}${file.separator}version.inc">
const REVISION_STR = '${package.version}';
const BUILDDATE_STR = '${current_tstamp}';
const COMPILER_NAME = '${package.compiler}'
const COMPILER_VERSION = '${package.compiler.version}'
const PLATFORM_STR = '${package.os}-${package.cpu}'
</echo>
<if>
<equals arg1="${create-config}" arg2="true" />
<then>
<echo file="dcc32.cfg" message="-E${build.relative} -N${build.relative} -$H+ -M -H -W -$R+ -DCPU86 -DENDIAN_LITTLE -U${dir.units} -I${dir.includes} ${defines}"/>
<exec executable="dcc32" dir="${basedir}" searchpath="true" >
<arg line="@{compile-file}" />
</exec>
</then>
<else>
<exec executable="dcc32" dir="${basedir}" searchpath="true" >
<arg line="-E${build.relative} -N${build.relative} -$H+ -M -H -W -$R+ -DCPU86 -DENDIAN_LITTLE -U${dir.units} -I${dir.includes} ${defines} @{compile-file}" />
</exec>
</else>
</if>
</sequential>
</macrodef>
<!-- Compile the data using the Turbo pascal compiler
output variables:
package.os
package.compiler
package.cpu
-->
<macrodef name="tpc-compile" description="Turbo Pascal compiler execution macro" backtrace="true">
<attribute name="arguments" default="" description="Extra arguments to pass to compiler" />
<attribute name="compile-defines" description="Defines list" />
<attribute name="compile-units" description="Units and include search path" />
<attribute name="compile-file" description="Main file to compile" />
<sequential>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<local name="current_tstamp" />
<var name="dir.units" value="" />
<var name="dir.includes" value="" />
<var name="dir.objects" value="" />
<var name="defines" value="" />
<local name="package.os" />
<local name="package.compiler.version" />
<local name="package.cpu" />
<local name="package.compiler" />
<property name="package.compiler" value="tp" />
<property name="package.compiler.version" value="7" />
<property name="package.os" value="dos" />
<property name="package.cpu" value="x86" />
<for list="@{compile-units}" param="dir" delimiter=" ">
<sequential>
<var name="dir.units" value= "${dir.units}@{dir};" />
<var name="dir.includes" value= "${dir.includes}@{dir};" />
<var name="dir.objects" value= "${dir.objects}@{dir};" />
</sequential>
</for>
<for list="@{compile-defines}" param="defs" delimiter=" ">
<sequential>
<var name="defines" value= "${defines} -D@{defs}" />
</sequential>
</for>
<!-- The information on the compiler used is written to a temporary file -->
<package-write
package.os="${package.os}"
package.compiler="${package.compiler}"
package.compiler.version="${package.compiler.version}"
package.cpu="${package.cpu}"
/>
<tstamp>
<format property="current_tstamp" pattern="yyyy-MM-dd" />
</tstamp>
<echo file="${src}${file.separator}version.inc">
const REVISION_STR = '${package.version}';
const BUILDDATE_STR = '${current_tstamp}';
const COMPILER_NAME = '${package.compiler}'
const COMPILER_VERSION = '${package.compiler.version}'
const PLATFORM_STR = '${package.os}-${package.cpu}'
</echo>
<var name="tp.units" value="${dir.units}C:\PROGRAMS\BP\UNITS" />
<length string="${tp.units}" property="tp.units.length" />
<fail message="The search path for units and include files >= 127 characters, reduce your search path accordingly!">
<condition>
<length string="${tp.units}" when="greater" length="127" />
</condition>
</fail>
<echo>${tp.units}</echo>
<echo file="tpc.cfg" message="-I${dir.includes} -U${tp.units} -O${dir.objects} -E${build.relative} -M -L -$N+ -$R+ -DTP -DENDIAN_LITTLE -$$M65520,0,655360 "/>
<exec executable="tpc" dir="${basedir}" searchpath="true" failonerror="true" newenvironment="true" >
<arg line="/T${basedir} @{compile-file}" />
</exec>
</sequential>
</macrodef>
<!-- Compile the data using the Freepascal compiler
output variables to package.properties file:
package.target.os
package.compiler
package.compiler.version
package.target
-->
<macrodef name="fpc-compile" description="Freepascal compiler execution macro" backtrace="true">
<attribute name="executable" default="fpc" description="Executable name" />
<attribute name="arguments" default="" description="Extra arguments to pass to compiler" />
<attribute name="compile-defines" description="Defines list" />
<attribute name="compile-units" description="Units and include search path" />
<attribute name="compile-file" description="Main file to compile" />
<attribute name="create-config" description="Create a freepascal configuration file (boolean)" />
<sequential>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<var name="dir.units" value="" />
<var name="dir.includes" value="" />
<var name="dir.objects" value="" />
<var name="defines" value="" />
<local name="package.os" />
<local name="package.compiler.version" />
<local name="package.cpu" />
<local name="package.compiler" />
<property name="package.compiler" value="fpc" />
<local name="current_tstamp" />
<!-- Get the target operating system -->
<exec executable="@{executable}" dir="${basedir}" searchpath="true" output="target.tmp" >
<arg line="-iTO" />
</exec>
<exec executable="@{executable}" dir="${basedir}" searchpath="true" output="target1.tmp" >
<arg line="-iTP" />
</exec>
<exec executable="@{executable}" dir="${basedir}" searchpath="true" output="target2.tmp" >
<arg line="-iV" />
</exec>
<loadfile property="package.os" srcFile="target.tmp">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<delete file="target.tmp" />
<loadfile property="package.cpu" srcFile="target1.tmp">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<delete file="target1.tmp" />
<loadfile property="package.compiler.version" srcFile="target2.tmp">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<delete file="target2.tmp" />
<!-- The information on the compiler used is written to a temporary file -->
<package-write
package.os="${package.os}"
package.compiler="${package.compiler}"
package.compiler.version="${package.compiler.version}"
package.cpu="${package.cpu}"
/>
<tstamp>
<format property="current_tstamp" pattern="yyyy-MM-dd" />
</tstamp>
<echo file="${src}${file.separator}version.inc">
const REVISION_STR = '${package.version}';
const BUILDDATE_STR = '${current_tstamp}';
const COMPILER_NAME = '${package.compiler}'
const COMPILER_VERSION = '${package.compiler.version}'
const PLATFORM_STR = '${package.os}-${package.cpu}'
</echo>
<if>
<equals arg1="${create-config}" arg2="true" />
<then>
<for list="@{compile-units}" param="dir" delimiter=" ">
<sequential>
<var name="dir.units" value= "${dir.units}${line.separator}-Fu@{dir}" />
<var name="dir.includes" value= "${dir.includes}${line.separator}-Fi@{dir}" />
</sequential>
</for>
<for list="@{compile-defines}" param="defs" delimiter=" ">
<sequential>
<var name="defines" value= "${defines}${line.separator}-d@{defs}" />
</sequential>
</for>
<echo file="fpccfg.cfg" message="@{arguments}${line.separator}-FE${build.relative}${line.separator}-FU${build.relative}${line.separator}-vihwn${line.separator}-Cr${line.separator}-CR${line.separator}-Co${line.separator}-Ct${line.separator}-Ci${line.separator}-gl${line.separator}-Sg${line.separator}-Sh${line.separator}${dir.units}${line.separator}${dir.includes}${line.separator}${defines}${line.separator}" />
<exec executable="@{executable}" dir="${basedir}" searchpath="true" failonerror="true">
<arg line="@fpccfg.cfg @{compile-file}" />
</exec>
</then>
<else>
<for list="@{compile-units}" param="dir" delimiter=" ">
<sequential>
<var name="dir.units" value= "${dir.units} -Fu@{dir}" />
<var name="dir.includes" value= "${dir.includes} -Fi@{dir}" />
</sequential>
</for>
<for list="@{compile-defines}" param="defs" delimiter=" ">
<sequential>
<var name="defines" value= "${defines} -d@{defs}" />
</sequential>
</for>
<exec executable="@{executable}" dir="${basedir}" searchpath="true" failonerror="true">
<arg line="@{arguments} -FE${build.relative} -FU${build.relative} -vihwn -Cr -CR -Co -Ct -Ci -gl -Sg -Sh ${dir.units} ${dir.includes} ${defines} @{compile-file}" />
</exec>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="clean" description="Clean macro" backtrace="true">
<sequential>
<!-- Delete the ${bin} directory trees -->
<delete file="pad_file.xml" />
<delete>
<fileset dir="." includes="pad_file?.xml"/>
<fileset dir="." includes="package.properties"/>
</delete>
<delete>
<fileset dir="." includes="${general_delete_file_patterns}"/>
</delete>
<delete>
<fileset dir="${bin}" includes="${build_delete_file_patterns} *.*"/>
</delete>
</sequential>
</macrodef>
<!-- Create a zip distribution file for the specified platform with
the specified parameters -->
<macrodef name="dist-bin" description="Create binary distributable macro" backtrace="true">
<attribute name="package-name" description="The package name" />
<attribute name="package-title" description="The package title" />
<attribute name="package-version" description="Package version" />
<attribute name="package-arch" description="Package target arch" />
<attribute name="package-documents" description="Package documents" />
<attribute name="package-binaries" description="Package binaries" />
<attribute name="package-url" description="Package url" />
<sequential>
<var name="pad_os" value="Other" />
<local name="current_day" />
<local name="current_month" />
<local name="current_year" />
<!-- Create the distribution packages -->
<tstamp>
<format property="current_day" pattern="dd" />
<format property="current_month" pattern="MM" />
<format property="current_year" pattern="yyyy" />
</tstamp>
<if>
<contains string="@{platform-arch}" substring="win32" />
<then>
<var name="pad_os" value="Win95,Win98,WinME,WinNT 3.x,WinNT 4.x,Windows2000,WinXP,Windows2003" />
</then>
<elseif>
<contains string="@{platform-arch}" substring="linux" />
<then>
<var name="pad_os" value="Linux" />
</then>
</elseif>
<elseif>
<contains string="@{platform-arch}" substring="go32" />
<then>
<var name="pad_os" value="MS-DOS" />
</then>
</elseif>
<elseif>
<contains string="@{platform-arch}" substring="dos" />
<then>
<var name="pad_os" value="MS-DOS" />
</then>
</elseif>
<elseif>
<contains string="@{platform-arch}" substring="beos" />
<then>
</then>
</elseif>
<elseif>
<contains string="@{platform-arch}" substring="os2" />
<then>
<var name="pad_os" value="OS/2" />
</then>
</elseif>
<elseif>
<contains string="@{platform-arch}" substring="beos" />
<then>
<var name="pad_os" value="BEOS" />
</then>
</elseif>
</if>
<copy overwrite="true" file="master_pad_file.xml" tofile="pad_file.xml" />
<replace file="pad_file.xml">
<replacefilter
token="<Primary_Download_URL>"
value="<Primary_Download_URL>@{package-url}@{package-name}-@{package-version}-@{package-arch}.zip"/>
<replacefilter
token="<Program_Version>"
value="<Program_Version>@{package-version}"/>
<!--
<replacefilter
token="<Program_OS_Support>"
value="<Program_OS_Support>${pad_os}"/>
-->
<replacefilter
token="<Program_Release_Month>"
value="<Program_Release_Month>${current_month}"/>
<replacefilter
token="<Program_Release_Year>"
value="<Program_Release_Year>${current_year}"/>
<replacefilter
token="<Program_Release_Day>"
value="<Program_Release_Day>${current_day}"/>
<replacefilter
token="<Program_Name>"
value="<Program_Name>@{package-title}"/>
</replace>
<zip destfile=".${file.separator}${dist}${file.separator}@{package-name}-@{package-version}-@{package-arch}.zip" comment="@{package-title} binary @{package-arch} package, version @{package-version}">
<zipfileset dir="${basedir}" includes="pad_file.xml @{package-binaries} ${docs}/pasdoc/** ${docs}/javadoc/** ${docs}/doxygen/** @{package-documents}" prefix="@{package-name}" />
</zip>
</sequential>
</macrodef>
</project>