forked from jython/jython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
1543 lines (1399 loc) · 73.1 KB
/
build.xml
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
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
Original Copyright 2000 Dj Walker-Morgan
Further development (c)2019 Jython Developers
Licensed to the PSF under a Contributor Agreement.
-->
<project name="jython" default="developer-build" basedir=".">
<target name="usage" depends="common-version-strings"
description="print usage hints (-emacs removes [echo] prefix)">
<echo>
Case 1: developer build
-----------------------
Use the command:
ant developer-build
or just:
ant
as it is the default target. This build will create directories
/build and /dist below ${basedir}.
Jython will identify its version with a trailing "-DEV".
Case 2: build an installer for the development version
------------------------------------------------------
Use the command:
ant installer
An installer built this way does not include javadoc or source
JARs unless you build them first. It will be versioned as a
snapshot, e.g. ${jython.release}-SNAPSHOT. You can choose another name
for the snapshot, via a property:
ant -Dsnapshot.name=MYTEST installer
Case 3: full build for a release (use clean, tagged checkout)
-------------------------------------------------------------
You do not have to have access to the Jython Git
repository, but you do need to be at the root of a checked-out
(i.e. newly cloned) source tree. The release aretefacts will be
marked as a snapshot (not an official release) if any of the
following apply:
- there is no .git directory (this is not a repo),
- the source tree contains any extraneous files,
- files have been edited and not committed,
- the current state is not tagged with correct release,
- you supply the snapshot.name property.
This will create a big jython-installer-${jython.release}.jar,
in the artefacts directory.
See also https://jython-devguide.rtfd.io/en/latest/release_jy.html
Note on targets
---------------
A subset of the available targets are designed for direct invocation.
Following an ant convention, the callable targets have a description
attribute. Use ant -p to display these targets. All other targets
may behave unpredictably if called directly.
Where ant looks for ant.properties
----------------------------------
1. in user.home
2. in the same directory as this build.xml file
The first setting of a property wins. Further settings are ignored.
An example ant.properties file:
-------------------------------
# - zxJDBC
oracle.jar = ../support/ojdbc6.jar
informix.jar = ../support/jdbc-4.10.12.jar
# - option for javac (build.compiler=modern is a global option to use standard jdk 1.7/1.8)
#build.compiler=modern
#jdk.target.version=1.7
#debug=false
#deprecation=off
</echo>
</target>
<target name="developer-build"
depends="jar, copy-dev, pycompile"
description="a local build for developers" />
<target name="installer"
depends="installer-preinit, jar-installer"
description="build a snapshot installer from the current state" />
<target name="full-build"
depends="clean, full-preinit, full-check, all-jars, jar-installer"
description="build releasable artefacts. (Use a fresh checkout for a real release)" />
<target name="common-config" depends="common-constants">
<!-- Initialisations common to full and developer builds. -->
<property file="${user.home}/ant.properties" />
<property file="${basedir}/ant.properties" />
<property name="jython.java.version" value="1.8" />
<!-- Temporarily fix the source compatibility at Java 7 to keep open the possibility of
compiling for that target. After v2.7.2 is out, delete this assignment, and this comment,
reconsider choice of JARs, and feel free to use Java 8 syntax. -->
<property name="jdk.source.version" value="1.7" />
<!-- Designate the official release encoded in parts. In normal times, this is the *next*
official release, e.g. 2.7.2b2 while working towards 2.7.2b2, and sys.version will be
"2.7.2b2-DEV". To build that release, work in a clean checkout of the corresponding
tag. Until then sys.version will have a snapshot suffix (-DEV or -SNAPSHOT). You can
specify that suffix by -Dsnapshot.name on the ant command line. -->
<property name="jython.major_version" value="2"/>
<property name="jython.minor_version" value="7"/>
<property name="jython.micro_version" value="3"/>
<property name="jython.release_level" value="${PY_RELEASE_LEVEL_ALPHA}"/>
<!-- Zero at full release: one-up number for alpha, beta and candidate versions. -->
<property name="jython.release_serial" value="1"/>
</target>
<target name="common-constants">
<!-- Constants for relese levels (defined by Python) -->
<property name="PY_RELEASE_LEVEL_ALPHA" value="10"/> <!-- 0xA -->
<property name="PY_RELEASE_LEVEL_BETA" value="11"/> <!-- 0xB -->
<property name="PY_RELEASE_LEVEL_GAMMA" value="12"/> <!-- 0xC -->
<property name="PY_RELEASE_LEVEL_FINAL" value="15"/> <!-- 0xF -->
</target>
<target name="common-version-strings" depends="common-config">
<!-- Compose version strings we need, but not the "snapshot" suffix. -->
<property name="jython.version.short"
value="${jython.major_version}.${jython.minor_version}.${jython.micro_version}" />
<!-- The release level visible in the JAR needs a string form -->
<condition property="jython.release.str" value="a">
<equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_ALPHA}" />
</condition>
<condition property="jython.release.str" value="b">
<equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_BETA}" />
</condition>
<condition property="jython.release.str" value="rc" else="">
<equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_GAMMA}" />
</condition>
<!-- And the release serial too -->
<condition property="jython.release.num" value="" else="${jython.release_serial}">
<or>
<equals arg1="${jython.release_serial}" arg2="0" />
<equals arg1="${jython.release.str}" arg2="" />
</or>
</condition>
<!-- Finally the target version (last or next release) without snapshot suffix -->
<property name="jython.release"
value="${jython.version.short}${jython.release.str}${jython.release.num}" />
</target>
<target name="common-dirs">
<!-- There are several points of reference. The first is the base of the source code: -->
<property name="source.dir" value="${basedir}/src" />
<property name="templates.dir" value="${source.dir}/templates" />
<property name="templates.lazy" value="true" />
<property name="installer.src.dir" value="${basedir}/installer/src/java" />
<!-- The stdlib from CPython and JARs we import: -->
<property name="python.lib" value="${basedir}/lib-python/2.7" />
<property name="extlibs.dir" value="${basedir}/extlibs" />
<!-- Cache we need to clean (now it is not in dist.dir) -->
<property name="cache.dir" value="${basedir}/.jython_cache" />
<!-- Source specifically for test: -->
<property name="test.source.dir" value="${basedir}/tests/java" />
<property name="bugtests.dir" value="${basedir}/bugtests" />
<property name="test.shell.dir" value="${basedir}/tests/shell" />
<!-- Intermediate products including generated code and compiled classews go here: -->
<property name="build.dir" value="${basedir}/build" />
<property name="compile.dir" value="${build.dir}/classes" />
<property name="exposed.dir" value="${build.dir}/exposed" />
<property name="gensrc.dir" value="${build.dir}/gensrc" />
<!-- The distribution (mirroring the user's installation) is built here: -->
<property name="dist.dir" value="${basedir}/dist" />
<property name="apidoc.dir" value="${dist.dir}/Doc/javadoc" />
<!-- Test reports. -->
<property name="reports.dir" value="${basedir}/reports" />
<property name="junit.dir" value="${reports.dir}/junit" />
<property name="junit.reports" value="${junit.dir}/raw" />
<!-- Artefacts for publication. -->
<property name="pubs.dir" value="${basedir}/publications" />
</target>
<target name="common-jars" depends="common-dirs">
<!-- Names of JARs we (may) produce according to target. -->
<!-- Target: jar. Just the Jython code: needs main.classpath to work. For dev & test. -->
<property name="jython.dev.jar" value="jython-dev.jar" />
<!-- Target: jar-complete. jython.deploy.jar subsumes jython.dev.jar, and adds shaded
dependencies. For directory-based installations with a home, library, etc.. -->
<property name="jython.deploy.jar" value="jython.jar" />
<!-- Target: jar-standalone. jython.standalone.jar subsumes jython.deploy.jar, and
adds the Python library as a resource. A self-contained Python in a JAR. -->
<property name="jython.standalone.jar" value="jython-standalone.jar" />
<!-- Target: all-jars creates these and all the above JARs. -->
<property name="jython.javadoc.jar" value="javadoc.jar" />
<property name="jython.sources.jar" value="sources.jar" />
</target>
<target name="common-paths" depends="common-dirs">
<!-- ${informix.jar}, if defined, denotes a non-free JAR to be added to the class path. -->
<condition property="informix.present" else="false">
<and>
<isset property="informix.jar"/>
<available classname="com.informix.jdbc.IfxDriver"
classpath="${informix.jar}" />
</and>
</condition>
<!-- ${oracle.jar}, if defined, denotes a non-free JAR to be added to the class path. -->
<condition property="oracle.present" else="false">
<and>
<isset property="oracle.jar"/>
<available classname="oracle.jdbc.driver.OracleDriver"
classpath="${oracle.jar}" />
</and>
</condition>
<!-- classpaths -->
<local name="informix.location"/>
<condition property="informix.location" value="${informix.jar}" else="">
<istrue value="${informix.present}"/>
</condition>
<local name="oracle.location"/>
<condition property="oracle.location" value="${oracle.jar}" else="">
<istrue value="${oracle.present}"/>
</condition>
<path id="main.classpath">
<!-- The non-free database driver JARs, if not present. -->
<filelist files="${informix.location} ${oracle.location}" />
<!-- Further database and Java EE-related JARs -->
<filelist dir="${extlibs.dir}">
<file name="servlet-api-2.5.jar" />
<file name="mysql-connector-java-5.1.42-bin.jar" />
<file name="postgresql-42.1.1.jre7.jar" />
</filelist>
<!-- Other JARs (alphabetical) -->
<filelist dir="${extlibs.dir}">
<file name="antlr-complete-3.5.2.jar" /> <!-- ANTLR 3 until we upgrade parsing -->
<file name="asm-7.1.jar" />
<file name="asm-commons-7.1.jar" />
<file name="asm-util-7.1.jar" />
<file name="commons-compress-1.19.jar"/>
<file name="failureaccess-1.0.1.jar" />
<file name="guava-28.0-android.jar" />
<file name="icu4j-59_1.jar" />
<file name="jffi-1.2.20.jar"/>
<file name="java-sizeof-0.0.5.jar"/>
<file name="jnr-ffi-2.1.10.jar"/>
<file name="jnr-netdb-1.1.6.jar"/>
<file name="jnr-posix-3.0.50.jar"/>
<file name="jnr-constants-0.9.12.jar"/>
<file name="jline-2.14.5.jar"/>
<file name="netty-buffer-4.1.45.Final.jar"/>
<file name="netty-codec-4.1.45.Final.jar"/>
<file name="netty-common-4.1.45.Final.jar"/>
<file name="netty-handler-4.1.45.Final.jar"/>
<file name="netty-resolver-4.1.45.Final.jar"/>
<file name="netty-transport-4.1.45.Final.jar"/>
</filelist>
</path>
<path id="test.classpath">
<path refid="main.classpath"/>
<filelist dir="${extlibs.dir}">
<!-- Pin to 4.10 until dependency on hamcrest classes resolved. -->
<file name="junit-4.10.jar" />
</filelist>
<pathelement location="${exposed.dir}" />
<pathelement location="${compile.dir}" />
<pathelement location="${cpptasks.jar.dir}" />
</path>
</target>
<target name="init"
depends="developer-preinit, common-jars, common-paths, common-version-strings">
<!-- We can now compose the version as seen in sys.version and the installer -->
<property name="jython.version" value="${jython.release}${snapshot.suffix}" />
<!-- Build-time OS detection -->
<condition property="os.family.unix">
<os family="unix"/>
</condition>
<condition property="os.family.windows">
<os family="windows"/>
</condition>
<!-- Options we use when compiling (if not beaten to it: see *-preinit) -->
<property name="build.compiler" value="modern" />
<property name="jdk.target.version" value="${jython.java.version}" />
<property name="jdk.source.version" value="${jython.java.version}" />
<property name="deprecation" value="true" />
<property name="debug" value="true" />
<property name="nowarn" value="true" />
<property name="javac.Xlint" value="-Xlint -Xlint:-serial -Xlint:-unchecked -Xlint:-cast"/>
<!-- Options we use when building JARs (if not beaten to it: see *-preinit) -->
<property name="jar.update" value="true" />
</target>
<target name="developer-preinit">
<!-- This is invoked by init as its first dependency, which in turn is the first
dependency of many auxiliary targets. When the official "installer" or "full-build"
target is called, its specific installer-preinit or full-preinit will usually
have set the properties dealt with here. When, in the course of development, we
invoke various "unofficial" targets directly, this target acts as "developer-preinit".
-->
<!-- The suffix is "-" and the snapshot name, otherwise this is a developer build. -->
<condition property="snapshot.suffix" value="-${snapshot.name}" else="-DEV">
<isset property="snapshot.name"/>
</condition>
</target>
<target name="installer-preinit" depends="common-config">
<property name="snapshot.name" value="SNAPSHOT"/>
<property name="jar.update" value="true" />
<!-- Ensure we regenerate version.properties -->
<property name="brand-up-to-date" value="false" />
</target>
<target name="full-preinit" depends="common-config">
<!-- What is this? Why here in the full build only? -->
<property name="cpptasks.jar.dir" value="${basedir}/extlibs/cpptasks/cpptasks.jar" />
<property name="jar.update" value="false" />
<property name="brand-up-to-date" value="false" />
</target>
<target name="full-check" depends="full-preinit, force-snapshot-if-polluted, init, full-dump"
description="check the viability of a full build without running it" >
<!-- Require all of the optional jars for a full build -->
<fail unless="${informix.present}" message="informix jar not present" />
<fail unless="${oracle.present}" message="oracle jar not present" />
<!-- Require all git for a full build -->
<fail unless="${git.present}" message="A Git repository is required" />
</target>
<target name="dump-env" depends="init, dump"
description="dump the properties computed for a regular build without running it" />
<target name="dump" >
<echo>.</echo>
<echo>Build environment for ${ant.project.name}</echo>
<echo>(Note: if ${propertyname} is displayed, then the property is not set)</echo>
<echo>--- build Jython version ---</echo>
<echo>jython.version.short = '${jython.version.short}'</echo>
<echo>jython.release = '${jython.release}'</echo>
<echo>jython.version = '${jython.version}'</echo>
<echo>snapshot.name = '${snapshot.name}'</echo>
<echo>snapshot.suffix = '${snapshot.suffix}'</echo>
<echo>jython.dev.jar = '${jython.dev.jar}'</echo>
<echo>jython.deploy.jar = '${jython.deploy.jar}'</echo>
<echo>jython.standalone.jar = '${jython.standalone.jar}'</echo>
<echo>jython.javadoc.jar = '${jython.javadoc.jar}'</echo>
<echo>jython.sources.jar = '${jython.sources.jar}'</echo>
<echo>jar.update = '${jar.update}'</echo>
<echo>--- optional libraries ---</echo>
<echo>informix = '${informix.jar}'</echo>
<echo>informix.present = '${informix.present}'</echo>
<echo>oracle = '${oracle.jar}'</echo>
<echo>oracle.present = '${oracle.present}'</echo>
<echo>--- properties ---</echo>
<echo>basedir = '${basedir}'</echo>
<echo>source.dir = '${source.dir}'</echo>
<echo>build.dir = '${build.dir}'</echo>
<echo>compile.dir = '${compile.dir}'</echo>
<echo>exposed.dir = '${exposed.dir}'</echo>
<echo>gensrc.dir = '${gensrc.dir}'</echo>
<echo>dist.dir = '${dist.dir}'</echo>
<echo>apidoc.dir = '${apidoc.dir}'</echo>
<echo>templates.dir = '${templates.dir}'</echo>
<echo>templates.lazy = '${templates.lazy}'</echo>
<echo>python.lib = '${python.lib}'</echo>
<echo>--- compiler options ---</echo>
<echo>build.compiler = '${build.compiler}'</echo>
<echo>jdk.target.version = '${jdk.target.version}'</echo>
<echo>jdk.source.version = '${jdk.source.version}'</echo>
<echo>deprecation = '${deprecation}'</echo>
<echo>debug = '${debug}'</echo>
<echo>nowarn = '${nowarn}'</echo>
<echo>main.classpath = '${ant.refid:main.classpath}'</echo>
<echo>--- test config ---</echo>
<echo>test = '${test}'</echo>
<echo>test.source.dir = '${test.source.dir}'</echo>
<echo>reports.dir = '${reports.dir}'</echo>
<!-- <echo>test.classpath = '${ant.refid:test.classpath}'</echo> -->
</target>
<target name="full-dump"
depends="git-is-unmodified, git-is-clean, git-is-tagged, git-branch, dump" >
<echo>--- properties only used for a full-build ---</echo>
<echo>git.present = '${git.present}'</echo>
<echo>build.git.is_unmodified = '${build.git.is_unmodified}'</echo>
<echo>build.git.is_clean = '${build.git.is_clean}'</echo>
<echo>build.git.is_tagged = '${build.git.is_tagged}'</echo>
<echo>build.git.branch = '${build.git.branch}'</echo>
<echo>build.git.tag = '${build.git.tag}'</echo>
<echo>build.git.version = '${build.git.version}'</echo>
</target>
<!-- Delete all intermediate build products. Directories correspond to those bases defined in
common-dirs and built upon by the various targets as they are executed. -->
<target name="clean" depends="common-dirs, clean-test"
description="Delete contents of working directories">
<delete includeemptydirs="true" failonerror="false">
<!-- the package cache (now it is not in dist.dir). -->
<fileset dir="${cache.dir}" includes="**/*" erroronmissingdir="false" />
<!-- all files and subdirectories of ${build.dir}, without ${build.dir} itself. -->
<fileset dir="${build.dir}" includes="**/*" defaultexcludes="false" />
<!-- all files and subdirectories of ${dist.dir}, without ${dist.dir} itself. -->
<fileset dir="${dist.dir}" includes="**/*" defaultexcludes="false" />
<!-- all files and subdirectories of ${pubs.dir}, without ${pubs.dir} itself. -->
<fileset dir="${pubs.dir}" includes="**/*" erroronmissingdir="false" />
</delete>
</target>
<target name="devclean" depends="common-dirs, clean-test"
description="Delete contents of working directories preserving antlr, cachedir, and Lib">
<delete includeemptydirs="true" failonerror="false">
<!-- all files and subdirectories of ${build.dir}, without ${build.dir} itself. -->
<fileset dir="${build.dir}" includes="**/*" excludes="gensrc/**" />
<!-- all files and subdirectories of ${dist.dir}, without ${dist.dir} itself. -->
<fileset dir="${dist.dir}" includes="**/*" excludes="Lib/**" />
</delete>
</target>
<target name="force-snapshot-if-polluted" depends="git-is-unmodified, git-is-clean, git-is-tagged">
<!-- Ensure that a snapshot name is provided, if the workspace is not a pure checkout.
This only works before init is called, since it will set a value. -->
<!-- Check for conditions that will force us to a snapshot build. -->
<local name="diagnosis" />
<condition property="diagnosis"
value="The working directory is not a Git repository">
<not><istrue value="${git.present}"/></not>
</condition>
<condition property="build.git.status"
value="The git command failed (or is not on the path).">
<not><istrue value="${git.present}"/></not>
</condition>
<condition property="diagnosis"
value="Version-controlled files have been edited since the last commit">
<not><isset property="build.git.is_unmodified"/></not>
</condition>
<condition property="diagnosis"
value="Workspace contains uncontrolled files">
<not><isset property="build.git.is_clean"/></not>
</condition>
<condition property="diagnosis"
value="Change set ${build.git.version} is not tagged 'v${jython.release}'">
<not><isset property="build.git.is_tagged"/></not>
</condition>
<!-- If there was any kind of defect, make this a snapshot build. -->
<condition property="snapshot.name" value="SNAPSHOT">
<isset property="diagnosis"/>
</condition>
<!-- Now set the suffix as well, before init gets to try. (Our else is different.) -->
<condition property="snapshot.suffix" value="-${snapshot.name}" else="">
<isset property="snapshot.name"/>
</condition>
<!-- Produce a message about that. -->
<local name="message" />
<condition property="message"
value="${diagnosis} - build is a snapshot."
else ="Build is for release of ${jython.release}.">
<isset property="diagnosis"/>
</condition>
<echo>
${message}
${build.git.status}
</echo>
</target>
<target name="git-is-unmodified" depends="git-is-tagged" if="${git.present}">
<!-- If build.git.tag has no -dirty at the end, set build.git.is_unmodified -->
<condition property="build.git.is_unmodified">
<and>
<istrue value="${git.present}" />
<not><contains string="${build.git.tag}" substring="-dirty" /></not>
</and>
</condition>
</target>
<target name="git-is-clean" depends="git-present" if="${git.present}">
<!-- Set build.git.status, and if it lists no files, set build.git.is_clean -->
<exec executable="git" outputproperty="build.git.status">
<arg line="status --porcelain" />
</exec>
<!-- Check there are no extra files (except as per .gitignore) to catch in the build. -->
<condition property="build.git.is_clean">
<and>
<istrue value="${git.present}" />
<length string="${build.git.status}" trim="true" length="0" />
</and>
</condition>
</target>
<target name="git-is-tagged" depends="git-present, common-version-strings" if="${git.present}">
<!-- Set build.git.tag, and if it matches this version, set build.git.is_tagged -->
<exec executable="git" outputproperty="build.git.tag">
<arg line="describe --all --always --dirty"/>
</exec>
<!-- Check we are at a tag matching the release claimed in the configuration. -->
<condition property="build.git.is_tagged">
<and>
<istrue value="${git.present}" />
<equals arg1="${build.git.tag}" arg2="tags/v${jython.release}" />
</and>
</condition>
</target>
<target name="git-branch" depends="git-present" if="${git.present}">
<!-- Set build.git.branch. -->
<exec executable="git" outputproperty="build.git.branch">
<arg line="name-rev --name-only HEAD"/>
</exec>
</target>
<target name="git-present" depends="common-dirs">
<!-- Work out whether Git is available: the command and a repo. -->
<!-- Try using Git to set "build.git.version" as a test of availability,
as we need it anyway. This will fail if git is not on the path or
.git doesn't exist. -->
<local name="git_result" />
<local name="git_output" />
<exec executable="git" outputproperty="git_output"
failifexecutionfails="false" failonerror="false" resultproperty="git_result">
<arg line="rev-parse --short HEAD"/>
</exec>
<!-- Deduce presence of the git command and repo from how that execution went. -->
<condition property="git.present" else="false">
<and>
<isset property="git_output" />
<equals arg1="${git_result}" arg2="0" />
<available file="${basedir}/.git" type="dir" />
</and>
</condition>
<!-- And if both are present, the result provides the change set id. -->
<condition property="build.git.version" value="${git_output}">
<istrue value="${git.present}" />
</condition>
</target>
<target name="brand-up-to-date" depends="common-paths, git-is-unmodified">
<!-- Check freshness of generated version.properties file. -->
<condition property="brand-up-to-date" else="false">
<!-- The branding (version.properties) is adequately up to date if ... -->
<and>
<!-- The file exists (and we can't have edited the version info in build.xml). -->
<uptodate targetfile="${compile.dir}/org/python/version.properties">
<srcfiles file="build.xml" />
</uptodate>
<!-- *and* we have uncommited changes. This may sound backwards, but the idea is
that part-way through development, we'd rather not wait to regenerate the
file (and JAR), only when we reach the little rubicon of a commit. -->
<not><isset property="build.git.is_unmodified"/></not>
</and>
</condition>
</target>
<target name="brand-version-metadata"
depends="git-present, brand-up-to-date"
unless="${brand-up-to-date}"
if="${git.present}">
<!-- Get the git metadata (branch and tag) to update version.properties (see
brand-version"). We're lazy about this: we only do it if we need the information for
brand-version. -->
<exec executable="git" outputproperty="build.git.branch">
<arg line="name-rev --name-only HEAD"/>
</exec>
<exec executable="git" outputproperty="build.git.tag">
<arg line="describe --all --always --dirty"/>
</exec>
</target>
<target name="brand-version-nogit" depends="git-present" unless="${git.present}">
<!-- Substitute git metadata (branch and tag) to update version.properties. -->
<property name="build.git.branch" value="uncontrolled" />
<property name="build.git.version" value="uncontrolled" />
<property name="build.git.tag" value="-dirty" />
</target>
<target name="brand-version"
depends="brand-version-metadata, brand-version-nogit, init"
unless="${brand-up-to-date}">
<!-- Update version.properties, but only if something significant has changed. -->
<!-- These values are guaranteed by the dependencies, even if git is not installad or there
is no repo.-->
<echo>Writing git and build metadata to version.properties.</echo>
<echo>jython.version = ${jython.version}</echo>
<echo>build.git.branch = ${build.git.branch}</echo>
<echo>build.git.version = ${build.git.version}</echo>
<echo>build.git.tag = ${build.git.tag}</echo>
<tstamp>
<format property="build.date" pattern="MMM d yyyy" offset="0"/>
<format property="build.time" pattern="HH:mm:ss" offset="0"/>
</tstamp>
<mkdir dir="${compile.dir}/org/python"/>
<echo file="${compile.dir}/org/python/version.properties"># Jython version information
jython.version=${jython.version}
jython.major_version=${jython.major_version}
jython.minor_version=${jython.minor_version}
jython.micro_version=${jython.micro_version}
jython.release_level=${jython.release_level}
jython.release_serial=${jython.release_serial}
jython.build.date=${build.date}
jython.build.time=${build.time}
jython.build.git_branch=${build.git.branch}
jython.build.git_tag=${build.git.tag}
jython.build.git_version=${build.git.version}</echo>
</target>
<target name="brand-readme" depends="init">
<!-- Copy over README.txt and replace placeholders with information from the build. -->
<copy file="${basedir}/README.txt" todir="${dist.dir}" overwrite="true" />
<!-- An article and adjective to precede "release" to appear in README.txt -->
<local name="readme.release" />
<condition property="readme.release" value="an alpha">
<equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_ALPHA}" />
</condition>
<condition property="readme.release" value="a beta">
<equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_BETA}" />
</condition>
<condition property="readme.release" value="a candidate" else="a final">
<equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_GAMMA}" />
</condition>
<!-- README.txt contains this paragraph if this is a snapshot build. -->
<local name="snapshot.banner.active" />
<property name="snapshot.banner.active">
-------------------------------------------------------------------------
This is a snapshot build. It reflects the current development status.
The text for an official release would continue like ...
-------------------------------------------------------------------------
</property>
<!-- Change README.txt to replace placeholders with version-specific information. -->
<local name="snapshot.banner" />
<condition property="snapshot.banner" value="" else="${snapshot.banner.active}">
<equals arg1="${snapshot.suffix}" arg2="" />
</condition>
<replace file="${dist.dir}/README.txt" encoding="UTF-8">
<replacefilter token="@jython.version@" value="${jython.version}" />
<replacefilter token="@snapshot.banner@" value="${snapshot.banner}" />
<replacefilter token="@readme.release@" value="${readme.release}" />
<replacefilter token="@jython.version.short@" value="${jython.version.short}" />
<replacefilter token="@os.name@" value="${os.name}" />
<replacefilter token="@java.vendor@" value="${java.vendor}" />
<replacefilter token="@java.version@" value="${java.version}" />
<replacefilter token="@jdk.target.version@" value="${jdk.target.version}" />
</replace>
</target>
<target name="template-init" depends="init">
<javac srcdir="${source.dir}/"
destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
includeantruntime="false">
<include name="org/python/util/TemplateAntTask.java" />
<compilerarg line="${javac.Xlint}"/>
</javac>
</target>
<target name="template" depends="template-init">
<taskdef name="gentempl" classname="org.python.util.TemplateAntTask"
classpath="${compile.dir}" />
<gentempl srcdir="${templates.dir}" verbose="true" lazy="${templates.lazy}"/>
</target>
<target name="antlr-up-to-date" depends="common-paths">
<!-- Check freshness of generated parser & lexer files. -->
<uptodate property="antlr-up-to-date">
<!-- We don't check freshness of all generated files since they're made in a batch. -->
<srcfiles dir="${basedir}/grammar" includes="Python*.g" />
<globmapper from="*.g" to="${gensrc.dir}/org/python/antlr/*Parser.java" />
</uptodate>
</target>
<target name="antlr-gen" depends="common-paths, antlr-up-to-date" unless="antlr-up-to-date">
<local name="out" />
<property name="out" value="${gensrc.dir}/org/python/antlr" />
<mkdir dir="${out}" />
<java classname="org.antlr.Tool"
dir="${basedir}"
failonerror="true"
fork="true" >
<jvmarg value="-Xmx512m"/>
<jvmarg value="-Dfile.encoding=UTF-8"/>
<arg value="-Xconversiontimeout"/>
<arg value="2000"/>
<arg value="-fo"/>
<arg path="${out}"/>
<arg value="-lib"/>
<arg path="${out}"/>
<arg file="${basedir}/grammar/Python.g"/>
<arg file="${basedir}/grammar/PythonPartial.g"/>
<classpath refid="main.classpath"/>
</java>
<!-- copy the .tokens to /grammar, for usage in ANTLRWorks -->
<!--
<copy todir="grammar" preservelastmodified="true">
<fileset dir="build/gensrc/org/python/antlr">
<include name="Python.tokens" />
</fileset>
</copy>
-->
</target>
<target name="jarless" depends="compile, pycompile"/>
<target name="compile" depends="init, antlr-gen, brand-version">
<javac destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
includeantruntime="true"
memoryMaximumSize="1024m"
fork="true"
encoding="UTF-8">
<compilerarg line="${javac.Xlint}"/>
<src path="${source.dir}"/>
<src path="${gensrc.dir}"/>
<exclude name="**/handler/InformixDataHandler.java" unless="${informix.present}" />
<exclude name="**/handler/OracleDataHandler.java" unless="${oracle.present}" />
<classpath refid="main.classpath" />
</javac>
<javac srcdir="${basedir}/Lib"
includes="jxxload_help/**"
destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
includeantruntime="false">
<compilerarg line="${javac.Xlint}"/>
</javac>
<!-- java files used by tests -->
<javac srcdir="${test.source.dir}"
destdir="${compile.dir}"
target="${jdk.target.version}"
source="${jdk.source.version}"
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
includeantruntime="false"
encoding="UTF-8">
<compilerarg line="${javac.Xlint}"/>
<classpath refid="test.classpath" />
</javac>
<copy file="${source.dir}/org/python/modules/ucnhash.dat"
todir="${compile.dir}/org/python/modules"
preservelastmodified="true" />
<copy todir="${compile.dir}" preservelastmodified="true">
<fileset dir="${source.dir}">
<include name="**/*.properties" />
</fileset>
</copy>
<!-- grammar must now be up to date -->
<property name="antlr-up-to-date" value="true" />
<copy todir="${compile.dir}/META-INF/services">
<fileset dir="${source.dir}/META-INF/services" />
</copy>
</target>
<!--
If you run this before running regrtest, test__rawffi.py should pass.
So far I have been unable to enable cpptasks without passing an arg to ant.
To run this task like I am do:
ant -lib extlibs/cpptasks/cpptasks.jar compile_cpp
XXX: get cpptasks running without an arg to ant.
-->
<target name="compile_cpp" depends="compile">
<taskdef resource="cpptasks.tasks"/>
<cc outtype="shared" subsystem="console" outfile="ctypes_test" objdir="${compile.dir}">
<fileset dir="tests/c" includes="*.c"/>
</cc>
</target>
<target name="expose" depends="compile">
<taskdef name="expose" classname="org.python.expose.generate.ExposeTask">
<classpath>
<path refid="main.classpath" />
<pathelement path="${compile.dir}" />
</classpath>
</taskdef>
<mkdir dir="${exposed.dir}" />
<expose srcdir="${compile.dir}"
destdir="${exposed.dir}"
includesfile="${basedir}/CoreExposed.includes"/>
</target>
<target name="jar-complete" depends="jar, pycompile">
<taskdef name="jarjar" classname="org.pantsbuild.jarjar.JarJarTask">
<classpath>
<pathelement path="extlibs/jarjar-1.7.2.jar" />
<path refid="main.classpath" />
</classpath>
</taskdef>
<jarjar destfile="${dist.dir}/${jython.deploy.jar}" update="${jar.update}">
<zipfileset src="${dist.dir}/${jython.dev.jar}"/>
<!-- pin to Antlr 3 until we upgrade parsing -->
<zipfileset src="extlibs/antlr-runtime-3.5.2.jar"/>
<rule pattern="org.antlr.runtime.**" result="org.python.antlr.runtime.@1"/>
<zipfileset src="extlibs/asm-7.1.jar"/>
<zipfileset src="extlibs/asm-commons-7.1.jar"/>
<zipfileset src="extlibs/asm-util-7.1.jar"/>
<rule pattern="org.objectweb.asm.**" result="org.python.objectweb.asm.@1"/>
<zipfileset src="extlibs/bcpkix-jdk15on-1.62.jar" excludes="META-INF/**"/>
<rule pattern="org.bouncycastle.**" result="org.python.bouncycastle.@1"/>
<zipfileset src="extlibs/bcprov-jdk15on-1.62.jar" excludes="META-INF/**"/>
<rule pattern="org.bouncycastle.**" result="org.python.bouncycastle.@1"/>
<zipfileset src="extlibs/commons-compress-1.19.jar"/>
<rule pattern="org.apache.commons.compress.**" result="org.python.apache.commons.compress.@1"/>
<zipfileset src="extlibs/failureaccess-1.0.1.jar"/>
<zipfileset src="extlibs/guava-28.0-android.jar"/>
<rule pattern="com.google.**" result="org.python.google.@1"/>
<zipfileset src="extlibs/icu4j-59_1.jar"/>
<rule pattern="com.ibm.icu.**" result="org.python.icu.@1"/>
<zipfileset src="extlibs/netty-buffer-4.1.45.Final.jar" excludes="META-INF/**"/>
<rule pattern="io.netty.**" result="org.python.netty.@1"/>
<zipfileset src="extlibs/netty-codec-4.1.45.Final.jar" excludes="META-INF/**"/>
<rule pattern="io.netty.**" result="org.python.netty.@1"/>
<zipfileset src="extlibs/netty-common-4.1.45.Final.jar" excludes="META-INF/**"/>
<rule pattern="io.netty.**" result="org.python.netty.@1"/>
<zipfileset src="extlibs/netty-handler-4.1.45.Final.jar" excludes="META-INF/**"/>
<rule pattern="io.netty.**" result="org.python.netty.@1"/>
<zipfileset src="extlibs/netty-resolver-4.1.45.Final.jar" excludes="META-INF/**"/>
<rule pattern="io.netty.**" result="org.python.netty.@1"/>
<zipfileset src="extlibs/netty-transport-4.1.45.Final.jar" excludes="META-INF/**"/>
<rule pattern="io.netty.**" result="org.python.netty.@1"/>
<zipfileset src="${extlibs.dir}/java-sizeof-0.0.5.jar"/>
<rule pattern="com.carrotsearch.sizeof.**" result="org.python.sizeof.@1"/>
<!-- these stub jars are pre-built in https://github.com/jnr/jffi/tree/master/archive
and rarely if ever change -->
<zipfileset src="extlibs/jffi-aarch64-Linux.jar"/>
<zipfileset src="extlibs/jffi-arm-Linux.jar"/>
<zipfileset src="extlibs/jffi-Darwin.jar"/>
<zipfileset src="extlibs/jffi-i386-FreeBSD.jar"/>
<zipfileset src="extlibs/jffi-i386-Linux.jar"/>
<zipfileset src="extlibs/jffi-i386-OpenBSD.jar"/>
<zipfileset src="extlibs/jffi-i386-SunOS.jar"/>
<zipfileset src="extlibs/jffi-i386-Windows.jar"/>
<zipfileset src="extlibs/jffi-ppc64le-Linux.jar"/>
<zipfileset src="extlibs/jffi-ppc-AIX.jar"/>
<zipfileset src="extlibs/jffi-ppc-Linux.jar"/>
<zipfileset src="extlibs/jffi-ppc64-Linux.jar"/>
<zipfileset src="extlibs/jffi-s390x-Linux.jar"/>
<zipfileset src="extlibs/jffi-sparc-SunOS.jar"/>
<zipfileset src="extlibs/jffi-sparcv9-SunOS.jar"/>
<zipfileset src="extlibs/jffi-x86_64-FreeBSD.jar"/>
<zipfileset src="extlibs/jffi-x86_64-Linux.jar"/>
<zipfileset src="extlibs/jffi-x86_64-OpenBSD.jar"/>
<zipfileset src="extlibs/jffi-x86_64-SunOS.jar"/>
<zipfileset src="extlibs/jffi-x86_64-Windows.jar"/>
<!-- remainder of JNR, JFFI -->
<zipfileset src="extlibs/jffi-1.2.20.jar"/>
<zipfileset src="${extlibs.dir}/jnr-ffi-2.1.10.jar"/>
<zipfileset src="${extlibs.dir}/jnr-netdb-1.1.6.jar"/>
<zipfileset src="${extlibs.dir}/jnr-posix-3.0.50.jar"/>
<zipfileset src="${extlibs.dir}/jnr-constants-0.9.12.jar"/>
<zipfileset src="extlibs/xercesImpl-2.12.0.jar" excludes="META-INF/services/*"/>
<rule pattern="org.apache.xml.**" result="org.python.apache.xml.@1"/>
<rule pattern="org.apache.xerces.**" result="org.python.apache.xerces.@1"/>
<rule pattern="org.apache.wml.**" result="org.python.apache.wml.@1"/>
<rule pattern="org.apache.html.**" result="org.python.apache.html.@1"/>
<zipfileset src="extlibs/jline-2.14.5.jar"/>
<rule pattern="jline.**" result="org.python.jline.@1"/>
<manifest>
<attribute name="Main-Class" value="org.python.util.jython" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Implementation-Vendor" value="Python Software Foundation"/>
<attribute name="Implementation-Title" value="Jython fat jar"/>
<attribute name="Implementation-Version" value="${jython.version}"/>
<!-- info section. ATTN: no blanks, no '.' in the names -->
<section name="Build-Info">
<attribute name="version" value="${jython.version}" />
<attribute name="oracle" value="${oracle.present}" />
<attribute name="informix" value="${informix.present}" />
<attribute name="build-compiler" value="${build.compiler}" />
<attribute name="jdk-target-version" value="${jdk.target.version}" />
<attribute name="debug" value="${debug}" />
</section>
</manifest>
</jarjar>
</target>
<target name="jar-standalone" depends="jar-complete, copy-lib">
<jar destfile="${dist.dir}/${jython.standalone.jar}" update="${jar.update}">
<zipfileset src="${dist.dir}/${jython.deploy.jar}"/>
<fileset dir="${dist.dir}" includes="Lib/**" excludes="Lib/test/**" />
<manifest>
<attribute name="Main-Class" value="org.python.util.jython" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Implementation-Vendor" value="Python Software Foundation"/>
<attribute name="Implementation-Title" value="Jython fat jar with stdlib"/>
<attribute name="Implementation-Version" value="${jython.version}"/>
<!-- info section. ATTN: no blanks, no '.' in the names -->
<section name="Build-Info">
<attribute name="version" value="${jython.version}" />
<attribute name="git-build" value="${git.present}" />
<attribute name="oracle" value="${oracle.present}" />
<attribute name="informix" value="${informix.present}" />
<attribute name="build-compiler" value="${build.compiler}" />
<attribute name="jdk-target-version" value="${jdk.target.version}" />
<attribute name="debug" value="${debug}" />
</section>
</manifest>
<!-- FIXME: Because the standalone JAR may be distributed separately from the
installer JAR, it ought really to include necessary licences (Apache, etc.),
at least by reference.
-->
</jar>
</target>
<target name="jar" depends="compile, expose"
description="build the jython-dev.jar (requiring main classpath and Lib to use).">
<typedef name="nameunion" classname="org.python.util.NameUnionAntType">
<classpath>
<path refid="main.classpath" />
<pathelement path="${compile.dir}" />
</classpath>
</typedef>
<jar destfile="${dist.dir}/callbacker_test.jar" update="${jar.update}">
<fileset dir="${compile.dir}" includes="org/python/tests/Callbacker*"/>
</jar>
<jar destfile="${dist.dir}/${jython.dev.jar}" duplicate="fail" update="${jar.update}">
<!-- If only nameunion is used, ant issues a spurious warning about no files being
included. Use a fileset for version.properties just to shut that up. -->
<fileset dir="${compile.dir}" includes="org/python/version.properties"/>
<nameunion>
<fileset dir="${exposed.dir}"/>
<fileset dir="${compile.dir}"
excludes="org/python/expose/generate/**,org/python/version.properties"/>
</nameunion>
<manifest>
<attribute name="Main-Class" value="org.python.util.jython" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Implementation-Vendor" value="Python Software Foundation"/>
<attribute name="Implementation-Title" value="Jython"/>
<attribute name="Implementation-Version" value="${jython.version}"/>
<!-- info section. ATTN: no blanks, no '.' in the names -->
<section name="Build-Info">
<attribute name="version" value="${jython.version}" />
<attribute name="git-build" value="${git.present}" />
<attribute name="oracle" value="${oracle.present}" />
<attribute name="informix" value="${informix.present}" />
<attribute name="build-compiler" value="${build.compiler}" />
<attribute name="jdk-target-version" value="${jdk.target.version}" />
<attribute name="debug" value="${debug}" />
</section>
</manifest>
</jar>
</target>
<target name="javadoc" depends="compile">
<path id="javadoc.classpath">
<pathelement path="${java.class.path}" />
<pathelement path="${compile.dir}" />
<path refid="main.classpath" />
</path>
<mkdir dir="${apidoc.dir}" />
<javadoc sourcepath="${source.dir}"
destdir="${apidoc.dir}"
source="${jdk.source.version}"
encoding="UTF-8"