60
60
import textwrap
61
61
import zipfile
62
62
63
+ import mx_sdk_vm_ng
64
+
63
65
try :
64
66
# Use more secure defusedxml library, if available
65
67
from defusedxml .ElementTree import parse as etreeParse
77
79
import mx_util
78
80
79
81
80
- if sys .version_info [0 ] < 3 :
81
- _unicode = unicode # pylint: disable=undefined-variable
82
- def _decode (x ):
83
- return x
84
- def _encode (x ):
85
- return x
86
- else :
87
- _unicode = str
88
- def _decode (x ):
89
- return x .decode ()
90
- def _encode (x ):
91
- return x .encode ()
92
-
93
-
94
82
def unicode_utf8 (string ):
95
- if sys .version_info [0 ] < 3 :
96
- if isinstance (string , str ):
97
- return unicode (string , 'utf-8' ) # pylint: disable=undefined-variable
98
- elif isinstance (string , bytes ):
83
+ if isinstance (string , bytes ):
99
84
return str (string )
100
85
return string
101
86
@@ -479,7 +464,7 @@ def _patch_darwin_jdk():
479
464
root .write (bio ) # When porting to Python 3, we can use root.write(StringIO(), encoding="unicode")
480
465
plist_src = {
481
466
'source_type' : 'string' ,
482
- 'value' : _decode ( bio .getvalue ()),
467
+ 'value' : bio .getvalue (). decode ( ),
483
468
'ignore_value_subst' : True
484
469
}
485
470
_incl_list .append ((base_dir + '/Contents/Info.plist' , plist_src ))
@@ -1030,11 +1015,11 @@ def _get_graalvm_configuration(base_name, components=None, stage1=False):
1030
1015
mx .logv ("No dist name for {}" .format (components_sorted_set ))
1031
1016
m = hashlib .sha1 ()
1032
1017
for component in components_sorted_set :
1033
- m .update (_encode ( component ))
1018
+ m .update (component . encode ( ))
1034
1019
if _jlink_libraries ():
1035
- m .update (_encode ( "jlinked" ))
1020
+ m .update ("jlinked" . encode ( ))
1036
1021
else :
1037
- m .update (_encode ( "not-jlinked" ))
1022
+ m .update ("not-jlinked" . encode ( ))
1038
1023
short_sha1_digest = m .hexdigest ()[:10 ] # to keep paths short
1039
1024
base_dir = '{base_name}_{hash}_java{jdk_version}' .format (base_name = base_name , hash = short_sha1_digest , jdk_version = _src_jdk_version )
1040
1025
name = '{base_dir}{stage_suffix}' .format (base_dir = base_dir , stage_suffix = '_stage1' if stage1 else '' )
@@ -3171,7 +3156,7 @@ def get_stage1_graalvm_distribution():
3171
3156
""":rtype: GraalVmLayoutDistribution"""
3172
3157
global _stage1_graalvm_distribution
3173
3158
if _stage1_graalvm_distribution == 'uninitialized' :
3174
- _stage1_graalvm_distribution = GraalVmLayoutDistribution (_graalvm_base_name , stage1 = True )
3159
+ _stage1_graalvm_distribution = GraalVmLayoutDistribution (_graalvm_base_name , stage1 = True , defaultBuild = False )
3175
3160
_stage1_graalvm_distribution .description = "GraalVM distribution (stage1)"
3176
3161
_stage1_graalvm_distribution .maven = False
3177
3162
return _stage1_graalvm_distribution
@@ -3534,10 +3519,10 @@ def register_main_dist(dist, label):
3534
3519
register_distribution (debuginfo_dist )
3535
3520
main_dists [label ].append (debuginfo_dist .name )
3536
3521
3537
- _final_graalvm_distribution = get_final_graalvm_distribution ()
3522
+ final_graalvm_distribution = get_final_graalvm_distribution ()
3538
3523
3539
3524
from mx_native import TargetSelection
3540
- for c in _final_graalvm_distribution .components :
3525
+ for c in final_graalvm_distribution .components :
3541
3526
if c .extra_native_targets :
3542
3527
for t in c .extra_native_targets :
3543
3528
mx .logv (f"Selecting extra target '{ t } ' from GraalVM component '{ c .short_name } '." )
@@ -3549,7 +3534,7 @@ def register_main_dist(dist, label):
3549
3534
3550
3535
names = set ()
3551
3536
short_names = set ()
3552
- needs_stage1 = False
3537
+ needs_stage1 = mx_sdk_vm_ng . requires_native_image_stage1 ()
3553
3538
installables = {}
3554
3539
jvmci_parent_jars = []
3555
3540
modified_jmods = {}
@@ -3617,10 +3602,10 @@ def register_main_dist(dist, label):
3617
3602
register_project (native_image_resources_filelist_project )
3618
3603
3619
3604
# Register main distribution
3620
- register_main_dist (_final_graalvm_distribution , 'graalvm' )
3605
+ register_main_dist (final_graalvm_distribution , 'graalvm' )
3621
3606
3622
3607
# Register standalones
3623
- needs_java_standalone_jimage = False
3608
+ needs_java_standalone_jimage = mx_sdk_vm_ng . requires_standalone_jimage ()
3624
3609
for components in installables .values ():
3625
3610
main_component = _get_main_component (components )
3626
3611
svm_support = _get_svm_support ()
@@ -3639,7 +3624,7 @@ def register_main_dist(dist, label):
3639
3624
mx .warn ("Skipping JVM standalone of '{}' because it contains launcher configs that are not yet supported" .format (main_component .name ))
3640
3625
else :
3641
3626
needs_java_standalone_jimage = True
3642
- java_standalone = GraalVmStandaloneComponent (get_component (main_component .name , fatalIfMissing = True ), _final_graalvm_distribution , is_jvm = True , defaultBuild = False )
3627
+ java_standalone = GraalVmStandaloneComponent (get_component (main_component .name , fatalIfMissing = True ), final_graalvm_distribution , is_jvm = True , defaultBuild = False )
3643
3628
register_main_dist (java_standalone , 'graalvm_standalones' )
3644
3629
3645
3630
# Use `main_component.library_configs` rather than `_get_library_configs(main_component)` because we
@@ -3655,7 +3640,7 @@ def register_main_dist(dist, label):
3655
3640
only_native_launchers = not main_component .launcher_configs or has_svm_launcher (main_component )
3656
3641
only_native_libraries = not main_component .library_configs or (svm_support .is_supported () and not _has_skipped_libraries (main_component ))
3657
3642
if only_native_launchers and only_native_libraries :
3658
- native_standalone = GraalVmStandaloneComponent (get_component (main_component .name , fatalIfMissing = True ), _final_graalvm_distribution , is_jvm = False , defaultBuild = False )
3643
+ native_standalone = GraalVmStandaloneComponent (get_component (main_component .name , fatalIfMissing = True ), final_graalvm_distribution , is_jvm = False , defaultBuild = False )
3659
3644
register_main_dist (native_standalone , 'graalvm_standalones' )
3660
3645
3661
3646
if needs_java_standalone_jimage :
@@ -3678,7 +3663,7 @@ def register_main_dist(dist, label):
3678
3663
suite = _suite ,
3679
3664
name = 'java-standalone-jimage' ,
3680
3665
jimage_jars = sorted (java_standalone_jimage_jars ),
3681
- jimage_ignore_jars = sorted (_final_graalvm_distribution .jimage_ignore_jars ),
3666
+ jimage_ignore_jars = sorted (final_graalvm_distribution .jimage_ignore_jars ),
3682
3667
workingSets = None ,
3683
3668
defaultBuild = False ,
3684
3669
missing_export_target_action = 'warn' ,
@@ -3694,32 +3679,34 @@ def register_main_dist(dist, label):
3694
3679
else :
3695
3680
config_class = GraalVmMiscLauncher
3696
3681
for launcher_config in _get_launcher_configs (component ):
3697
- register_project (config_class (component , launcher_config , stage1 = True ))
3698
- for component in registered_graalvm_components (stage1 = False ):
3699
- # native properties in the final distribution also need native properties in the stage1 distribution
3700
- for launcher_config in _get_launcher_configs (component ):
3701
- register_project (GraalVmNativeProperties (component , launcher_config , stage1 = True ))
3702
- for library_config in _get_library_configs (component ):
3703
- register_project (GraalVmNativeProperties (component , library_config , stage1 = True ))
3682
+ register_project (config_class (component , launcher_config , stage1 = True , defaultBuild = False ))
3683
+ if get_component ('svm' , stage1 = True ):
3684
+ for component in registered_graalvm_components (stage1 = False ):
3685
+ # native properties in the final distribution also need native properties in the stage1 distribution
3686
+ for launcher_config in _get_launcher_configs (component ):
3687
+ register_project (GraalVmNativeProperties (component , launcher_config , stage1 = True , defaultBuild = False ))
3688
+ for library_config in _get_library_configs (component ):
3689
+ register_project (GraalVmNativeProperties (component , library_config , stage1 = True , defaultBuild = False ))
3704
3690
register_distribution (get_stage1_graalvm_distribution ())
3705
3691
3706
3692
if register_project :
3707
3693
if needs_stage1 :
3708
- _stage1_graalvm_distribution = get_stage1_graalvm_distribution ()
3709
- if _needs_stage1_jimage (_stage1_graalvm_distribution , _final_graalvm_distribution ):
3694
+ stage1_graalvm_distribution = get_stage1_graalvm_distribution ()
3695
+ if _needs_stage1_jimage (stage1_graalvm_distribution , final_graalvm_distribution ):
3710
3696
register_project (GraalVmJImage (
3711
3697
suite = _suite ,
3712
3698
name = 'graalvm-stage1-jimage' ,
3713
- jimage_jars = sorted (_stage1_graalvm_distribution .jimage_jars ),
3714
- jimage_ignore_jars = sorted (_stage1_graalvm_distribution .jimage_ignore_jars ),
3699
+ jimage_jars = sorted (stage1_graalvm_distribution .jimage_jars ),
3700
+ jimage_ignore_jars = sorted (stage1_graalvm_distribution .jimage_ignore_jars ),
3715
3701
workingSets = None ,
3716
3702
default_to_jvmci = False , # decide depending on the included modules
3703
+ defaultBuild = False ,
3717
3704
))
3718
3705
final_jimage_project = GraalVmJImage (
3719
3706
suite = _suite ,
3720
3707
name = 'graalvm-jimage' ,
3721
- jimage_jars = sorted (_final_graalvm_distribution .jimage_jars ),
3722
- jimage_ignore_jars = sorted (_final_graalvm_distribution .jimage_ignore_jars ),
3708
+ jimage_jars = sorted (final_graalvm_distribution .jimage_jars ),
3709
+ jimage_ignore_jars = sorted (final_graalvm_distribution .jimage_ignore_jars ),
3723
3710
workingSets = None ,
3724
3711
default_to_jvmci = _get_libgraal_component () is not None ,
3725
3712
)
@@ -4377,7 +4364,7 @@ def check_versions(jdk, expect_graalvm, check_jvmci):
4377
4364
mx .log_error (out .data )
4378
4365
mx .abort ("'{}' is not a JVMCI-enabled JDK ('java -XX:+JVMCIPrintProperties' fails).\n {}." .format (jdk .home , check_env ))
4379
4366
4380
- out = _decode ( subprocess .check_output ([jdk .java , '-version' ], stderr = subprocess .STDOUT )).rstrip ()
4367
+ out = subprocess .check_output ([jdk .java , '-version' ], stderr = subprocess .STDOUT ). decode ( ).rstrip ()
4381
4368
4382
4369
jdk_version = jdk .version
4383
4370
if os .environ .get ('JDK_VERSION_CHECK' , None ) != 'ignore' and (jdk_version <= mx .VersionSpec ('1.8' ) or mx .VersionSpec ('9' ) <= jdk_version < mx .VersionSpec ('11' )):
@@ -4399,7 +4386,7 @@ def graalvm_vm_name(graalvm_dist, jdk):
4399
4386
:type jdk_home: str
4400
4387
:rtype str:
4401
4388
"""
4402
- out = _decode ( subprocess .check_output ([jdk .java , '-version' ], stderr = subprocess .STDOUT )).rstrip ()
4389
+ out = subprocess .check_output ([jdk .java , '-version' ], stderr = subprocess .STDOUT ). decode ( ).rstrip ()
4403
4390
match = re .search (r'^(?P<base_vm_name>[a-zA-Z() ]+64-Bit Server VM )' , out .split ('\n ' )[- 1 ])
4404
4391
vm_name = match .group ('base_vm_name' ) if match else ''
4405
4392
return vm_name + graalvm_vendor_version ()
@@ -4592,15 +4579,16 @@ def _expand_native_images_list(only):
4592
4579
return only
4593
4580
4594
4581
4595
- def _force_bash_launchers (launcher ):
4582
+ def _force_bash_launchers (launcher , build_by_default = None ):
4596
4583
"""
4597
4584
:type launcher: str | mx_sdk.LauncherConfig
4598
4585
"""
4599
4586
launcher_name = _get_launcher_name (launcher )
4600
4587
4601
4588
forced = _parse_cmd_arg ('force_bash_launchers' )
4602
- default = has_vm_suite () or forced is not None # for compatibility with legacy behavior
4603
- only = _parse_cmd_arg ('native_images' , default_value = str (default ))
4589
+ if build_by_default is None :
4590
+ build_by_default = has_vm_suite () or forced is not None # for compatibility with legacy behavior
4591
+ only = _parse_cmd_arg ('native_images' , default_value = str (build_by_default ))
4604
4592
only = _expand_native_images_list (only )
4605
4593
if isinstance (only , bool ):
4606
4594
included = only
@@ -4615,15 +4603,16 @@ def _force_bash_launchers(launcher):
4615
4603
return not included
4616
4604
4617
4605
4618
- def _skip_libraries (library ):
4606
+ def _skip_libraries (library , build_by_default = None ):
4619
4607
"""
4620
4608
:type library: str | mx_sdk.LibraryConfig
4621
4609
"""
4622
4610
library_name = _get_library_name (library )
4623
4611
4624
4612
skipped = _parse_cmd_arg ('skip_libraries' )
4625
- default = has_vm_suite () or skipped is not None # for compatibility with legacy behavior
4626
- only = _parse_cmd_arg ('native_images' , default_value = str (default ))
4613
+ if build_by_default is None :
4614
+ build_by_default = has_vm_suite () or skipped is not None # for compatibility with legacy behavior
4615
+ only = _parse_cmd_arg ('native_images' , default_value = str (build_by_default ))
4627
4616
only = _expand_native_images_list (only )
4628
4617
if isinstance (only , bool ):
4629
4618
included = only
@@ -4765,12 +4754,15 @@ def _generate_debuginfo(image_config):
4765
4754
elif isinstance (generate_debuginfo , bool ):
4766
4755
return generate_debuginfo
4767
4756
else :
4768
- destination = image_config .destination if isinstance (image_config , mx_sdk .AbstractNativeImageConfig ) else image_config
4769
- if isinstance (image_config , mx_sdk .LauncherConfig ):
4770
- name = basename (remove_exe_suffix (destination , require_suffix = False ))
4771
- elif isinstance (image_config , mx_sdk .LibraryConfig ):
4772
- name = remove_lib_prefix_suffix (basename (destination ), require_suffix_prefix = False )
4773
- generate_debuginfo = [lib [4 :] for lib in generate_debuginfo if lib .startswith ('lib:' )]
4757
+ if isinstance (image_config , str ):
4758
+ name = image_config
4759
+ else :
4760
+ destination = image_config .destination if isinstance (image_config , mx_sdk .AbstractNativeImageConfig ) else image_config
4761
+ if isinstance (image_config , mx_sdk .LauncherConfig ):
4762
+ name = basename (remove_exe_suffix (destination , require_suffix = False ))
4763
+ elif isinstance (image_config , mx_sdk .LibraryConfig ):
4764
+ name = remove_lib_prefix_suffix (basename (destination ), require_suffix_prefix = False )
4765
+ generate_debuginfo = [lib [4 :] for lib in generate_debuginfo if lib .startswith ('lib:' )]
4774
4766
return name in generate_debuginfo
4775
4767
4776
4768
0 commit comments