|
50 | 50 | import json |
51 | 51 | import os |
52 | 52 | from os.path import relpath, join, dirname, basename, exists, isfile, normpath, abspath, isdir, islink, isabs |
| 53 | +import pipes |
53 | 54 | import pprint |
54 | 55 | import re |
55 | 56 | import shlex |
@@ -330,6 +331,8 @@ def _get_main_component(components): |
330 | 331 | """:type: dict[str, (str, str)]""" |
331 | 332 | _parent_info_cache = {} |
332 | 333 |
|
| 334 | +_jlink_copy_plugin = None |
| 335 | + |
333 | 336 | def _graalvm_maven_attributes(tag='graalvm'): |
334 | 337 | """ |
335 | 338 | :type tag: str |
@@ -609,7 +612,7 @@ def _find_escaping_links(root_dir): |
609 | 612 | _libpolyglot_component = mx_sdk_vm.graalvm_component_by_name('libpoly', fatalIfMissing=False) |
610 | 613 | assert _libpolyglot_component is None or len(_libpolyglot_component.library_configs) == 1 |
611 | 614 | _libpolyglot_macro_dir = (_macros_dir + '/' + GraalVmNativeProperties.macro_name(_libpolyglot_component.library_configs[0]) + '/') if _macros_dir is not None and _libpolyglot_component is not None else None |
612 | | - |
| 615 | + _jlink_copyfiles = set() |
613 | 616 | for _component in sorted(self.components, key=lambda c: c.name): |
614 | 617 | mx.logv('Adding {} ({}) to the {} {}'.format(_component.name, _component.__class__.__name__, name, self.__class__.__name__)) |
615 | 618 | _component_type_base = _get_component_type_base(_component) |
@@ -724,7 +727,11 @@ def _find_escaping_links(root_dir): |
724 | 727 | _svm_library_home = _component_base |
725 | 728 | _svm_library_dest = _svm_library_home + _library_config.destination |
726 | 729 | if not stage1 and _get_svm_support().is_supported(): |
727 | | - _source_type = 'skip' if _skip_libraries(_library_config) else 'dependency' |
| 730 | + if _skip_libraries(_library_config): |
| 731 | + _source_type = 'skip' |
| 732 | + else: |
| 733 | + _source_type = 'dependency' |
| 734 | + _jlink_copyfiles.add(_svm_library_dest[len('<jre_base>/'):]) |
728 | 735 | _library_project_name = GraalVmNativeImage.project_name(_library_config) |
729 | 736 | # add `LibraryConfig.destination` and the generated header files to the layout |
730 | 737 | _add(layout, _svm_library_dest, _source_type + ':' + _library_project_name, _component) |
@@ -794,6 +801,9 @@ def _find_escaping_links(root_dir): |
794 | 801 | _metadata = self._get_metadata(_suites) |
795 | 802 | _add(layout, _base + 'release', "string:{}".format(_metadata)) |
796 | 803 |
|
| 804 | + if is_graalvm and add_jdk_base and _has_jlink_copy_plugin() and _jlink_copyfiles: |
| 805 | + _add(layout, '<jdk_base>/conf/jlink.copyfiles', 'string:{}'.format('\n'.join(sorted(_jlink_copyfiles)))) |
| 806 | + |
797 | 807 | if has_graal_compiler: |
798 | 808 | _add(layout, '<jre_base>/lib/jvmci/compiler-name', 'string:graal') |
799 | 809 |
|
@@ -3748,6 +3758,18 @@ def _base_jdk_info(): |
3748 | 3758 | return base_jdk_info.split(':') |
3749 | 3759 |
|
3750 | 3760 |
|
| 3761 | +def _has_jlink_copy_plugin(): |
| 3762 | + global _jlink_copy_plugin |
| 3763 | + if _jlink_copy_plugin is None: |
| 3764 | + out = mx.LinesOutputCapture() |
| 3765 | + args = [_src_jdk.exe_path('jlink'), '--list-plugins'] |
| 3766 | + exit_status = mx.run(args, out=out, err=out, nonZeroIsFatal=False) |
| 3767 | + if exit_status: |
| 3768 | + raise mx.abort('Failed to run \"{}\". Output:\n{}'.format(' '.join([pipes.quote(str(arg)) for arg in args]), '\n'.join(out.lines))) |
| 3769 | + _jlink_copy_plugin = any('--copy-files' in line for line in out.lines) |
| 3770 | + return _jlink_copy_plugin |
| 3771 | + |
| 3772 | + |
3751 | 3773 | def mx_post_parse_cmd_line(args): |
3752 | 3774 | if _src_jdk_version >= 9: |
3753 | 3775 | for component in registered_graalvm_components(): |
|
0 commit comments