Skip to content

Commit 482fcb2

Browse files
Allow loading espresso-compiler-stub when no standalone can be built
It is no longer fatal when none of the "ESPRESSO_NI" standalones can be built. This is useful for example when running unit tests.
1 parent aef9986 commit 482fcb2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

espresso-compiler-stub/mx.espresso-compiler-stub/mx_espresso_compiler_stub.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import mx_sdk_vm
2828
import mx_gate
2929

30-
from mx_espresso import _espresso_stability, _has_native_espresso_standalone, _send_sigquit, get_java_home_dep, _jdk_lib_dir, jvm_standalone_with_llvm
30+
from mx_espresso import _espresso_stability, _send_sigquit, get_java_home_dep, _jdk_lib_dir, jvm_standalone_with_llvm
3131
from mx_sdk_vm_ng import _find_native_image_command, ThinLauncherProject # pylint: disable=unused-import
3232
from mx_sdk_vm_impl import get_final_graalvm_distribution, has_component, graalvm_skip_archive
3333

@@ -113,7 +113,7 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
113113
native = create_ni_standalone('ESPRESSO_NATIVE_STANDALONE', register_distribution)
114114
jvm = create_ni_standalone('ESPRESSO_JVM_STANDALONE', register_distribution)
115115
if not (native or jvm):
116-
raise mx.abort("Couldn't create any Espresso native-image standalone")
116+
mx.warn("Couldn't create any Espresso native-image standalone")
117117

118118
def _run_espresso_native_image_launcher(args, cwd=None, nonZeroIsFatal=True, out=None, err=None, timeout=None, mode=None):
119119
extra_args = ['-J--vm.' + arg for arg in mx_gate.get_jacoco_agent_args() or []]
@@ -139,10 +139,16 @@ def _run_espresso_native_image_launcher(args, cwd=None, nonZeroIsFatal=True, out
139139
return mx.run([native_image_command] + extra_args + args, cwd=cwd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, timeout=timeout, on_timeout=_send_sigquit)
140140

141141
def _detect_espresso_native_image_mode():
142-
if _has_native_espresso_standalone() and exists(mx.distribution('ESPRESSO_NI_NATIVE_STANDALONE').get_output()):
142+
native_dist = mx.distribution('ESPRESSO_NI_NATIVE_STANDALONE', fatalIfMissing=False)
143+
jvm_dist = mx.distribution('ESPRESSO_JVM_NATIVE_STANDALONE', fatalIfMissing=False)
144+
if native_dist and exists(native_dist.get_output()):
143145
return 'native'
144-
else:
146+
elif jvm_dist and exists(jvm_dist.get_output()):
145147
return 'jvm'
148+
elif jvm_dist or native_dist:
149+
raise mx.abort("No espresso Native Image Standalone is built")
150+
else:
151+
raise mx.abort("No espresso Native Image Standalone is available (see warnings above)")
146152

147153
def _run_espresso_native_image_jvm_launcher(args, cwd=None, nonZeroIsFatal=True, out=None, err=None, timeout=None):
148154
return _run_espresso_native_image_launcher(args, cwd, nonZeroIsFatal, out, err, timeout, mode='jvm')

0 commit comments

Comments
 (0)