forked from graalvm/mx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mx_compat.py
602 lines (463 loc) · 16.3 KB
/
mx_compat.py
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
#
# ----------------------------------------------------------------------------------------------------
#
# Copyright (c) 2015, 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.
#
# 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.
#
# ----------------------------------------------------------------------------------------------------
from __future__ import print_function
import sys, inspect, re, bisect
from collections import OrderedDict
from os.path import join
import mx
class MxCompatibility500(object):
@staticmethod
def version():
return mx.VersionSpec("5.0.0")
def supportsLicenses(self):
return False
def licenseAttribute(self):
return 'licence'
def licensesAttribute(self):
return 'licences'
def defaultLicenseAttribute(self):
return 'defaultLicence'
def supportedMavenMetadata(self):
return []
def supportsRepositories(self):
return False
def newestInputIsTimeStampFile(self):
'''
Determines if the 'newestInput' parameter of BuildTask.needsBuild()
is a TimeStampFile or a simple time stamp (i.e. a float).
'''
return False
def getSuiteOutputRoot(self, suite):
return suite.dir
def mavenDeployJavadoc(self):
return False
def validate_maven_javadoc(self):
return False
def mavenSupportsClassifier(self):
return False
def checkstyleVersion(self):
return '6.0'
def checkDependencyJavaCompliance(self):
"""
Determines if a project must have a higher or equal Java compliance level
than a project it depends upon.
"""
return False
def improvedImportMatching(self):
return False
def verifySincePresent(self):
return []
def moduleDepsEqualDistDeps(self):
"""
Determines if the constituents of a module derived from a distribution are
exactly the same as the constituents of the distribution.
"""
return False
def useDistsForUnittest(self):
"""
Determines if Unittest uses jars from distributions for testing.
"""
return False
def excludeDisableJavaDebuggging(self):
"""
Excludes the misspelled class name.
"""
return False
def makePylintVCInputsAbsolute(self):
"""
Makes pylint input paths discovered by VC absolute.
"""
return False
def disableImportOfTestProjects(self):
"""
Requires that test projects can only be imported by test projects.
"""
return False
def useJobsForMakeByDefault(self):
"""
Uses -j for make by default, can be prevented using `single_job` attribute on the project.
"""
return False
def overwriteProjectAttributes(self):
"""
Attributes from the configuration that are not explicitly handled overwrite values set by the constructor.
"""
return True
def requireJsonifiableSuite(self):
return False
def supportSuiteImportGitBref(self):
return True
def enforceTestDistributions(self):
return False
def deprecateIsTestProject(self):
return False
def filterFindbugsProjectsByJavaCompliance(self):
"""
Should selection of projects to analyze with FindBugs filter
out projects whose Java compliance is greater than 8.
"""
return False
def addVersionSuffixToExplicitVersion(self):
return False
def __str__(self):
return str("MxCompatibility({})".format(self.version()))
def __repr__(self):
return str(self)
def jarsUseJDKDiscriminant(self):
"""
Should `mx.JARDistribution` use the jdk version used for the build as a `Dependency._extra_artifact_discriminant`
to avoid collisions of build artifacts when building with different JAVA_HOME/EXTRA_JAVA_HOMES settings.
"""
return False
def check_package_locations(self):
"""
Should `canonicalizeprojects` check whether the java package declarations and source location match.
"""
return False
def check_checkstyle_config(self):
"""
Should sanity check Checkstyle configuration for a project.
"""
return False
def verify_multirelease_projects(self):
"""
Should multi-release projects be verified (see mx.verifyMultiReleaseProjects).
"""
return False
def spotbugs_version(self):
"""
Which version of findbugs/spotbugs should be used?
"""
return "3.0.0"
def automatic_overlay_distribution_deps(self):
"""
When a distribution depends on a project that has versioned overlays, are the
overlay projects automatically added as dependencies to the distribution?
"""
return False
def supports_disjoint_JavaCompliance_range(self):
"""
Specifies if disjoint JavaCompliance ranges (e.g. "8,13+") are supported.
"""
return False
def maven_deploy_unsupported_is_error(self):
"""
Specifies if trying to deploy a distribution whose type is not supported is an error.
"""
return False
def enhanced_module_usage_info(self):
"""
Returns True if a Java project must specify its use of concealed packages with
a "requiresConcealed" attribute and use of modules other than java.base with
a "requires" attribute.
"""
return False
def get_sigtest_jar(self):
"""
Returns the proper version of the SIGTEST jar used by `mx sigtest`.
"""
return mx.library('SIGTEST_1_2').get_path(resolve=True)
def fix_extracted_dependency_prefix(self):
"""
Returns True if the `./` prefix should be removed from `extracted-dependency` sources of layout distributions.
"""
return False
def is_using_jdk_headers_implicitly(self, project):
"""Returns whether a native project is using JDK headers implicitly.
The use of JDK headers is implied if any build dependency is a Java project with JNI headers.
"""
assert project.isNativeProject()
is_using_jdk_headers = any(d.isJavaProject() and d.include_dirs for d in project.buildDependencies)
if is_using_jdk_headers and project.suite._output_root_includes_config():
project.abort('This project is using JDK headers implicitly. For MX_OUTPUT_ROOT_INCLUDES_CONFIG=true to '
'work, it must set the "use_jdk_headers" attribute explicitly.')
return is_using_jdk_headers
def bench_suite_needs_suite_args(self):
"""
Returns whether extracting the benchmark suite name depends on the `bmSuiteArgs` or not.
"""
return False
class MxCompatibility520(MxCompatibility500):
@staticmethod
def version():
return mx.VersionSpec("5.2.0")
def supportsLicenses(self):
return True
def supportedMavenMetadata(self):
return ['library-coordinates', 'suite-url', 'suite-developer', 'dist-description']
class MxCompatibility521(MxCompatibility520):
@staticmethod
def version():
return mx.VersionSpec("5.2.1")
def supportsRepositories(self):
return True
class MxCompatibility522(MxCompatibility521):
@staticmethod
def version():
return mx.VersionSpec("5.2.2")
def licenseAttribute(self):
return 'license'
def licensesAttribute(self):
return 'licenses'
def defaultLicenseAttribute(self):
return 'defaultLicense'
class MxCompatibility533(MxCompatibility522):
@staticmethod
def version():
return mx.VersionSpec("5.3.3")
def newestInputIsTimeStampFile(self):
return True
class MxCompatibility555(MxCompatibility533):
@staticmethod
def version():
return mx.VersionSpec("5.5.5")
def getSuiteOutputRoot(self, suite):
return join(suite.dir, 'mxbuild')
class MxCompatibility566(MxCompatibility555):
@staticmethod
def version():
return mx.VersionSpec("5.6.6")
def mavenDeployJavadoc(self):
return True
class MxCompatibility5616(MxCompatibility566):
@staticmethod
def version():
return mx.VersionSpec("5.6.16")
def checkstyleVersion(self):
return '6.15'
class MxCompatibility59(MxCompatibility5616):
@staticmethod
def version():
return mx.VersionSpec("5.9.0")
def verifySincePresent(self):
return ['-verifysincepresent']
class MxCompatibility5200(MxCompatibility59):
@staticmethod
def version():
return mx.VersionSpec("5.20.0")
def checkDependencyJavaCompliance(self):
return True
def improvedImportMatching(self):
return True
class MxCompatibility5344(MxCompatibility5200):
@staticmethod
def version():
return mx.VersionSpec("5.34.4")
def moduleDepsEqualDistDeps(self):
return True
class MxCompatibility5590(MxCompatibility5344):
@staticmethod
def version():
return mx.VersionSpec("5.59.0")
def useDistsForUnittest(self):
return True
class MxCompatibility5680(MxCompatibility5590):
@staticmethod
def version():
return mx.VersionSpec("5.68.0")
def excludeDisableJavaDebuggging(self):
return True
class MxCompatibility51104(MxCompatibility5680):
@staticmethod
def version():
return mx.VersionSpec("5.110.4")
def makePylintVCInputsAbsolute(self):
return True
class MxCompatibility51120(MxCompatibility51104):
@staticmethod
def version():
return mx.VersionSpec("5.113.0")
def disableImportOfTestProjects(self):
return True
class MxCompatibility51150(MxCompatibility51120):
@staticmethod
def version():
return mx.VersionSpec("5.115.0")
def useJobsForMakeByDefault(self):
return True
class MxCompatibility51247(MxCompatibility51150):
@staticmethod
def version():
return mx.VersionSpec("5.124.7")
def overwriteProjectAttributes(self):
return False
class MxCompatibility51330(MxCompatibility51247):
@staticmethod
def version():
return mx.VersionSpec("5.133.0")
def requireJsonifiableSuite(self):
return True
class MxCompatibility51380(MxCompatibility51330):
@staticmethod
def version():
return mx.VersionSpec("5.138.0")
def supportSuiteImportGitBref(self):
return False
class MxCompatibility51400(MxCompatibility51380):
@staticmethod
def version():
return mx.VersionSpec("5.140.0")
def enforceTestDistributions(self):
return True
def deprecateIsTestProject(self):
return True
class MxCompatibility51492(MxCompatibility51400):
@staticmethod
def version():
return mx.VersionSpec("5.149.2")
def filterFindbugsProjectsByJavaCompliance(self):
return True
class MxCompatibility51760(MxCompatibility51492):
@staticmethod
def version():
return mx.VersionSpec("5.176.0")
def addVersionSuffixToExplicitVersion(self):
return True
class MxCompatibility5181(MxCompatibility51760):
@staticmethod
def version():
return mx.VersionSpec("5.181.0")
def jarsUseJDKDiscriminant(self):
return True
class MxCompatibility5194(MxCompatibility5181):
@staticmethod
def version():
return mx.VersionSpec("5.194.0")
def check_package_locations(self):
return True
class MxCompatibility51950(MxCompatibility5194):
@staticmethod
def version():
return mx.VersionSpec("5.195.0")
def mavenSupportsClassifier(self):
return True
class MxCompatibility51951(MxCompatibility51950):
@staticmethod
def version():
return mx.VersionSpec("5.195.1")
def check_checkstyle_config(self):
return True
class MxCompatibility52061(MxCompatibility51951):
@staticmethod
def version():
return mx.VersionSpec("5.206.1")
def verify_multirelease_projects(self):
return True
class MxCompatibility52102(MxCompatibility52061):
@staticmethod
def version():
return mx.VersionSpec("5.210.2")
def spotbugs_version(self):
return "3.1.11"
class MxCompatibility52230(MxCompatibility52102):
@staticmethod
def version():
return mx.VersionSpec("5.223.0")
def automatic_overlay_distribution_deps(self):
return True
def supports_disjoint_JavaCompliance_range(self):
return True
class MxCompatibility52290(MxCompatibility52230):
@staticmethod
def version():
return mx.VersionSpec("5.229.0")
def maven_deploy_unsupported_is_error(self):
return True
class MxCompatibility52310(MxCompatibility52290):
@staticmethod
def version():
return mx.VersionSpec("5.231.0")
def enhanced_module_usage_info(self):
return True
class MxCompatibility52710(MxCompatibility52310):
@staticmethod
def version():
return mx.VersionSpec("5.271.0")
def validate_maven_javadoc(self):
return True
class MxCompatibility52791(MxCompatibility52710):
@staticmethod
def version():
return mx.VersionSpec("5.279.1")
def get_sigtest_jar(self):
return mx.library('SIGTEST_1_3').get_path(resolve=True)
class MxCompatibility52820(MxCompatibility52791):
@staticmethod
def version():
return mx.VersionSpec("5.282.0")
def fix_extracted_dependency_prefix(self):
return True
class MxCompatibility53000(MxCompatibility52820):
@staticmethod
def version():
return mx.VersionSpec("5.300.0")
def is_using_jdk_headers_implicitly(self, project):
assert project.isNativeProject()
if any(d.isJavaProject() and d.include_dirs for d in project.buildDependencies):
project.abort('This project is using JDK headers implicitly. Instead, it must set the "use_jdk_headers" '
'attribute explicitly.')
return False
class MxCompatibility53010(MxCompatibility53000):
@staticmethod
def version():
return mx.VersionSpec("5.301.0")
def bench_suite_needs_suite_args(self):
return True
def minVersion():
_ensureCompatLoaded()
return list(_versionsMap)[0]
def getMxCompatibility(version):
""":rtype: MxCompatibility500"""
if version < minVersion(): # ensures compat loaded
return None
keys = list(_versionsMap.keys())
return _versionsMap[keys[bisect.bisect_right(keys, version)-1]]
_versionsMap = OrderedDict()
def _ensureCompatLoaded():
if not _versionsMap:
def flattenClassTree(tree):
root = tree[0][0]
assert isinstance(root, type), root
yield root
if len(tree) > 1:
assert len(tree) == 2
rest = tree[1]
assert isinstance(rest, list), rest
for c in flattenClassTree(rest):
yield c
classes = []
regex = re.compile(r'^MxCompatibility[0-9a-z]*$')
for name, clazz in inspect.getmembers(sys.modules[__name__], inspect.isclass):
m = regex.match(name)
if m:
classes.append(clazz)
previousVersion = None
for clazz in flattenClassTree(inspect.getclasstree(classes)):
if clazz == object:
continue
assert previousVersion is None or previousVersion < clazz.version()
previousVersion = clazz.version()
_versionsMap[previousVersion] = clazz()