You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide tools to build unchained language standalones
Add `mx_sdk_vm_ng` with a number of helper project, build tasks, and
distributions that can be used to build "unchained" language standalone.
In particular they allow building native images using a bootstrap
GraalVM (or the current stage1) without requiring the input jars and
build arguments to be part of a legacy stage1 GraalVM.
* `NativeImageLibraryProject` allows defining shared libraries built
with native-image:
```
"mylib": {
"class": "NativeImageLibraryProject",
"dependencies": ["SOME_JAR"],
"build_args": ["-R:+InstallSegfaultHandler"],
},
```
There is also the `LanguageLibraryProject` subclass that has good
defaults for truffle languages.
By default, if the `substratevm` suite is loaded, it will use
native-image from the current legacy stage1 GraalVM. If `substartevm`
is not loaded, those native image projects will be ignored and liklely
cause layout distributions that contain them to be recursively
ignored.
If the `BOOTSTRAP_GRAALVM` environment variable is set, it will be
used to build those native images instead. If this is not set but
`JAVA_HOME` contains the native-image tools, it will be used.
These projects are build by default and respect
`mx --native-images=...` arguments.
* `NativeImageExecutableProject` is similar but is used to build
executables instead of shared library.
* `ThinLauncherProject` allows building a thin native launcher that can
be used to start a JVM or a native language library:
```
"mylauncher": {
"class": "ThinLauncherProject",
"mainClass": "org.example.MyLauncher",
"jar_distributions": ["MY_LAUNCHER"],
"relative_jre_path": "../jvm", # for JVM mode
"relative_module_path": "../modules", # for JVM mode
},
```
* `StandaloneLicenses` can be used to provide licenses that can be used
in a layout distribution. It adapts to the current context being
"community" or "enterprise":
```
"truffleruby_licenses": {
"class": "StandaloneLicenses",
"community_license_file": "LICENCE.md",
"community_3rd_party_license_file": "3rd_party_licenses.txt",
},
```
* `JavaHomeDependency` can be used to represent a java home in the mx
build system. It can be used in layout distributions to copy a JDK.
* `DynamicPOMDistribution` is like mx's `POMDistribution` but
additionally supports `dynamicDistDependencies` and
`dynamicDistDependencies` attributes which call back into the suite's
mx extensions to dynamically retrieve a list of distributions. This
can replace the use of `mx_register_dynamic_suite_constituents`.
```python filename="suite.py"
"MY_DISTRIBUTION": {
"class": "DynamicPOMDistribution",
"distDependencies": ["A_STATIC_DEPENDENCY"],
"dynamicDistDependencies": "my_callback",
},
```
```python filename="mx_mysuite.py"
def my_callback():
return [] if foo else ['A_DYNAMIC_DEPENDENCY']
```
* `DeliverableStandaloneArchive` can be used to make an archive for a
standalone based on a layout "dir" distribution. It will adjust its
name based on the current context being "community" or "enterprise".
It ensure that the archive has a single root directory for easy
consumption by user (multiple `tar xf ...` in the same directory will
not conflit).
* `sdk:STANDALONE_JAVA_HOME` is a dependency that can be used in a
layout distribution to get a JDK that can be used in a standalone.
The `STANDALONE_JAVA_HOME` environment variable can be used to point
at an explicit JDK. Otherwise it will be the `BOOTSTRAP_GRAALVM` if it
is set. If `BOOTSTRAP_GRAALVM` was not set but `JAVA_HOME` contains
the native-image tool, `JAVA_HOME` is used.
If none of the above works, it will be similar to the JDK that used to
be inserted into legacy standalones: a special jlink'd JDK that
contains the sdk and libgraal if it is available.
* `sdk:TOOLS_FOR_STANDALONE` is a convenience pom distribution that can
be used to depend on all known tools if they are available.
* `ExtractedEngineResources` can be used to obtain the engine resources
for use in a layout distributions.
```
"my-resources": {
"class": "ExtractedEngineResources",
"dependencies": ['LANG_AND_RESOURCES_DISTS'],
},
...
"layout": {
"resources/": "dependency:my-resources/mylang/*",
},
```
Note that native image projects also produce copied internal resources
if `-H:+CopyLanguageResources` is used.
* Define TRUFFLE_ATTACH_GRAALVM_SUPPORT to be used for standalones:
```
"jvmlibs/": [
"extracted-dependency:truffle:TRUFFLE_ATTACH_GRAALVM_SUPPORT",
"extracted-dependency:truffle:TRUFFLE_NFI_NATIVE_GRAALVM_SUPPORT",
],
```
Co-authored-by: Benoit Daloze <[email protected]>
0 commit comments