-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
4480 lines (3846 loc) · 184 KB
/
build.gradle
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
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The main build script for JavaFX.
*
* MUST FIX tasks to complete:
* - build check -- making sure the final artifact has the right bits
* - some things worth automatically sanity checking:
* - are there images in the javadocs?
* - are all of the expected dylibs etc there?
* - Perform sanity checking to make sure a JDK exists with javac, javah, etc
* - Support building with no known JDK location, as long as javac, javah, etc are on the path
* - Check all of the native flags. We're adding weight to some libs that don't need it, and so forth.
*
* Additional projects to work on as we go:
* - Add "developer debug". This is where the natives do not have debug symbols, but the Java code does
* - The genVSproperties.bat doesn't find the directory where RC.exe lives. So it is hard coded. Might be a problem.
* - special tasks for common needs, such as:
* - updating copyright headers
* - stripping trailing whitespace (?)
* - checkstyle
* - findbugs
* - re needs?
* - sqe testing
* - API change check
* - Pushing results to a repo?
* - ServiceWithSecurityManagerTest fails to complete when run from gradle.
* - Integrate Parfait reports for C code
* - FXML Project tests are not running
*/
defaultTasks = ["sdk"]
import java.util.concurrent.CountDownLatch
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.Future
/******************************************************************************
* Utility methods *
*****************************************************************************/
/**
* If the given named property is not defined, then this method will define
* it with the given defaultValue. Any properties defined by this method can
* be substituted on the command line by using -P, or by specifying a
* gradle.properties file in the user home dir
*
* @param name The name of the property to define
* @param defaultValue The default value to assign the property
*/
void defineProperty(String name, String defaultValue) {
if (!project.hasProperty(name)) {
project.ext.set(name, defaultValue);
}
}
/**
* If the given named property is not defined, then this method will attempt to
* look up the property in the props map, and use the defaultValue if it cannot be found.
*
* @param name The name of the property to look up and/or define
* @param props The properties to look for the named property in, if it has not already been defined
* @param defaultValue The default value if the property has not been defined and the
* props map does not contain the named property
*/
void defineProperty(String name, Properties props, String defaultValue) {
if (!project.hasProperty(name)) {
project.ext.set(name, props.getProperty(name, defaultValue));
}
}
/**
* Converts cygwin style paths to windows style paths, but with a forward slash.
* This method is safe to call from any platform, and will only do work if
* called on Windows (in all other cases it simply returns the supplied path.
*
* @param path the path to convert
* @return the path converted to windows style, if on windows, otherwise it
* is the supplied path.
*/
String cygpath(String path) {
if (!IS_WINDOWS) return path;
if (path == null || "".equals(path)) return path;
String ret = path.replaceAll('\\\\', '/')
logger.info("Converting path '$path' via cygpath to "+ret)
return ret
}
void loadProperties(String sourceFileName) {
def config = new Properties()
def propFile = new File(sourceFileName)
if (propFile.canRead()) {
config.load(new FileInputStream(propFile))
for (java.util.Map.Entry property in config) {
def keySplit = property.key.split("\\.");
def key = keySplit[0];
for (int i = 1; i < keySplit.length; i++) {
key = key + keySplit[i].capitalize();
}
ext[key] = property.value;
}
}
}
/**
* Struct used to contain some information passed to the closure
* passed to compileTargets.
*/
class CompileTarget {
String name;
String upper;
String capital;
}
/**
* Iterates over each of the compile targets, passing the given closure
* a CompileTarget instance.
*
* @param c The closure to call
*/
void compileTargets(Closure c) {
if (COMPILE_TARGETS == "") {
return
}
COMPILE_TARGETS.split(",").each { target ->
CompileTarget ct = new CompileTarget();
ct.name = target;
ct.upper = target.trim().toUpperCase(Locale.ROOT)
ct.capital = target.trim().capitalize()
c(ct)
}
}
/**
* Manages the execution of some closure which is responsible for producing
* content for a properties file built at build time and stored in the
* root project's $buildDir, and then loading that properties file and
* passing it to the processor closure.
*
* This is used on windows to produce a properties file containing all the
* windows visual studio paths and environment variables, and on Linux
* for storing the results of pkg-config calls.
*
* @param name the name of the file to produce
* @param loader a closure which is invoked, given the properties file. This
* closure is invoked only if the properties file needs to be created
* and is responsible for populating the properties file.
* @param processor a closure which is invoked every time this method is
* called and which will be given a Properties object, fully populated.
* The processor is then responsible for doing whatever it is that it
* must do with those properties (such as setting up environment
* variables used in subsequent native builds, or whatnot).
*/
void setupTools(String name, Closure loader, Closure processor) {
// Check to see whether $buildDir/$name.properties file exists. If not,
// then generate it. Once generated, we need to read the properties file to
// help us define the defaults for this block of properties
File propFile = file("$buildDir/${name}.properties");
if (!propFile.exists()) {
// Create the properties file
propFile.getParentFile().mkdirs();
propFile.createNewFile();
loader(propFile);
}
// Try reading the properties in order to define the properties. If the property file cannot
// be located, then we will throw an exception because we cannot guess these values
InputStream propStream = null;
try {
Properties properties = new Properties();
propStream = new FileInputStream(propFile);
properties.load(propStream);
processor(properties);
} finally {
try { propStream.close() } catch (Exception e) { }
}
}
String[] parseJavaVersion(String jRuntimeVersion) {
def jVersion = jRuntimeVersion.split("[-\\+]")[0]
def tmpBuildNumber = "0"
if (jVersion.startsWith("1.")) {
// This is a pre-JEP-223 version string
def dashbIdx = jRuntimeVersion.lastIndexOf("-b")
if (dashbIdx != -1) {
tmpBuildNumber = jRuntimeVersion.substring(dashbIdx + 2)
}
} else {
// This is a post-JEP-223 version string
def plusIdx = jRuntimeVersion.indexOf("+")
if (plusIdx != -1) {
tmpBuildNumber = jRuntimeVersion.substring(plusIdx + 1)
}
}
def jBuildNumber = tmpBuildNumber.split("[-\\+]")[0]
def versionInfo = new String[2];
versionInfo[0] = jVersion
versionInfo[1] = jBuildNumber
return versionInfo
}
/**
* Fails the build with the specified error message
*
* @param msg the reason for the failure
*/
void fail(String msg) {
throw new GradleException("FAIL: " + msg);
}
/******************************************************************************
* *
* Definition of project properties *
* *
* All properties defined using ext. are immediately available throughout *
* the script as variables that can be used. These variables are attached *
* to the root project (whereas if they were defined as def variables then *
* they would only be available within the root project scope). *
* *
* All properties defined using the "defineProperty" method can be replaced *
* on the command line by using the -P flag. For example, to override the *
* location of the binary plug, you would specify -PBINARY_PLUG=some/where *
* *
*****************************************************************************/
// If the ../rt-closed directory exists, then we are doing a closed build.
// In this case, build and property files will be read from
// ../rt-closed/closed-build.gradle and ../rt-closed/closed-properties.gradle
// respectively
def closedDir = file("../rt-closed")
def buildClosed = closedDir.isDirectory()
ext.BUILD_CLOSED = buildClosed
ext.RUNARGSFILE = "run.args"
ext.COMPILEARGSFILE = "compile.args"
ext.RUNJAVAPOLICYFILE = 'run.java.policy'
ext.TESTCOMPILEARGSFILE = "testcompile.args"
ext.TESTRUNARGSFILE = "testrun.args"
ext.TESTJAVAPOLICYFILE = 'test.java.policy'
// the file containing "extra" --add-exports
ext.EXTRAADDEXPORTS = 'buildSrc/addExports'
ext.MODULESOURCEPATH = "modulesourcepath.args"
// These variables indicate what platform is running the build. Is
// this build running on a Mac, Windows, or Linux machine? 32 or 64 bit?
ext.OS_NAME = System.getProperty("os.name").toLowerCase()
ext.OS_ARCH = System.getProperty("os.arch")
ext.IS_64 = OS_ARCH.toLowerCase().contains("64")
ext.IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin")
ext.IS_WINDOWS = OS_NAME.contains("windows")
ext.IS_LINUX = OS_NAME.contains("linux")
// Verify that the architecture & OS are supported configurations. Note that
// at present building on PI is not supported, but we would only need to make
// some changes on assumptions on what should be built (like SWT / Swing) and
// such and we could probably make it work.
if (!IS_MAC && !IS_WINDOWS && !IS_LINUX) fail("Unsupported build OS ${OS_NAME}")
if (IS_WINDOWS && OS_ARCH != "x86" && OS_ARCH != "amd64") {
fail("Unknown and unsupported build architecture: $OS_ARCH")
} else if (IS_MAC && OS_ARCH != "x86_64") {
fail("Unknown and unsupported build architecture: $OS_ARCH")
} else if (IS_LINUX && OS_ARCH != "i386" && OS_ARCH != "amd64") {
fail("Unknown and unsupported build architecture: $OS_ARCH")
}
// Get the JDK_HOME automatically based on the version of Java used to execute gradle. Or, if specified,
// use a user supplied JDK_HOME, STUB_RUNTIME, JAVAC, all of which may be specified
// independently (or we'll try to get the right one based on other supplied info). Sometimes the
// JRE might be the thing that is being used instead of the JRE embedded in the JDK, such as:
// c:\Program Files (x86)\Java\jdk1.8.0\jre
// c:\Program Files (x86)\Java\jre8\
// Because of this, you may sometimes get the jdk's JRE (in which case the logic we used to have here
// was correct and consistent with all other platforms), or it might be the standalone JRE (for the love!).
def envJavaHome = cygpath(System.getenv("JDK_HOME"))
if (envJavaHome == null || envJavaHome.equals("")) envJavaHome = cygpath(System.getenv("JAVA_HOME"))
def javaHome = envJavaHome == null || envJavaHome.equals("") ? System.getProperty("java.home") : envJavaHome
def javaHomeFile = file(javaHome)
defineProperty("JDK_HOME",
javaHomeFile.name == "jre" ?
javaHomeFile.getParent().toString() :
javaHomeFile.name.startsWith("jre") ?
new File(javaHomeFile.getParent(), "jdk1.${javaHomeFile.name.substring(3)}.0").toString() :
javaHome) // we have to bail and set it to something and this is as good as any!
ext.JAVA_HOME = JDK_HOME
defineProperty("JAVA", cygpath("$JDK_HOME/bin/java${IS_WINDOWS ? '.exe' : ''}"))
defineProperty("JAVAC", cygpath("$JDK_HOME/bin/javac${IS_WINDOWS ? '.exe' : ''}"))
defineProperty("JAVAH", cygpath("$JDK_HOME/bin/javah${IS_WINDOWS ? '.exe' : ''}"))
defineProperty("JAVADOC", cygpath("$JDK_HOME/bin/javadoc${IS_WINDOWS ? '.exe' : ''}"))
defineProperty("JDK_DOCS", "http://download.java.net/java/jdk9/docs/api/")
defineProperty("JDK_JMODS", cygpath(System.getenv("JDK_JMODS")) ?: cygpath(System.getenv("JDK_HOME") + "/jmods"))
defineProperty("javaRuntimeVersion", System.getProperty("java.runtime.version"))
def javaVersionInfo = parseJavaVersion(javaRuntimeVersion)
defineProperty("javaVersion", javaVersionInfo[0])
defineProperty("javaBuildNumber", javaVersionInfo[1])
loadProperties("$projectDir/build.properties")
// Look for stub runtime in either JDK or modular-sdk dir layout
def String closedCacheStubRuntime = cygpath("$projectDir") + "/../caches/modular-sdk"
def String jdkStubRuntime = cygpath("$JDK_HOME")
defineProperty("STUB_RUNTIME", BUILD_CLOSED ? closedCacheStubRuntime : jdkStubRuntime)
def cachedStub = STUB_RUNTIME.equals(closedCacheStubRuntime)
if (cachedStub) {
def stubModulesLib = "$STUB_RUNTIME/modules_libs"
defineProperty("MEDIA_STUB", "$stubModulesLib/javafx.media")
defineProperty("WEB_STUB", "$stubModulesLib/javafx.web")
} else {
def libraryStub = IS_WINDOWS ? "$STUB_RUNTIME/bin" : "$STUB_RUNTIME/lib"
defineProperty("MEDIA_STUB", libraryStub)
defineProperty("WEB_STUB", libraryStub)
}
defineProperty("UPDATE_STUB_CACHE", (cachedStub ? 'true' : 'false'))
def supplementalPreBuildFile = file("$closedDir/closed-pre-build.gradle");
def supplementalBuildFile = file("$closedDir/closed-build.gradle");
if (BUILD_CLOSED) {
apply from: supplementalPreBuildFile
}
// GRADLE_VERSION_CHECK specifies whether to fail the build if the
// gradle version check fails
defineProperty("GRADLE_VERSION_CHECK", "true")
ext.IS_GRADLE_VERSION_CHECK = Boolean.parseBoolean(GRADLE_VERSION_CHECK)
// COMPILE_WEBKIT specifies whether to build all of webkit.
defineProperty("COMPILE_WEBKIT", "false")
ext.IS_COMPILE_WEBKIT = Boolean.parseBoolean(COMPILE_WEBKIT)
// COMPILE_MEDIA specifies whether to build all of media.
defineProperty("COMPILE_MEDIA", "false")
ext.IS_COMPILE_MEDIA = Boolean.parseBoolean(COMPILE_MEDIA)
// COMPILE_PANGO specifies whether to build javafx_font_pango.
defineProperty("COMPILE_PANGO", "${IS_LINUX}")
ext.IS_COMPILE_PANGO = Boolean.parseBoolean(COMPILE_PANGO)
// COMPILE_HARFBUZZ specifies whether to use Harfbuzz.
defineProperty("COMPILE_HARFBUZZ", "false")
ext.IS_COMPILE_HARFBUZZ = Boolean.parseBoolean(COMPILE_HARFBUZZ)
// COMPILE_PARFAIT specifies whether to build parfait
defineProperty("COMPILE_PARFAIT", "false")
ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT)
// BUILD_FXPACKAGER enables building the packager modules and native code
defineProperty("BUILD_FXPACKAGER", "true")
ext.IS_BUILD_FXPACKAGER = Boolean.parseBoolean(BUILD_FXPACKAGER)
// RETAIN_PACKAGER_TESTS specifies whether the tests in fxpackager should
// keep generated files instead of attempting to automatically delete them
defineProperty("RETAIN_PACKAGER_TESTS", "false")
ext.IS_RETAIN_PACKAGER_TESTS = Boolean.parseBoolean(RETAIN_PACKAGER_TESTS)
// TEST_PACKAGER_DMG whether tests that create DMG files via hdiutil
// should be run. On OSX 10.7 this tends to hang automated builds
defineProperty("TEST_PACKAGER_DMG", "false")
ext.IS_TEST_PACKAGER_DMG = Boolean.parseBoolean(TEST_PACKAGER_DMG)
// Define the SWT.jar that we are going to have to download during the build process based
// on what platform we are compiling from (not based on our target).
ext.SWT_FILE_NAME = IS_MAC ? "org.eclipse.swt.cocoa.macosx.x86_64_3.7.2.v3740f" :
IS_WINDOWS && IS_64 ? "org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f" :
IS_WINDOWS && !IS_64 ? "org.eclipse.swt.win32.win32.x86_3.7.2.v3740f" :
IS_LINUX && IS_64 ? "org.eclipse.swt.gtk.linux.x86_64_3.7.2.v3740f" :
IS_LINUX && !IS_64 ? "org.eclipse.swt.gtk.linux.x86_3.7.2.v3740f" : ""
// Specifies whether to run full tests (true) or smoke tests (false)
defineProperty("FULL_TEST", "false")
ext.IS_FULL_TEST = Boolean.parseBoolean(FULL_TEST);
defineProperty("FORCE_TESTS", "false")
ext.IS_FORCE_TESTS = Boolean.parseBoolean(FORCE_TESTS);
// Specifies whether to run robot-based visual tests (only used when FULL_TEST is also enabled)
defineProperty("USE_ROBOT", "false")
ext.IS_USE_ROBOT = Boolean.parseBoolean(USE_ROBOT);
// Specified whether to run tests in headless mode
defineProperty("HEADLESS_TEST", "false")
ext.IS_HEADLESS_TEST = Boolean.parseBoolean(HEADLESS_TEST);
// Specifies whether to run system tests that depend on AWT (only used when FULL_TEST is also enabled)
defineProperty("AWT_TEST", "true")
ext.IS_AWT_TEST = Boolean.parseBoolean(AWT_TEST);
// Specifies whether to run system tests that depend on SWT (only used when FULL_TEST is also enabled)
defineProperty("SWT_TEST", "true")
ext.IS_SWT_TEST = Boolean.parseBoolean(SWT_TEST);
// Specifies whether to run unstable tests (true) - tests that don't run well with Hudson builds
// These tests should be protected with :
// assumeTrue(Boolean.getBoolean("unstable.test"));
defineProperty("UNSTABLE_TEST", "false")
ext.IS_UNSTABLE_TEST = Boolean.parseBoolean(UNSTABLE_TEST);
// Toggle diagnostic output from the Gradle workaround and the Sandbox test apps.
defineProperty("WORKER_DEBUG", "false")
ext.IS_WORKER_DEBUG = Boolean.parseBoolean(WORKER_DEBUG);
// Specify the build configuration (Release, Debug, or DebugNative)
defineProperty("CONF", "Debug")
ext.IS_DEBUG_JAVA = CONF == "Debug" || CONF == "DebugNative"
ext.IS_DEBUG_NATIVE = CONF == "DebugNative"
// Defines the compiler warning levels to use. If empty, then no warnings are generated. If
// not empty, then the expected syntax is as a space or comma separated list of names, such
// as defined in the javac documentation.
defineProperty("LINT", "none")
ext.IS_LINT = LINT != "none"
defineProperty("DOC_LINT", "all")
ext.IS_DOC_LINT = DOC_LINT != ""
// Specifies whether to use the "useDepend" option when compiling Java sources
defineProperty("USE_DEPEND", "true")
ext.IS_USE_DEPEND = Boolean.parseBoolean(USE_DEPEND)
// Specifies whether to use the "incremental" option when compiling Java sources
defineProperty("INCREMENTAL", "false")
ext.IS_INCREMENTAL = Boolean.parseBoolean(INCREMENTAL)
// Specifies whether to include the Null3D pipeline (for perf debugging)
defineProperty("INCLUDE_NULL3D", "false")
ext.IS_INCLUDE_NULL3D = Boolean.parseBoolean(INCLUDE_NULL3D)
// Specifies whether to include the ES2 pipeline if available
defineProperty("INCLUDE_ES2", IS_WINDOWS ? "false" : "true")
ext.IS_INCLUDE_ES2 = Boolean.parseBoolean(INCLUDE_ES2)
// Specifies whether to generate code coverage statistics when running tests
defineProperty("JCOV", "false")
ext.DO_JCOV = Boolean.parseBoolean(JCOV)
// Define the number of threads to use when compiling (specifically for native compilation)
// On Mac we limit it to 1 by default due to problems running gcc in parallel
if (IS_MAC) {
defineProperty("NUM_COMPILE_THREADS", "1")
} else {
defineProperty("NUM_COMPILE_THREADS", "${Runtime.runtime.availableProcessors()}")
}
//
// The next three sections of properties are used to generate the
// VersionInfo class, and the Windows DLL manifest.
//
// The following properties should be left alone by developers and set only from Hudson.
defineProperty("HUDSON_JOB_NAME", "not_hudson")
defineProperty("HUDSON_BUILD_NUMBER","0000")
defineProperty("PROMOTED_BUILD_NUMBER", "0")
// The following properties define the product name for Oracle JDK and OpenJDK
// for VersionInfo and the DLL manifest.
if (BUILD_CLOSED) {
defineProperty("PRODUCT_NAME", "Java(TM)")
defineProperty("COMPANY_NAME", "Oracle Corporation")
defineProperty("PLATFORM_NAME", "Platform SE")
} else {
defineProperty("PRODUCT_NAME", "OpenJFX")
defineProperty("COMPANY_NAME", "N/A")
defineProperty("PLATFORM_NAME", "Platform")
}
// The following properties are set based on properties defined in
// build.properties. The release version and suffix should be updated
// in that file.
def relVer = 0
if (jfxReleasePatchVersion == "0") {
if (jfxReleaseSecurityVersion == "0") {
if (jfxReleaseMinorVersion == "0") {
relVer = "${jfxReleaseMajorVersion}"
} else {
relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}"
}
} else {
relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}"
}
} else {
relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}.${jfxReleasePatchVersion}"
}
defineProperty("RELEASE_VERSION", relVer)
defineProperty("RELEASE_VERSION_PADDED", "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}.${jfxReleasePatchVersion}")
def buildDate = new java.util.Date()
def buildTimestamp = new java.text.SimpleDateFormat("yyyy-MM-dd-HHmmss").format(buildDate)
defineProperty("BUILD_TIMESTAMP", buildTimestamp)
def relSuffix = ""
def relOpt = ""
if (HUDSON_JOB_NAME == "not_hudson") {
relSuffix = "-internal"
relOpt = "-${buildTimestamp}"
} else {
relSuffix = jfxReleaseSuffix
}
defineProperty("RELEASE_SUFFIX", relSuffix)
defineProperty("RELEASE_VERSION_SHORT", "${RELEASE_VERSION}${RELEASE_SUFFIX}")
defineProperty("RELEASE_VERSION_LONG", "${RELEASE_VERSION_SHORT}+${PROMOTED_BUILD_NUMBER}${relOpt}")
// Check whether the COMPILE_TARGETS property has been specified (if so, it was done by
// the user and not by this script). If it has not been defined then default
// to building the normal desktop build for this machine
project.ext.set("defaultHostTarget", IS_MAC ? "mac" : IS_WINDOWS ? "win" : IS_LINUX ? "linux" : "");
defineProperty("COMPILE_TARGETS", "$defaultHostTarget")
// Flag indicating whether to import cross compile tools
def importCrossTools = BUILD_CLOSED ? true : false;
if (!importCrossTools && hasProperty("IMPORT_CROSS_TOOLS")) {
importCrossTools = Boolean.parseBoolean(IMPORT_CROSS_TOOLS);
}
ext.IS_IMPORT_CROSS_TOOLS = importCrossTools
// Location of the cross compile tools
def crossToolsDir = "../crosslibs"
if (hasProperty("CROSS_TOOLS_DIR")) {
crossToolsDir = CROSS_TOOLS_DIR
}
ext.CROSS_TOOLS_DIR = file(crossToolsDir)
// Specifies whether to run tests with the existing javafx.* modules instead of compiling a new one
defineProperty("BUILD_SDK_FOR_TEST", "true")
ext.DO_BUILD_SDK_FOR_TEST = Boolean.parseBoolean(BUILD_SDK_FOR_TEST)
// All "classes" and "jar" tasks and their dependencies would be disabled
// when running with DO_BUILD_SDK_FOR_TEST=false as they're unneeded for running tests
if (!DO_BUILD_SDK_FOR_TEST) {
gradle.taskGraph.useFilter({ task -> !task.name.equals("classes") && !task.name.equals("jar") })
}
/**
* Fetch/Check that external tools are present for the build. This method
* will conditionally download the packages from project defined ivy repositories
* and unpack them into the specified destdir
*
* @param configName A unique name to distinguish the configuration (ie "ARMSFV6")
* @param packages A list of required packages (with extensions .tgz, .zip)
* @param destdir where the packages should be unpacked
* @param doFetch if true, the named packages will be download
*/
void fetchExternalTools(String configName, List packages, File destdir, boolean doFetch) {
if (doFetch) {
// create a unique configuration for this fetch
def String fetchToolsConfig = "fetchTools$configName"
rootProject.configurations.create(fetchToolsConfig)
def List<String> fetchedPackages = []
def int fetchCount = 0
packages.each { pkgname->
def int dotdex = pkgname.lastIndexOf('.')
def int dashdex = pkgname.lastIndexOf('-')
def String basename = pkgname.substring(0,dashdex)
def String ver = pkgname.substring(dashdex+1,dotdex)
def String ext = pkgname.substring(dotdex+1)
def File pkgdir = file("$destdir/$basename-$ver")
if (!pkgdir.isDirectory()) {
rootProject.dependencies.add(fetchToolsConfig, "javafx:$basename:$ver", {
artifact {
name = basename
version = ver
type = ext
}
})
println "adding $pkgname as a downloadable item did not find $pkgdir"
fetchedPackages.add(pkgname)
fetchCount++
}
}
//fetch all the missing packages
if (fetchedPackages.size > 0) {
destdir.mkdirs()
logger.quiet "fetching missing packages $fetchedPackages"
copy {
from rootProject.configurations[fetchToolsConfig]
into destdir
}
// unpack the fetched packages
fetchedPackages.each { pkgname->
logger.quiet "expanding the package $pkgname"
def srcball = file("${destdir}/${pkgname}")
if (!srcball.exists()) {
throw new GradleException("Failed to fetch $pkgname");
}
def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
def File pkgdir = file("$destdir/$basename")
if (pkgname.endsWith(".tgz")) {
if (IS_LINUX || IS_MAC) {
// use native tar to support symlinks
pkgdir.mkdirs()
exec {
workingDir pkgdir
commandLine "tar", "zxf", "${srcball}"
}
} else {
copy {
from tarTree(resources.gzip("${srcball}"))
into pkgdir
}
}
} else if (pkgname.endsWith(".zip")) {
copy {
from zipTree("${srcball}")
into pkgdir
}
} else {
throw new GradleException("Unhandled package type for compile package ${pkgname}")
}
srcball.deleteOnExit();
}
} else {
logger.quiet "all tool packages are present $packages"
}
} else { // !doFetch - so just check they are present
// check that all the dirs are really there
def List<String> errors = []
packages.each { pkgname->
def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
def File pkgdir = file("$destdir/$basename")
if (!pkgdir.isDirectory()) {
errors.add(pkgname)
}
}
if (errors.size > 0) {
throw new GradleException("Error: missing tool packages: $errors")
} else {
logger.quiet "all tool packages are present $packages"
}
}
}
// Make a forked ANT call.
// This needs to be forked so that ant can be used with the right JDK and updated modules
// for testing obscure things like packaging of apps
void ant(String conf, // platform configuration
String dir, // directory to run from
String target, // ant target
List<String> params // parameters (usually -Dxxx=yyy)
) {
// Try to use ANT_HOME
String antHomeEnv = System.getenv("ANT_HOME")
String antHome = antHomeEnv != null ? cygpath(antHomeEnv) : null;
String ant = (antHome != null && !antHome.equals("")) ? "$antHome/bin/ant" : "ant";
exec {
workingDir = dir
environment("JDK_HOME", JDK_HOME)
environment("JAVA_HOME", JDK_HOME)
if (IS_WINDOWS) {
environment([
"VCINSTALLDIR" : WINDOWS_VS_VCINSTALLDIR,
"VSINSTALLDIR" : WINDOWS_VS_VSINSTALLDIR,
"DEVENVDIR" : WINDOWS_VS_DEVENVDIR,
"MSVCDIR" : WINDOWS_VS_MSVCDIR,
"INCLUDE" : WINDOWS_VS_INCLUDE,
"LIB" : WINDOWS_VS_LIB,
"LIBPATH" : WINDOWS_VS_LIBPATH,
"DXSDK_DIR" : WINDOWS_DXSDK_DIR
]);
commandLine "cmd", "/c", ant, "-Dbuild.compiler=javac1.7"
} else {
commandLine ant, "-Dbuild.compiler=javac1.7"
}
if ((conf != null) && !rootProject.defaultHostTarget.equals(conf)) {
def targetProperties = rootProject.ext[t.trim().toUpperCase()]
args("-Dcross.platform=$conf")
if (targetProperties.containsKey('arch')) {
args("-Dcross.platform.arch=${targetProperties.arch}")
}
}
if (params != null) {
params.each() { s->
args(s)
}
}
args(target);
}
}
List<String> computeLibraryPath(boolean working) {
List<String> lp = []
List<String> modsWithNative = [ 'graphics', 'media', 'web' ]
// the build/modular-sdk area
def platformPrefix = ""
def modularSdkDirName = "${platformPrefix}modular-sdk"
def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
def modulesLibsDir = "${modularSdkDir}/modules_libs"
modsWithNative.each() { m ->
lp << cygpath("${modulesLibsDir}/javafx.${m}")
}
return lp
}
// Return list with the arguments needed for --patch-module for the provided projects
// used with Java executables ie. tests
List<String> computePatchModuleArgs(List<String> deps, boolean test, boolean includeJLP) {
List<String> pma = []
deps.each {String projname ->
def proj = project(projname)
if (proj.hasProperty("moduleName")) {
File dir;
if (test && proj.sourceSets.hasProperty('shims')) {
dir = file("${rootProject.buildDir}/shims")
} else {
dir = file("${rootProject.buildDir}/modular-sdk/modules")
}
String moduleName = proj.ext.moduleName
String dirpath = cygpath("${dir}/${moduleName}")
pma += "--patch-module=${moduleName}=${dirpath}"
}
}
if (includeJLP) {
pma += "-Djava.library.path=" + computeLibraryPath(true).join(File.pathSeparator)
}
return pma
}
// Return a list containing the --upgrade-module-path
// used with Javac
List<String> computeModulePathArgs(String pname, List<String> deps, boolean test) {
List<String> mpa = [ '--upgrade-module-path' ]
String mp = null
deps.each {String projname ->
def proj = project(projname)
// for a non test set of args, we don't want the current module in the list
// for a test test, we do need it to update what we built
if (proj.hasProperty("moduleName") &&
proj.buildModule &&
!(!test && proj.name.equals(pname))) {
File dir;
if (test && proj.sourceSets.hasProperty('shims')) {
dir = new File(proj.sourceSets.shims.output.classesDir, proj.ext.moduleName);
} else {
dir = new File(proj.sourceSets.main.output.classesDir, proj.ext.moduleName);
}
if (mp == null) {
mp = dir.path
} else {
mp = mp + File.pathSeparator + dir.path
}
}
}
// in some cases like base we could end up with an empty
// path... make sure we don't pass one back
if (mp == null) {
return null
}
mpa += mp
return mpa
}
void writeRunArgsFile(File dest, List<String> libpath, List<String> modpath) {
dest.delete()
logger.info("Creating file ${dest.path}")
if (libpath != null) {
dest << "-Djava.library.path=\"\\\n"
libpath.each() { e->
dest << " "
dest << e
dest << File.pathSeparator
dest << "\\\n"
}
dest << " \"\n"
}
modpath.each { e ->
dest << "--patch-module=\""
dest << e
dest << "\"\n"
}
}
// perform common project manipulation for modules
void commonModuleSetup(Project p, List<String> moduleChain) {
p.ext.moduleChain = moduleChain
if (p.hasProperty("moduleName")) {
p.ext.moduleDir = new File (p.sourceSets.main.output.classesDir, "${p.moduleName}")
if (p.sourceSets.hasProperty('shims')) {
p.ext.moduleShimsDir = new File (p.sourceSets.shims.output.classesDir, "${p.moduleName}")
}
}
def mpa = computeModulePathArgs(p.name, moduleChain, false)
if (mpa != null) {
p.ext.modulePathArgs = mpa
}
p.ext.testModulePathArgs = computePatchModuleArgs(moduleChain, true, false)
p.ext.patchModuleArgs = computePatchModuleArgs(moduleChain ,false, true)
p.ext.testPatchModuleArgs = computePatchModuleArgs(moduleChain, true, true)
moduleChain.each() {e ->
if (!e.equals(p.name)) {
p.compileJava.dependsOn(project(e).classes)
p.compileTestJava.dependsOn(project(e).testClasses)
}
}
// read in any addExports file
File addExportsFile = new File(p.projectDir,"src/test/addExports")
if (addExportsFile.exists()) {
List<String> ae = []
addExportsFile.eachLine { line ->
line = line.trim()
if (!(line.startsWith("#") || line.equals(""))) {
ae += line.split(' ')
}
}
p.ext.testAddExports = ae.flatten()
}
// read in the temporary addExports file EXTRAADDEXPORTS)
//
// These extra --add-exports will be used in two places and so we
// create/modify two items:
// p.testAddExports - add the extra items so they are included in test builds
//
// p.extraAddExports - for use in any other place where we don't automatically update
// for example any non modular, non 'test' compile, any compile that does not
// use a module-source-path that includes the dependent modules
//
// Note that we don't modify the modular build (main, shims) because they use
// module-info directly, and we don't want to cover up any missing items there.
//
if (!rootProject.hasProperty("EXTRA_ADDEXPORTS_ARGS")) {
List<String> extraAddExportsList = []
String fullae = ""
File tmpaddExportsFile = new File(rootProject.projectDir, EXTRAADDEXPORTS)
if (tmpaddExportsFile.exists()) {
String nl = System.getProperty("line.separator")
tmpaddExportsFile.eachLine { line ->
line = line.trim()
fullae += line + nl
if (!(line.startsWith("#") || line.equals(""))) {
extraAddExportsList += line.split(' ')
}
}
}
// This string is used in the creation of the build/*.args files
// so we preserve comments
if (!extraAddExportsList.isEmpty()) {
rootProject.ext.EXTRA_ADDEXPORTS_STRING = fullae
}
rootProject.ext.EXTRA_ADDEXPORTS_ARGS = extraAddExportsList
}
// use this variable, because it shows we have a non empty addition
if (rootProject.hasProperty("EXTRA_ADDEXPORTS_STRING")) {
p.ext.extraAddExports = EXTRA_ADDEXPORTS_ARGS.flatten()
if (p.hasProperty("testAddExports")) {
p.testAddExports += EXTRA_ADDEXPORTS_ARGS.flatten()
}
}
}
// Now we need to define the native compilation tasks. The set of parameters to
// native compilation depends on the target platform (and also to some extent what platform
// you are compiling on). These settings are contained in various gradle files
// such as mac.gradle and linux.gradle and armhf.gradle. Additionally, the developer
// can specify COMPILE_FLAGS_FILE to be a URL or path to a different gradle file
// that will contain the appropriate flags.
defineProperty("COMPILE_FLAGS_FILES", COMPILE_TARGETS.split(",").collect {"buildSrc/${it.trim()}.gradle"}.join(","))
if (COMPILE_TARGETS == "all") {
def tmp = []
File buildSrcDir = file("buildSrc")
buildSrcDir.listFiles().each { File f ->
if (f.isFile() && f.name.endsWith(".gradle") && !f.name.equals("build.gradle")) {
def target = f.name.substring(0, f.name.lastIndexOf('.gradle')).toUpperCase(Locale.ROOT)
apply from: f
if (project.ext["${target}"].canBuild) {
tmp.add(target)
}
}
}
COMPILE_FLAGS_FILES = tmp.collect { "buildSrc/${it}.gradle"}.join(",")
COMPILE_TARGETS = tmp.collect { "${it.toLowerCase()}"}.join(",")
} else {
COMPILE_FLAGS_FILES.split(",").each {
logger.info("Applying COMPILE_FLAGS_FILE '$it'")
apply from: it
}
}
if (COMPILE_TARGETS != "") {
def tmp = []
COMPILE_TARGETS.split(",").each {target ->
if (project.ext["${target.toUpperCase(Locale.ROOT)}"].canBuild) {
tmp.add(target)
}
}
COMPILE_TARGETS = tmp.collect { "${it.toLowerCase()}"}.join(",")
}
// Sanity check the expected properties all exist
compileTargets { t ->
// Every platform must define these variables
if (!project.hasProperty(t.upper)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${t.name} property")
def props = project.ext[t.upper];
// TODO: we could remove libDest in favor of modLibDest
["compileSwing", "compileSWT", "compileFXPackager", "libDest"].each { prop ->
if (!props.containsKey(prop)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${prop} property on ${t.name}")
}
}
// Various build flags may be set by the different target files, such as
// whether to build Swing, SWT, FXPackager, etc. We iterate over all
// compile targets and look for these settings in our properties. Note that
// these properties cannot be set from the command line, but are set by
// the target build files such as armv6hf.gradle or mac.gradle.
ext.COMPILE_SWING = false;
ext.COMPILE_SWT = false;
ext.COMPILE_FXPACKAGER = false;
compileTargets { t ->
def targetProperties = project.rootProject.ext[t.upper]
if (targetProperties.compileSwing) COMPILE_SWING = true
if (targetProperties.compileSWT) COMPILE_SWT = true
if (IS_BUILD_FXPACKAGER && targetProperties.compileFXPackager) COMPILE_FXPACKAGER = true
if (!targetProperties.containsKey('compileWebnodeNative')) {
// unless specified otherwise, we will compile native Webnode if IS_COMPILE_WEBKIT
targetProperties.compileWebnodeNative = true
}
if (!targetProperties.containsKey('compileMediaNative')) {
// unless specified otherwise, we will compile native Media if IS_COMPILE_MEDIA
targetProperties.compileMediaNative = true
}
if (!targetProperties.containsKey('includeSWT')) targetProperties.includeSWT = true
if (!targetProperties.containsKey('includeSwing')) targetProperties.includeSwing = true
if (!targetProperties.containsKey('includeNull3d')) targetProperties.includeNull3d = true
if (!targetProperties.containsKey('includeLens')) targetProperties.includeLens = false
if (!targetProperties.containsKey('includeMonocle')) targetProperties.includeMonocle = false
if (!targetProperties.containsKey('includeEGL')) targetProperties.includeEGL = false
if (!targetProperties.containsKey('includeGTK')) targetProperties.includeGTK = IS_LINUX
if (!targetProperties.containsKey('modLibDest')) targetProperties.modLibDest = targetProperties.libDest
// This value is used as a prefix for various directories under ./build,
// such as sdk, to allow for a common name for the hosted build