Skip to content

Commit 2d1aaca

Browse files
committed
Refine is_module_launcher into use_modules to allow differentiating module laucher and module image-build
1 parent 38ced72 commit 2d1aaca

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

sdk/mx.sdk/mx_sdk_vm.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ def __prepare__(mcs, name, this_bases):
9393

9494

9595
class AbstractNativeImageConfig(_with_metaclass(ABCMeta, object)):
96-
def __init__(self, destination, jar_distributions, build_args, is_module_launcher=False, links=None, is_polyglot=False, dir_jars=False, home_finder=False, build_time=1): # pylint: disable=super-init-not-called
96+
def __init__(self, destination, jar_distributions, build_args, use_modules=None, links=None, is_polyglot=False, dir_jars=False, home_finder=False, build_time=1): # pylint: disable=super-init-not-called
9797
"""
9898
:type destination: str
9999
:type jar_distributions: list[str]
100100
:type build_args: list[str]
101-
:type is_module_launcher: bool
102101
:type links: list[str]
102+
:param str use_modules: Run (with 'laucher') or run and build image with module support (with 'image').
103103
:param bool dir_jars: If true, all jars in the component directory are added to the classpath.
104104
"""
105105
self.destination = mx_subst.path_substitutions.substitute(destination)
106106
self.jar_distributions = jar_distributions
107107
self.build_args = build_args
108-
self.module_launcher = is_module_launcher
108+
self.use_modules = use_modules
109109
self.links = [mx_subst.path_substitutions.substitute(link) for link in links] if links else []
110110
self.is_polyglot = is_polyglot
111111
self.dir_jars = dir_jars
@@ -135,20 +135,20 @@ def get_add_exports_list(required_exports, custom_target_module_str=None):
135135
class LauncherConfig(AbstractNativeImageConfig):
136136
def __init__(self, destination, jar_distributions, main_class, build_args, is_main_launcher=True,
137137
default_symlinks=True, is_sdk_launcher=False, custom_launcher_script=None, extra_jvm_args=None,
138-
is_module_launcher=False, main_module=None, option_vars=None, home_finder=True, **kwargs):
138+
use_modules=None, main_module=None, option_vars=None, home_finder=True, **kwargs):
139139
"""
140140
:param str main_class
141141
:param bool is_main_launcher
142142
:param bool default_symlinks
143143
:param bool is_sdk_launcher: Whether it uses org.graalvm.launcher.Launcher
144-
:param bool is_module_launcher: Whether it uses classpath or module-path for the application
145-
:param str main_module: Specifies the main module. Mandatory if this is a module_launcher
144+
:param str use_modules: Run (with 'laucher') or run and build image with module support (with 'image').
145+
:param str main_module: Specifies the main module. Mandatory if use_modules is not None
146146
:param str custom_launcher_script: Custom launcher script, to be used when not compiled as a native image
147147
"""
148-
super(LauncherConfig, self).__init__(destination, jar_distributions, build_args, is_module_launcher, home_finder=home_finder, **kwargs)
148+
super(LauncherConfig, self).__init__(destination, jar_distributions, build_args, use_modules, home_finder=home_finder, **kwargs)
149149
self.main_class = main_class
150150
self.is_main_launcher = is_main_launcher
151-
assert not is_module_launcher or main_module
151+
assert use_modules is None or main_module
152152
self.main_module = main_module
153153
self.default_symlinks = default_symlinks
154154
self.is_sdk_launcher = is_sdk_launcher
@@ -165,7 +165,7 @@ def add_relative_home_path(self, language, path):
165165
self.relative_home_paths[language] = path
166166

167167
def get_add_exports(self, missing_jars):
168-
if not self.module_launcher:
168+
if self.use_modules is None:
169169
return ''
170170
distributions = self.jar_distributions
171171
distributions_transitive = mx.classpath_entries(distributions)

sdk/mx.sdk/mx_sdk_vm_impl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,12 +1286,13 @@ def _write_ln(s):
12861286
_write_ln(u'ImagePath=' + java_properties_escape("${.}/" + relpath(dirname(graalvm_image_destination), graalvm_location).replace(os.sep, '/')))
12871287
if requires:
12881288
_write_ln(u'Requires=' + java_properties_escape(' '.join(requires), ' ', len('Requires')))
1289+
build_with_module_path = image_config.use_modules == 'image'
12891290
if isinstance(image_config, mx_sdk.LauncherConfig):
12901291
_write_ln(u'ImageClass=' + java_properties_escape(image_config.main_class))
1291-
if image_config.module_launcher:
1292+
if build_with_module_path:
12921293
_write_ln(u'ImageModule=' + java_properties_escape(image_config.main_module))
12931294
if location_classpath:
1294-
image_path_arg = u'ImageModulePath=' if image_config.module_launcher else u'ImageClasspath='
1295+
image_path_arg = u'ImageModulePath=' if build_with_module_path else u'ImageClasspath='
12951296
_write_ln(image_path_arg + java_properties_escape(':'.join(("${.}/" + e.replace(os.sep, '/') for e in location_classpath)), ':', len('ImageClasspath')))
12961297
_write_ln(u'Args=' + java_properties_escape(' '.join(build_args), ' ', len('Args')))
12971298
return self._contents
@@ -1845,7 +1846,7 @@ def _get_main_class():
18451846
return self.subject.native_image_config.main_class
18461847

18471848
def _is_module_launcher():
1848-
return str(self.subject.native_image_config.module_launcher)
1849+
return str(self.subject.native_image_config.use_modules is not None)
18491850

18501851
def _get_main_module():
18511852
return str(self.subject.native_image_config.main_module)

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ def _native_image_launcher_extra_jvm_args():
894894
support_distributions=['substratevm:NATIVE_IMAGE_GRAALVM_SUPPORT'],
895895
launcher_configs=[
896896
mx_sdk_vm.LauncherConfig(
897-
is_module_launcher=not svm_java8(),
897+
use_modules='image' if USE_NI_JPMS else 'launcher' if not svm_java8() else None,
898898
destination="bin/<exe:native-image>",
899899
jar_distributions=["substratevm:SVM_DRIVER"],
900900
main_module="org.graalvm.nativeimage.driver",

0 commit comments

Comments
 (0)