Repository navigation
Expand file tree
/
Copy pathbuild.xml
More file actions
946 lines (822 loc) · 27.1 KB
/
Copy pathbuild.xml
File metadata and controls
946 lines (822 loc) · 27.1 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
933
934
935
936
937
938
939
940
941
942
943
944
945
946
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2014-2017 Charles University in Prague
- Copyright 2014-2017 Vojtech Horky
-
- Licensed 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 basedir="." name="Microbenchmarking agent for Java" default="main" xmlns:if="ant:if" xmlns:unless="ant:unless">
<property file="local-settings.ini" />
<property environment="env" />
<property name="dist.name" value="ubench-agent" />
<property name="java.src.dir" value="src/java" />
<property name="agent.src.dir" value="src/c" />
<property name="barrier.src.dir" value="src/c-barrier" />
<property name="demo.src.dir" value="src/demo-java" />
<property name="java.test.src.dir" value="src/test-java" />
<property name="build.dir" location="out" />
<property name="classes.build.dir" location="${build.dir}/classes" />
<property name="demo.classes.build.dir" location="${build.dir}/demo-classes" />
<property name="test.classes.build.dir" location="${build.dir}/test-classes" />
<property name="test.results.dir" value="${build.dir}/test-results" />
<property name="agent.build.dir" location="${build.dir}/agent/" />
<property name="barrier.build.dir" location="${build.dir}/barrier/" />
<property name="lib.build.dir" location="${build.dir}/lib/" />
<property name="javadoc.build.dir" location="${build.dir}/javadoc/" />
<property name="junit.jar.path" value="lib/junit-4.11.jar" />
<property name="hamcrest.jar.path" value="lib/hamcrest-core.jar" />
<property name="agent.cc" value="gcc" />
<property name="agent.feature.want.papi" value="true" />
<antversion property="ant.version.bare" />
<!--
Determine features (capabilities) of the agent based
on available libraries or on which platform we are
operating.
-->
<condition property="agent.feature.has.papi">
<and>
<istrue value="${agent.feature.want.papi}" />
<os family="unix" />
<or>
<available file="libpapi.so" filepath="/usr/lib" />
<available file="libpapi.so" filepath="/usr/lib64" />
<available file="libpapi.so" filepath="/usr/lib/x86_64-linux-gnu" />
</or>
</and>
</condition>
<condition property="agent.feature.has.getrusage">
<os name="Linux" />
</condition>
<condition property="agent.feature.has.timespec">
<os family="unix" />
</condition>
<!-- Only MSVC on Windows -->
<condition property="agent.features.has.native.windows">
<and>
<os family="windows" />
<equals arg1="${agent.cc}" arg2="msvc" />
</and>
</condition>
<!--
Prepare some compiler/linker settings.
-->
<property name="agent.cc.warnings" value="diagnostic" />
<property name="agent.cc.extra.flags" value="" />
<!--
4100 - unreferenced formal parameter
4710 - function not inlined (had 'inline' directive)
4711 - function inlined (no 'inline' directive)
4820 - padding added
5045 - Spectre mitigation
-->
<property name="agent.cc.msvc.ignored.warnings" value="/wd4100 /wd4710 /wd4711 /wd4820 /wd5045" />
<!-- Helper properties to check for compiler -->
<condition property="agent.cc.is.gcc">
<equals arg1="${agent.cc}" arg2="gcc" />
</condition>
<condition property="agent.cc.is.msvc">
<equals arg1="${agent.cc}" arg2="msvc" />
</condition>
<!-- javah is deprecated since JDK 8 ... -->
<condition property="agent.generate.headers.javah">
<matches pattern="^1[.][678]" string="${java.version}" />
</condition>
<condition property="agent.generate.headers.javac">
<and>
<antversion atleast="1.10.2" />
<matches pattern="^(1[.]9)|9|([1-9][0-9])" string="${java.version}" />
</and>
</condition>
<condition property="agent.generate.headers.javac.manually">
<and>
<matches pattern="^(1[.]9)|9|(1[0-9])" string="${java.version}" />
<not>
<antversion atleast="1.10.2" />
</not>
</and>
</condition>
<!-- Agent file naming -->
<condition property="agent.filename" value="libubench-agent.so">
<and>
<os family="unix" />
<not>
<os name="Mac OS X"/>
</not>
</and>
</condition>
<condition property="agent.filename" value="libubench-agent.jnilib">
<and>
<os family="unix" />
<os name="Mac OS X"/>
</and>
</condition>
<condition property="agent.filename" value="ubench-agent.dll">
<os family="windows" />
</condition>
<property name="agent.path"
location="${agent.build.dir}${file.separator}${agent.filename}" />
<!-- JVM arguments for loading the agent library. -->
<property name="agent.jvmarg.agent" value="-agentpath:${agent.path}" />
<property name="agent.jvmarg.library" value="-Djava.library.path=${agent.build.dir}" />
<property name="agent.jvmarg.default" value="${agent.jvmarg.agent}" />
<!-- Barrier file naming -->
<condition property="barrier.filename" value="ubench-barrier">
<os family="unix" />
</condition>
<condition property="barrier.filename" value="ubench-barrier.exe">
<os family="windows" />
</condition>
<property name="barrier.path"
location="${barrier.build.dir}${file.separator}${barrier.filename}" />
<!-- Java include paths -->
<pathconvert property="agent.cc.java.jni.h.path" setonempty="false">
<!--
Try to find jni.h in known locations.
We first try $JAVA_HOME (%JAVA_HOME%) if set (that
should take care of custom locations or when the
user wants to compile with a specific version of JDK).
Then we try ${java.home} that usually points to JRE
that could be inside JDK. After that, we go through
list of typical locations in various distributions.
If your distribution uses different location, feel
free to add it here (but preferably only directories
without build versions, such as/usr/java/jdk1.7 but
not /usr/java/jdk1.7.0_55/).
If you have a custom location, use local-settings.ini
to specify the exact path as a value of the
agent.cc.java.include property.
-->
<first>
<restrict>
<exists />
<union>
<filelist dir="${env.JAVA_HOME}${file.separator}include" files="jni.h" />
<filelist dir="${java.home}${file.separator}..${file.separator}include" files="jni.h" />
<filelist dir="/usr/lib/jvm/default/include/" files="jni.h" />
<filelist dir="/usr/lib/jvm/java/include" files="jni.h" />
<filelist dir="/usr/java/default/include" files="jni.h" />
<filelist dir="/usr/java/latest/include" files="jni.h" />
</union>
</restrict>
</first>
</pathconvert>
<fail unless="agent.cc.java.jni.h.path"
message="Failed to locate JDK directory with C headers (set JAVA_HOME)."/>
<dirname property="agent.cc.java.include"
file="${agent.cc.java.jni.h.path}" />
<condition property="agent.cc.java.os.include"
value="${agent.cc.java.include}${file.separator}linux">
<os name="Linux" />
</condition>
<condition property="agent.cc.java.os.include"
value="${agent.cc.java.include}${file.separator}win32">
<os family="windows" />
</condition>
<condition property="agent.cc.java.os.include"
value="${agent.cc.java.include}${file.separator}darwin">
<os family="mac" />
</condition>
<!-- PAPI support and other has.* settings -->
<condition property="agent.link.papi" value="-lpapi" else="">
<isset property="agent.feature.has.papi" />
</condition>
<condition property="agent.cc.papi" value="-DHAS_PAPI" else="">
<isset property="agent.feature.has.papi" />
</condition>
<condition property="agent.cc.getrusage" value="-DHAS_GETRUSAGE" else="">
<isset property="agent.feature.has.getrusage" />
</condition>
<condition property="agent.cc.timespec" value="-DHAS_TIMESPEC" else="">
<isset property="agent.feature.has.timespec" />
</condition>
<condition property="agent.link.librt" value="-lrt" else="">
<os name="Linux" />
</condition>
<condition property="agent.cc.native.windows" value="-DHAS_QUERY_PERFORMANCE_COUNTER -DHAS_GET_THREAD_TIMES" else="">
<isset property="agent.features.has.native.windows" />
</condition>
<!-- Warning-related compiler flags for GCC -->
<condition property="agent.gcc.warn.flags" value="-Wall -Wextra -Wno-unknown-pragmas">
<equals arg1="${agent.cc.warnings}" arg2="diagnostic" />
</condition>
<condition property="agent.gcc.warn.flags" value="-Wall -Wno-unknown-pragmas">
<equals arg1="${agent.cc.warnings}" arg2="default" />
</condition>
<condition property="agent.gcc.warn.flags" value="-Wall -Wextra -Werror -Wno-unknown-pragmas">
<equals arg1="${agent.cc.warnings}" arg2="aserror" />
</condition>
<property name="agent.gcc.warn.flags" value="" />
<!-- Warning-related compiler flags for MSVC -->
<condition property="agent.msvc.warn.flags" value="/Wall ${agent.cc.msvc.ignored.warnings}">
<equals arg1="${agent.cc.warnings}" arg2="diagnostic" />
</condition>
<condition property="agent.msvc.warn.flags" value="/W3">
<equals arg1="${agent.cc.warnings}" arg2="default" />
</condition>
<condition property="agent.msvc.warn.flags" value="/Wall /WX ${agent.cc.msvc.ignored.warnings}">
<equals arg1="${agent.cc.warnings}" arg2="aserror" />
</condition>
<property name="agent.msvc.warn.flags" value="" />
<!-- Determine when agent recompilation is necessary for GCC -->
<condition property="agent.gcc.recompilation.necessary">
<or>
<and>
<isset property="agent.cc.is.gcc" />
<not><and>
<uptodate targetfile="${agent.path}">
<srcfiles
dir="${agent.build.dir}"
includes="*.o"
/>
</uptodate>
<uptodate>
<srcfiles
dir="${agent.src.dir}"
includes="*.c"
/>
<mapper type="glob"
from="*.c"
to="${agent.build.dir}${file.separator}*.o" />
</uptodate>
</and></not>
</and>
<contains
string="${ant.project.invoked-targets}"
substring="clean"
/>
</or>
</condition>
<!-- Determine when agent recompilation is necessary for MSVC -->
<condition property="agent.msvc.recompilation.necessary">
<or>
<and>
<isset property="agent.cc.is.msvc" />
<not><and>
<uptodate targetfile="${agent.path}">
<srcfiles
dir="${agent.build.dir}"
includes="*.obj"
/>
</uptodate>
<uptodate>
<srcfiles
dir="${agent.src.dir}"
includes="*.c"
/>
<mapper type="glob"
from="*.c"
to="${agent.build.dir}${file.separator}*.obj" />
</uptodate>
</and></not>
</and>
<contains
string="${ant.project.invoked-targets}"
substring="clean"
/>
</or>
</condition>
<!-- Determine when barrier recompilation is necessary for GCC -->
<condition property="barrier.gcc.recompilation.necessary">
<or>
<and>
<isset property="agent.cc.is.gcc" />
<not><and>
<uptodate targetfile="${barrier.path}">
<srcfiles
dir="${barrier.build.dir}"
includes="*.o"
/>
</uptodate>
<uptodate>
<srcfiles
dir="${barrier.src.dir}"
includes="*.c"
/>
<mapper type="glob"
from="*.c"
to="${barrier.build.dir}${file.separator}*.o"
/>
</uptodate>
</and></not>
</and>
<contains
string="${ant.project.invoked-targets}"
substring="clean"
/>
</or>
</condition>
<target name="print-config"
description="Print current configuration (include paths, compiler, ...)."
>
<echo message=" OS: ${os.name} ${os.version} (${os.arch})" />
<echo message=" Used Java version: ${ant.java.version}" />
<echo message=" JRE version: ${java.version}" />
<echo message=" Ant version: ${ant.version.bare}" />
<echo message=" JNI headers via: javah task" if:set="agent.generate.headers.javah" />
<echo message=" JNI headers via: javac task" if:set="agent.generate.headers.javac" />
<echo message=" JNI headers via: javac executable" if:set="agent.generate.headers.javac.manually" />
<echo message=" Java C headers in: ${agent.cc.java.include}" />
<echo message=" Used C compiler: ${agent.cc}" />
<echo message="C compiler warnings: ${agent.cc.warnings}" />
<echo message=" Agent library name: ${agent.filename}" />
<echo message=" PAPI support: on" if:set="agent.feature.has.papi" />
<echo message=" PAPI support: off" unless:set="agent.feature.has.papi" />
<echo message=" getrusage support: on" if:set="agent.feature.has.getrusage" />
<echo message=" getrusage support: off" unless:set="agent.feature.has.getrusage" />
</target>
<target name="print-properties">
<echoproperties format="text" />
</target>
<target name="main"
depends="compile"
description="Default target: compile everything."
/>
<target name="gate" description="Gate: check everything.">
<antcall target="clean" />
<antcall target="print-properties" />
<antcall target="print-config" />
<antcall target="compile" />
<antcall target="test">
<param name="agent.jvmarg" value="${agent.jvmarg.agent}" />
</antcall>
<antcall target="test">
<param name="agent.jvmarg" value="${agent.jvmarg.library}" />
</antcall>
<antcall target="test-junit">
<param name="agent.jvmarg" value="${agent.jvmarg.agent}" />
</antcall>
<antcall target="test-junit">
<param name="agent.jvmarg" value="${agent.jvmarg.library}" />
</antcall>
<antcall target="list-events">
<param name="agent.jvmarg" value="${agent.jvmarg.agent}" />
</antcall>
<antcall target="list-events">
<param name="agent.jvmarg" value="${agent.jvmarg.library}" />
</antcall>
<antcall target="demo">
<param name="agent.jvmarg" value="${agent.jvmarg.agent}" />
</antcall>
<antcall target="demo">
<param name="agent.jvmarg" value="${agent.jvmarg.library}" />
</antcall>
<antcall target="lib" />
<antcall target="checkstyle" />
<antcall target="javadoc" />
<antcall target="dist" />
</target>
<target name="compile"
depends="compile-java,compile-agent,compile-barrier"
description="Compile everything."
/>
<target name="compile-java"
description="Compile Java sources."
>
<mkdir dir="${classes.build.dir}" />
<javac
destdir="${classes.build.dir}"
debug="true"
includeantruntime="false"
>
<src path="${java.src.dir}" />
<compilerarg value="-Xlint:all"/>
</javac>
</target>
<target name="compile-agent"
depends="compile-agent-maybe-gcc,compile-agent-maybe-msvc"
description="Compile the C agent."
/>
<macrodef name="compile-header">
<attribute name="classname" />
<sequential>
<javah if:set="agent.generate.headers.javah"
destdir="${agent.build.dir}"
verbose="true"
classpath="${classes.build.dir}">
<class name="cz.cuni.mff.d3s.perf.@{classname}" />
</javah>
<javac if:set="agent.generate.headers.javac"
nativeheaderdir="${agent.build.dir}"
destdir="${classes.build.dir}"
includeantruntime="false"
srcdir="${java.src.dir}/cz/cuni/mff/d3s/perf/"
includes="@{classname}.java">
<classpath>
<pathelement path="${classes.build.dir}" />
</classpath>
</javac>
<exec if:set="agent.generate.headers.javac.manually"
executable="javac">
<arg value="-cp" />
<arg file="${classes.build.dir}"/>
<arg value="-d"/>
<arg file="${classes.build.dir}"/>
<arg value="-h"/>
<arg file="${agent.build.dir}"/>
<arg file="${java.src.dir}/cz/cuni/mff/d3s/perf/@{classname}.java" />
</exec>
</sequential>
</macrodef>
<target name="compile-agent-prepare-headers"
depends="compile-java"
description="Generate JNI headers."
>
<mkdir dir="${agent.build.dir}" />
<compile-header classname="Barrier" />
<compile-header classname="CompilationCounter" />
<compile-header classname="OverheadEstimations" />
<compile-header classname="Measurement" />
<compile-header classname="NativeThreads" />
<compile-header classname="UbenchAgent" />
</target>
<target name="compile-agent-maybe-gcc" if="agent.cc.is.gcc">
<antcall target="compile-agent-gcc" />
</target>
<target name="compile-agent-gcc"
depends="compile-agent-prepare-headers"
if="agent.gcc.recompilation.necessary"
>
<echo level="info" message="[run] Running gcc on *.c" />
<apply
executable="${agent.cc}"
failonerror="true"
dest="${agent.build.dir}"
parallel="false"
verbose="true"
>
<arg value="-c" />
<arg value="-I${agent.build.dir}" />
<arg value="-I${agent.cc.java.include}" />
<arg value="-I${agent.cc.java.os.include}" />
<arg value="-fPIC" />
<arg value="-pthread" />
<arg value="-O3" />
<arg value="-std=gnu99" />
<arg line="${agent.cc.papi}" />
<arg line="${agent.cc.getrusage}" />
<arg line="${agent.cc.timespec}" />
<arg line="${agent.gcc.warn.flags}" />
<arg line="${agent.cc.extra.flags}" />
<arg value="-o"/>
<targetfile />
<srcfile />
<fileset dir="${agent.src.dir}" includes="*.c" />
<mapper type="glob" from="*.c" to="*.o" />
</apply>
<echo level="info" message="[run] Running gcc on *.o" />
<apply
executable="${agent.cc}"
failonerror="true"
parallel="true"
verbose="true"
>
<arg value="-shared" />
<arg value="-pthread" />
<arg value="-fPIC" />
<arg value="-o" />
<arg file="${agent.path}" />
<srcfile />
<arg line="${agent.link.papi}" />
<arg line="${agent.link.librt}" />
<fileset dir="${agent.build.dir}" includes="*.o" />
</apply>
</target>
<target name="compile-agent-maybe-msvc" if="agent.cc.is.msvc">
<antcall target="compile-agent-msvc" />
</target>
<target name="compile-agent-msvc"
depends="compile-agent-prepare-headers"
if="agent.msvc.recompilation.necessary"
>
<echo level="info" message="[run] Running cl.exe on *.c" />
<apply
executable="cl.exe"
failonerror="true"
dest="${agent.build.dir}"
parallel="false"
verbose="true"
>
<arg value="/c" />
<arg value="/I${agent.build.dir}" />
<arg value="/I${agent.cc.java.include}" />
<arg value="/I${agent.cc.java.os.include}" />
<arg value="/O2" />
<arg line="${agent.cc.extra.flags}" />
<arg line="${agent.msvc.warn.flags}" />
<arg line="${agent.cc.native.windows}" />
<arg value="/Fo${agent.build.dir}${file.separator}"/>
<arg value="/TC" />
<srcfile />
<fileset dir="${agent.src.dir}" includes="*.c" />
<mapper type="glob" from="*.c" to="*.obj" />
</apply>
<echo level="info" message="[run] Running link.exe on *.obj" />
<apply
executable="link.exe"
failonerror="true"
parallel="true"
verbose="true"
>
<arg value="/DLL" />
<arg value="/OUT:${agent.path}" />
<srcfile />
<fileset dir="${agent.build.dir}" includes="*.obj" />
</apply>
</target>
<target name="compile-barrier"
depends="compile-barrier-maybe-gcc"
description="Compile the barrier initialization tool."
/>
<target name="compile-barrier-maybe-gcc" if="agent.cc.is.gcc">
<antcall target="compile-barrier-gcc" />
</target>
<target name="compile-barrier-gcc"
if="barrier.gcc.recompilation.necessary"
>
<mkdir dir="${barrier.build.dir}" />
<apply
executable="${agent.cc}"
failonerror="true"
dest="${barrier.build.dir}"
parallel="false"
verbose="true"
>
<arg value="-c" />
<arg value="-pthread" />
<arg value="-std=gnu99" />
<arg line="${agent.gcc.warn.flags}" />
<arg value="-o"/>
<targetfile />
<srcfile />
<fileset dir="${barrier.src.dir}" includes="*.c" />
<mapper type="glob" from="*.c" to="*.o" />
</apply>
<apply
executable="${agent.cc}"
failonerror="true"
parallel="true"
verbose="true"
>
<arg value="-pthread" />
<arg value="-o" />
<arg file="${barrier.path}" />
<srcfile />
<arg line="${agent.link.librt}" />
<fileset dir="${barrier.build.dir}" includes="*.o" />
</apply>
</target>
<target name="lib"
description="Create the library, that is JAR and C-agent."
depends="compile"
>
<mkdir dir="${lib.build.dir}" />
<jar
destfile="${lib.build.dir}${file.separator}ubench-agent.jar"
basedir="${classes.build.dir}"
/>
<copy file="${agent.path}" todir="${lib.build.dir}" />
<!-- Barrier not compiled on Windows -->
<copy file="${barrier.path}" todir="${lib.build.dir}" failonerror="false" />
<!-- Because copy task ignores file mode -->
<chmod perm="+x">
<fileset dir="${lib.build.dir}">
<exclude name="*.jar" />
</fileset>
</chmod>
</target>
<target name="compile-demo"
description="Compile all the demo code."
depends="compile"
>
<mkdir dir="${demo.classes.build.dir}" />
<javac
destdir="${demo.classes.build.dir}"
debug="true"
includeantruntime="false"
>
<src path="${demo.src.dir}" />
<classpath>
<pathelement path="${classes.build.dir}" />
</classpath>
<compilerarg value="-Xlint:all"/>
</javac>
</target>
<target name="compile-test"
description="Compile all the test code."
depends="compile"
>
<mkdir dir="${test.classes.build.dir}" />
<javac
destdir="${test.classes.build.dir}"
debug="true"
includeantruntime="false"
>
<src path="${java.test.src.dir}" />
<classpath>
<pathelement path="${classes.build.dir}" />
<pathelement path="${junit.jar.path}" />
<pathelement path="${hamcrest.jar.path}" />
</classpath>
<compilerarg value="-Xlint:all"/>
</javac>
</target>
<macrodef name="self-test">
<attribute name="classname" default="mixed" />
<attribute name="jvmarg" default="-Xmixed" />
<attribute name="progarg" default="mixed" />
<sequential>
<fail unless="agent.jvmarg" message="The 'agent.jvmarg' property is not set, cannot load agent library!" />
<echo level="info" message="[run] java ${agent.jvmarg} @{jvmarg} @{classname} @{progarg}" />
<java
classname="@{classname}"
fork="true"
failonerror="true"
>
<classpath>
<pathelement path="${classes.build.dir}" />
<pathelement path="${test.classes.build.dir}" />
</classpath>
<jvmarg value="${agent.jvmarg}" />
<jvmarg value="@{jvmarg}" />
<arg value="@{progarg}" />
</java>
</sequential>
</macrodef>
<target name="test"
depends="compile,compile-test"
description="Run simple self-tests (obsoleted)."
>
<!-- Use default JVM arguments to load the agent (unless overriden from outside). -->
<property name="agent.jvmarg" value="${agent.jvmarg.default}" />
<echo level="info" message="Agent loaded using ${agent.jvmarg}" />
<self-test
classname="cz.cuni.mff.d3s.perf.CompilationCounterTest"
jvmarg="-Xmixed"
progarg="mixed"
/>
<self-test
classname="cz.cuni.mff.d3s.perf.CompilationCounterTest"
jvmarg="-Xint"
progarg="int"
/>
<self-test
classname="cz.cuni.mff.d3s.perf.BenchmarkTest"
/>
<self-test
classname="cz.cuni.mff.d3s.perf.ThreadTimeTest"
progarg="4"
/>
<self-test
classname="cz.cuni.mff.d3s.perf.MeasurementSamplingTest"
/>
<echo level="info" message="All tests passed." />
</target>
<target name="test-junit"
depends="compile,compile-test"
description="Run JUnit tests, generate HTML report."
>
<!-- Use default JVM arguments to load the agent (unless overriden from outside). -->
<property name="agent.jvmarg" value="${agent.jvmarg.default}" />
<echo level="info" message="Agent loaded using ${agent.jvmarg}" />
<mkdir dir="${test.results.dir}"/>
<junit printsummary="no" failureproperty="junit.failed" haltonfailure="no">
<classpath>
<pathelement path="${junit.jar.path}" />
<pathelement path="${hamcrest.jar.path}" />
<pathelement path="${test.classes.build.dir}" />
<pathelement path="${classes.build.dir}" />
</classpath>
<jvmarg value="-Dubench.classpath=${test.classes.build.dir}${path.separator}${classes.build.dir}" />
<jvmarg value="-Dubench.agent=${agent.path}" />
<jvmarg value="${agent.jvmarg}" />
<assertions>
<enable/>
</assertions>
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${test.results.dir}">
<fileset dir="${test.classes.build.dir}">
<include name="**/*Test.class" />
<exclude name="${test.classes.excluded}" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.results.dir}">
<fileset dir="${test.results.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${test.results.dir}/html" />
</junitreport>
<fail message="JUnit test(s) failed." if="junit.failed" />
</target>
<target name="demo"
depends="compile,compile-demo"
description="Run simple demo (measure md5 speed)."
>
<!-- Use default JVM arguments to load the agent (unless overriden from outside). -->
<property name="agent.jvmarg" value="${agent.jvmarg.default}" />
<echo level="info" message="Agent loaded using ${agent.jvmarg}" />
<java
classname="cz.cuni.mff.d3s.perf.demo.MeasureHashing"
fork="true"
failonerror="true"
>
<classpath>
<pathelement path="${classes.build.dir}" />
<pathelement path="${demo.classes.build.dir}" />
</classpath>
<jvmarg value="${agent.jvmarg}" />
<arg value="build.xml" />
</java>
</target>
<target name="list-events"
depends="compile-demo"
description="List available events."
>
<!-- Use default JVM arguments to load the agent (unless overriden from outside). -->
<property name="agent.jvmarg" value="${agent.jvmarg.default}" />
<echo level="info" message="Agent loaded using ${agent.jvmarg}" />
<java
classname="cz.cuni.mff.d3s.perf.demo.ListEvents"
fork="true"
failonerror="true"
>
<classpath>
<pathelement path="${classes.build.dir}" />
<pathelement path="${demo.classes.build.dir}" />
</classpath>
<jvmarg value="${agent.jvmarg}" />
</java>
</target>
<target name="dist"
description="Create distributable ZIP with all sources."
>
<mkdir dir="${build.dir}" />
<zip destfile="${build.dir}/${dist.name}.zip">
<zipfileset dir="src" prefix="${dist.name}/src" />
<zipfileset dir="lib" prefix="${dist.name}/lib" />
<zipfileset file="build.xml" prefix="${dist.name}/" />
<zipfileset file="LICENSE.txt" prefix="${dist.name}/" />
<zipfileset file="README.md" prefix="${dist.name}/" />
</zip>
</target>
<target name="javadoc">
<mkdir dir="${javadoc.build.dir}" />
<javadoc
destdir="${javadoc.build.dir}"
author="true"
version="true"
use="true"
overview="${java.src.dir}/overview.html"
windowtitle="${ant.project.name}"
>
<packageset
dir="${java.src.dir}"
defaultexcludes="yes" />
<arg value="-Xdoclint:none" />
</javadoc>
</target>
<target name="javadoc-make-overview">
<echo
append="false"
file="${java.src.dir}/overview.html"
message="<html><head><title>${ant.project.name}</title></head><body>${line.separator}"
/>
<exec
executable="pandoc"
output="${java.src.dir}/overview.html"
input="README.md"
append="true"
>
<arg value="--no-highlight" />
</exec>
<echo
append="true"
file="${java.src.dir}/overview.html"
message="${line.separator}</body></html>${line.separator}"
/>
</target>
<target name="checkstyle">
<java jar="lib/checkstyle-9.3-all.jar" fork="true">
<arg value="-c" />
<arg file="checkstyle.xml" />
<arg file="src/java" />
</java>
</target>
<target name="clean"
description="Remove generated files."
>
<delete dir="${classes.build.dir}" />
<delete dir="${build.dir}" />
</target>
</project>