Skip to content

Commit

Permalink
Add support for suite:$NAME to include or exclude all components of a…
Browse files Browse the repository at this point in the history
… suite

* For instance, COMPONENTS=foo,suite:tools includes all components
  registered by the 'tools' suite, as well as component 'foo'.
  • Loading branch information
eregon committed Nov 16, 2020
1 parent 1e6b914 commit f6cf448
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
24 changes: 20 additions & 4 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2682,8 +2682,8 @@ def graalvm_vendor_version(graalvm_dist):
vendor_version += ' {}'.format(graalvm_version())
return vendor_version

mx.add_argument('--components', action='store', help='Comma-separated list of component names to build. Only those components and their dependencies are built.')
mx.add_argument('--exclude-components', action='store', help='Comma-separated list of component names to be excluded from the build.')
mx.add_argument('--components', action='store', help='Comma-separated list of component names to build. Only those components and their dependencies are built. suite:NAME can be used to exclude all components of a suite.')
mx.add_argument('--exclude-components', action='store', help='Comma-separated list of component names to be excluded from the build. suite:NAME can be used to exclude all components of a suite.')
mx.add_argument('--disable-libpolyglot', action='store_true', help='Disable the \'polyglot\' library project.')
mx.add_argument('--disable-polyglot', action='store_true', help='Disable the \'polyglot\' launcher project.')
mx.add_argument('--disable-installables', action='store', help='Disable the \'installable\' distributions for gu.'
Expand Down Expand Up @@ -2753,14 +2753,30 @@ def _components_include_list():
included = _parse_cmd_arg('components', parse_bool=False, default_value=None)
if included is None:
return None
return [mx_sdk.graalvm_component_by_name(name) for name in included]
components = []
for name in included:
if name.startswith('suite:'):
suite_name = name[len('suite:'):]
components.extend([c for c in mx_sdk_vm.graalvm_components() if c.suite.name == suite_name])
else:
components.append(mx_sdk.graalvm_component_by_name(name))
return components


def _excluded_components():
excluded = _parse_cmd_arg('exclude_components', parse_bool=False, default_value='')
if mx.get_opts().disable_polyglot or _env_var_to_bool('DISABLE_POLYGLOT'):
excluded.append('poly')
return excluded

expanded = []
for name in excluded:
if name.startswith('suite:'):
suite_name = name[len('suite:'):]
expanded.extend([c.name for c in mx_sdk_vm.graalvm_components() if c.suite.name == suite_name])
else:
expanded.append(name)

return expanded


def _extra_image_builder_args(image):
Expand Down
8 changes: 5 additions & 3 deletions vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,20 @@ mx --dy truffleruby --components='TruffleRuby' build

### Example: build only the TruffleRuby launcher
```bash
mx --dy truffleruby,/substratevm --components='TruffleRuby,Native Image' --native-images=truffleruby build
mx --dy truffleruby,/substratevm,/tools --components='TruffleRuby,Native Image,suite:tools' --native-images=truffleruby build
```
or as env file (e.g., in `mx.vm/ruby`):
```
DYNAMIC_IMPORTS=truffleruby,/substratevm
COMPONENTS=TruffleRuby,Native Image
DYNAMIC_IMPORTS=truffleruby,/substratevm,/tools
COMPONENTS=TruffleRuby,Native Image,suite:tools
NATIVE_IMAGES=truffleruby
```
```bash
$ mx --env ruby build
```

This also include all tools, which is of course optional.

## Versioned dynamic imports
Dynamic imports typically require the user to locate and clone the dynamically imported suites.
There is also no indication of which version of those suites would work.
Expand Down

0 comments on commit f6cf448

Please sign in to comment.