|
| 1 | +# |
| 2 | +# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. |
| 3 | +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | +# |
| 5 | +# This code is free software; you can redistribute it and/or modify it |
| 6 | +# under the terms of the GNU General Public License version 2 only, as |
| 7 | +# published by the Free Software Foundation. |
| 8 | +# |
| 9 | +# This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | +# version 2 for more details (a copy is included in the LICENSE file that |
| 13 | +# accompanied this code). |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License version |
| 16 | +# 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | +# |
| 19 | +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | +# or visit www.oracle.com if you need additional information or have any |
| 21 | +# questions. |
| 22 | +# |
| 23 | +from os.path import exists |
| 24 | + |
| 25 | +import mx |
| 26 | +import mx_sdk_vm |
| 27 | +import mx_sdk_vm_impl |
| 28 | +import mx_gate |
| 29 | + |
| 30 | +from mx_espresso import _espresso_stability, espresso_library_config, _espresso_command, _send_sigquit, _llvm_toolchain_wrappers |
| 31 | + |
| 32 | +_suite = mx.suite('espresso-compiler-stub') |
| 33 | + |
| 34 | +mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmLanguage( |
| 35 | + suite=_suite, |
| 36 | + name='Espresso Compiler Stub', |
| 37 | + short_name='ecs', |
| 38 | + license_files=[], |
| 39 | + third_party_license_files=[], |
| 40 | + truffle_jars=[], |
| 41 | + dir_name='java', |
| 42 | + installable_id='espresso-compiler-stub', |
| 43 | + installable=True, |
| 44 | + dependencies=['Java on Truffle'], |
| 45 | + support_distributions=['espresso-compiler-stub:ESPRESSO_COMPILER_SUPPORT'], |
| 46 | + priority=2, |
| 47 | + stability=_espresso_stability, |
| 48 | + standalone=False, |
| 49 | +)) |
| 50 | + |
| 51 | + |
| 52 | +def _run_espresso_native_image_launcher(args, cwd=None, nonZeroIsFatal=True, out=None, err=None, timeout=None): |
| 53 | + extra_args = ['-J--vm.' + arg for arg in mx_gate.get_jacoco_agent_args() or []] |
| 54 | + if mx_sdk_vm_impl._skip_libraries(espresso_library_config): |
| 55 | + # JVM mode |
| 56 | + espresso_launcher = _espresso_command('espresso', [])[0] |
| 57 | + if not exists(espresso_launcher): |
| 58 | + raise mx.abort("It looks like JVM mode but the espresso launcher does not exist") |
| 59 | + extra_args += [ |
| 60 | + '--vm.Dcom.oracle.svm.driver.java.executable.override=' + espresso_launcher, |
| 61 | + '-J--java.GuestFieldOffsetStrategy=graal', |
| 62 | + '-J--java.NativeBackend=nfi-llvm', |
| 63 | + ] |
| 64 | + native_image_command = _espresso_command('native-image', extra_args + args) |
| 65 | + if not exists(native_image_command[0]): |
| 66 | + raise mx.abort("The native-image launcher does not exist") |
| 67 | + return mx.run(native_image_command, cwd=cwd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, timeout=timeout, on_timeout=_send_sigquit) |
| 68 | + |
| 69 | + |
| 70 | +mx.update_commands(_suite, { |
| 71 | + 'espresso-native-image': [_run_espresso_native_image_launcher, '[args]'], |
| 72 | +}) |
| 73 | + |
| 74 | +mx_sdk_vm.register_vm_config('espresso-ni-ce', ['java', 'ejvm', 'ejc', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'cmp', 'svm', 'svmt', 'svmsl', 'tflm', 'bnative-image', 'ni', 'nil', 'tflsm', 'snative-image-agent', 'snative-image-diagnostics-agent', 'ecs'], _suite, env_file='espresso-ni') # pylint: disable=line-too-long |
| 75 | +mx_sdk_vm.register_vm_config('espresso-ni-jvm-ce', ['java', 'ejvm', 'elau', 'ellvm', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'cmp', 'antlr4', 'llrc', 'llrlf', 'llrn', 'svm', 'svmt', 'svmsl', 'tflm', 'bnative-image', 'ni', 'nil', 'tflsm', 'snative-image-agent', 'snative-image-diagnostics-agent', 'lg', 'sjavavm', 'bespresso', 'ecs'] + _llvm_toolchain_wrappers, _suite, env_file='espresso-ni-jvm') # pylint: disable=line-too-long |
0 commit comments