Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ build:source-native-image --config=labsjdk
build:source-native-image --tool_java_runtime_version=labsjdk_25
build:source-native-image --config=elide-processors
build:source-native-image --extra_toolchains=//graal:source_native_image_toolchain

# The SDK and Truffle API references (//graal/apidocs). elide-dev/doclet needs JDK 25, and javadoc
# must run on a JDK without GraalVM modules, so the doclet and javadoc use Labs JDK 25.
build:apidocs --config=labsjdk
build:apidocs --tool_java_runtime_version=labsjdk_25
build:apidocs --config=elide-processors
2 changes: 2 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
bazelisk test --test_output=errors //graal:sdk_toolchain_descriptors_test
bazelisk test --test_output=errors --config=elide-processors //... @graal//sdk/... @graal//truffle/... @graal//compiler/... @graal//regex/... @graal//tools/...
bazelisk test --test_output=errors --config=elide-processors --config=labsjdk @graal//substratevm/... @graal//substratevm:support_distributions @graal//substratevm:test_distributions @graal//vm:VM_GRAALVM_SUPPORT //graal:source_native_image_test
bazelisk test --test_output=errors --config=apidocs //graal/apidocs:apidocs_test
bazelisk test --test_output=errors --config=elide-python --config=elide-processors //mx:export_test //mx:pack_jar_test //graal:truffle_layout_test //graal/nativebridge:launcher_test //graal:launcher_modules_test @graal//truffle:sl.test.Fibonacci @graal//compiler:GR36613Test
- name: Test on BuildBuddy
if: github.event_name != 'pull_request'
Expand All @@ -55,6 +56,7 @@ jobs:
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=elide-processors //... @graal//sdk/... @graal//truffle/... @graal//compiler/... @graal//regex/... @graal//tools/...
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=elide-processors --config=labsjdk @graal//substratevm/... @graal//substratevm:support_distributions @graal//substratevm:test_distributions @graal//vm:VM_GRAALVM_SUPPORT //graal:source_native_image_test
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=labsjdk //graal:panama_module_test //mx:export_test //graal:launcher_modules_test //graal:truffle_polyglot_test //graal:truffle_runtime_modules_test @graal//truffle:sl.test.Fibonacci
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=apidocs //graal/apidocs:apidocs_test
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=elide-python --config=elide-processors //mx:export_test //mx:pack_jar_test //graal:truffle_layout_test //graal/nativebridge:launcher_test //graal:launcher_modules_test @graal//truffle:sl.test.Fibonacci @graal//compiler:GR36613Test
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=source-native-image //graal:source_native_image_action_test @graal//substratevm:com.oracle.svm.with.space.test.com.oracle.svm.with.space.test.NativeImageResourceTest
tools/buildbuddy test --test_output=errors --config=buildbuddy-rbe --config=native-image-linux //tests/native_image:checkcopy_test //graal/nativebridge:native_isolate_test
24 changes: 19 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module(
bazel_dep(name = "rules_java", version = "9.9.0")
bazel_dep(name = "rules_python", version = "1.9.2")
bazel_dep(name = "rules_elide", version = "0.6.1")
# rules_elide has no release with the unified JVM builder, Native Image toolchain and
# JavaBuilder processor fixes yet, so pin its main branch by commit.
# rules_elide has no release with the unified JVM builder, Native Image toolchain,
# JavaBuilder processor fixes and elide_apidocs yet, so pin its main branch by commit.
archive_override(
module_name = "rules_elide",
integrity = "sha256-//E8/7JDZWKKiQg4edEJN8ye3S8VaD5EhsQe60GYhnM=",
strip_prefix = "rules_elide-50e0e8f8b3696a86b4294491740434db4e9d4260",
urls = ["https://github.com/elide-dev/rules_elide/archive/50e0e8f8b3696a86b4294491740434db4e9d4260.tar.gz"],
integrity = "sha256-45px5H5DlFKasbn66kMhVgE+1w/jrTOW/JrkRC3SNjY=",
strip_prefix = "rules_elide-a4ed40d092d21f8f4aaafa2eecba60398bbaf817",
urls = ["https://github.com/elide-dev/rules_elide/archive/a4ed40d092d21f8f4aaafa2eecba60398bbaf817.tar.gz"],
)

bazel_dep(name = "gazelle", version = "0.54.0")
Expand Down Expand Up @@ -168,6 +168,20 @@ hsdis(
bazel_dep(name = "bazel_skylib", version = "1.9.2", dev_dependency = True)
bazel_dep(name = "rules_license", version = "1.0.0", dev_dependency = True)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# elide-dev/doclet renders the SDK and Truffle API references (//graal/apidocs). It has no
# release, so build it from a pinned commit: main plus the fix for malformed block tags
# (elide-dev/doclet, branch fix/erroneous-block-tag). Move the pin to main once that merges.
http_archive(
name = "elide_doclet",
build_file = "//graal/apidocs:doclet.BUILD.bazel",
dev_dependency = True,
integrity = "sha256-DFI0X2/eoSEDmGZnbDYD4VIRAsrHVZvCuIKh4JG8tws=",
strip_prefix = "doclet-9e1c00741d087297dd9339518cca3d9d9d200edb",
urls = ["https://github.com/elide-dev/doclet/archive/9e1c00741d087297dd9339518cca3d9d9d200edb.tar.gz"],
)

libffi = use_repo_rule("//graal:libffi.bzl", "graal_libffi")

libffi(
Expand Down
16 changes: 16 additions & 0 deletions graal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ The hosted tests (`SVM_HOSTED_TESTS`, mx's `svm-invariants-tests` configuration)
- `SVM_GRAALVM_SUPPORT` packages the debug helpers, `SVM_HOSTED_NATIVE`, the reporter library, zstd-jni, the reachability metadata schema and the skills. On macOS AArch64 it also contains the pinned standalone `ld64.lld`.
- `com.oracle.svm.native.jvm.windows` is compatible only with Windows targets. rules_mx pins no Windows Labs JDK, so building it also needs a Windows Labs JDK registered as `//tools:labs_runtime` for the JVM function fallbacks.

## API references

```sh
bazelisk test --config=apidocs //graal/apidocs:apidocs_test
bazelisk build --config=apidocs //graal/apidocs:sdk //graal/apidocs:truffle
bazelisk build --config=apidocs --//graal/apidocs:version=25.6.0-elide.1 --//graal/apidocs:source_ref="$SHA" //graal/apidocs:sdk
```

`//graal/apidocs:sdk` and `//graal/apidocs:truffle` render the GraalVM SDK and Truffle Java API references with [elide-dev/doclet](https://github.com/elide-dev/doclet), through rules_elide's `elide_apidocs`. Each produces a site directory (`<name>_site`) and a reproducible `<name>.tar.gz`. The SDK reference documents the packages of `org.graalvm.{collections,home,nativeimage,options,polyglot,word}`. The Truffle reference documents the projects of `mx truffle javadoc`: the SDK set, `com.oracle.svm.core.annotate` and the `com.oracle.truffle.api*` projects. As in mx, only packages with a `package-info.java` are documented, so the implementation packages are left out. `apidocs_test` checks both package sets.

Javadoc runs once per reference, in unnamed-module `-sourcepath` mode, over the source jars of the Bazel-built projects. The compile classpath of those projects supplies the classes that Truffle's annotation processors generate. `--config=apidocs` selects Labs JDK 25: the doclet needs JDK 25, and a GraalVM JDK fails with "package exists in another module". The targets are tagged `manual`, so `//...` skips them. JDK types link to the JDK 25 reference through the checked-in `graal/apidocs/jdk/element-list`. The doclet is built from a pinned commit (`@elide_doclet` in `MODULE.bazel`).

The `version` and `source_ref` build settings name the release. The version becomes the library version and the canonical base URL, `https://static.elideusercontent.com/graalvm/javadoc/<sdk|truffle>/<version>/`. elide-dev/graal's API reference workflow builds both references for each release tag and publishes them there.

The doclet cannot yet represent some Truffle comments, so the Truffle reference reports these as warnings and leaves the affected parts out: 86 external `{@snippet file=...}` examples, one `{@link}` to a type parameter and one malformed `@see`. Source links are off: the doclet's `{path}` is relative to the package root, not to the project directory in the Graal tree.

## Select the Graal source

`graal/source.json` pins the default archive: its URL, SHA-256 and strip prefix. The `graal` module extension in `graal/extensions.bzl` fetches that archive as `@graal` and applies the overlays generated for it. The Labs JDK pin in `mx/labsjdk.json` follows `labsjdk-ce-latest` in the same tree's `common.json`.
Expand Down
157 changes: 157 additions & 0 deletions graal/apidocs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_python//python:py_test.bzl", "py_test")
load(":defs.bzl", "graal_apidocs")

# Build and test with --config=apidocs, which selects Labs JDK 25:
# bazelisk test --config=apidocs //graal/apidocs:apidocs_test
# The targets are manual so that //... on other JDKs skips them.

exports_files(["doclet.BUILD.bazel"])

# The release the references describe. Empty in development builds; the elide-dev/graal
# publish workflow sets both, e.g.
# --//graal/apidocs:version=25.6.0-elide.1 --//graal/apidocs:source_ref=<commit>
string_flag(
name = "version",
build_setting_default = "",
)

string_flag(
name = "source_ref",
build_setting_default = "",
)

_THEME = {
"brand": "Elide GraalVM",
"footer": "Built from elide-dev/graal, Elide's fork of oracle/graal. Licensed under the Universal Permissive License (UPL), Version 1.0.",
"links": {
"header": [{
"label": "Source",
"url": "https://github.com/elide-dev/graal",
}],
"footer": [
{
"label": "elide-dev/graal",
"url": "https://github.com/elide-dev/graal",
},
{
"label": "Elide",
"url": "https://elide.dev",
},
],
},
"tokens": {
"light": {"accent": "#246785"},
"dark": {"accent": "#86cce8"},
},
}

# The SDK packages that `mx sdk javadoc` publishes. Like mx, this documents only packages with a
# package-info.java: the implementation packages are left out.
_SDK_PACKAGES = [
"org.graalvm.collections",
"org.graalvm.home",
"org.graalvm.nativeimage",
"org.graalvm.options",
"org.graalvm.polyglot",
"org.graalvm.word",
]

_SDK_EXCLUDES = [
"org.graalvm.home.impl",
"org.graalvm.nativeimage.impl",
# javadoc keeps this subpackage of an excluded package, so name it too.
"org.graalvm.nativeimage.impl.clinit",
"org.graalvm.nativeimage.libgraal",
"org.graalvm.polyglot.impl",
"org.graalvm.polyglot.tck",
"org.graalvm.word.impl",
]

_SDK_PROJECTS = [
"@graal//sdk:org.graalvm.collections",
"@graal//sdk:org.graalvm.home",
"@graal//sdk:org.graalvm.nativeimage",
"@graal//sdk:org.graalvm.options",
"@graal//sdk:org.graalvm.polyglot",
"@graal//sdk:org.graalvm.word",
]

graal_apidocs(
name = "sdk",
exclude_packages = _SDK_EXCLUDES,
packages = _SDK_PACKAGES,
tags = ["manual"],
theme = _THEME | {"productName": "GraalVM SDK"},
title = "GraalVM SDK",
deps = _SDK_PROJECTS,
)

# The projects of `mx truffle javadoc` (mx_truffle.javadoc): the SDK set plus the Truffle API.
graal_apidocs(
name = "truffle",
exclude_packages = _SDK_EXCLUDES + [
"com.oracle.truffle.api.debug.impl",
"com.oracle.truffle.api.impl",
"com.oracle.truffle.api.strings.provider",
],
packages = _SDK_PACKAGES + [
"com.oracle.svm.core.annotate",
"com.oracle.truffle.api",
],
# The doclet cannot yet represent these Truffle comments, so they are warnings and the
# affected parts are left out:
# - snippet: 86 external {@snippet file=...} examples (mx resolves them with --snippet-path).
# - reference: a {@link} to a type parameter (BytecodeDescriptor).
# - malformed: a @see with a trailing period (StaticProperty).
problems = "error,malformed=warning,reference=warning,snippet=warning",
tags = ["manual"],
theme = _THEME | {"productName": "Truffle"},
title = "Truffle",
deps = _SDK_PROJECTS + [
"@graal//sdk:com.oracle.svm.core.annotate",
"@graal//truffle:com.oracle.truffle.api",
"@graal//truffle:com.oracle.truffle.api.bytecode",
"@graal//truffle:com.oracle.truffle.api.debug",
"@graal//truffle:com.oracle.truffle.api.dsl",
"@graal//truffle:com.oracle.truffle.api.exception",
"@graal//truffle:com.oracle.truffle.api.instrumentation",
"@graal//truffle:com.oracle.truffle.api.interop",
"@graal//truffle:com.oracle.truffle.api.library",
"@graal//truffle:com.oracle.truffle.api.object",
"@graal//truffle:com.oracle.truffle.api.profiles",
"@graal//truffle:com.oracle.truffle.api.staticobject",
"@graal//truffle:com.oracle.truffle.api.strings",
"@graal//truffle:com.oracle.truffle.api.utilities",
],
)

[
filegroup(
name = name + "_" + kind,
srcs = [":" + name],
output_group = "apidocs_" + kind,
tags = ["manual"],
)
for name in ("sdk", "truffle")
for kind in ("archive", "site")
]

py_test(
name = "apidocs_test",
size = "small",
srcs = ["apidocs_test.py"],
args = [
"$(rootpath :sdk_site)",
"$(rootpath :truffle_site)",
"$(rootpath :sdk_archive)",
"$(rootpath :truffle_archive)",
],
data = [
":sdk_archive",
":sdk_site",
":truffle_archive",
":truffle_site",
],
tags = ["manual"],
)
108 changes: 108 additions & 0 deletions graal/apidocs/apidocs_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
"""Checks the SDK and Truffle API references: their package sets, pages and archives."""

import json
import sys
import tarfile
import unittest
from pathlib import Path

SDK_PACKAGES = {
"org.graalvm.collections",
"org.graalvm.home",
"org.graalvm.nativeimage",
"org.graalvm.nativeimage.c",
"org.graalvm.nativeimage.c.constant",
"org.graalvm.nativeimage.c.function",
"org.graalvm.nativeimage.c.struct",
"org.graalvm.nativeimage.c.type",
"org.graalvm.nativeimage.dynamicaccess",
"org.graalvm.nativeimage.hosted",
"org.graalvm.options",
"org.graalvm.polyglot",
"org.graalvm.polyglot.io",
"org.graalvm.polyglot.management",
"org.graalvm.polyglot.proxy",
"org.graalvm.word",
}

# mx_truffle.javadoc: the SDK set, com.oracle.svm.core.annotate and the Truffle API projects.
TRUFFLE_PACKAGES = SDK_PACKAGES | {
"com.oracle.svm.core.annotate",
"com.oracle.truffle.api",
"com.oracle.truffle.api.bytecode",
"com.oracle.truffle.api.bytecode.debug",
"com.oracle.truffle.api.bytecode.serialization",
"com.oracle.truffle.api.debug",
"com.oracle.truffle.api.dsl",
"com.oracle.truffle.api.exception",
"com.oracle.truffle.api.frame",
"com.oracle.truffle.api.instrumentation",
"com.oracle.truffle.api.instrumentation.provider",
"com.oracle.truffle.api.interop",
"com.oracle.truffle.api.io",
"com.oracle.truffle.api.library",
"com.oracle.truffle.api.library.provider",
"com.oracle.truffle.api.memory",
"com.oracle.truffle.api.nodes",
"com.oracle.truffle.api.object",
"com.oracle.truffle.api.profiles",
"com.oracle.truffle.api.provider",
"com.oracle.truffle.api.source",
"com.oracle.truffle.api.staticobject",
"com.oracle.truffle.api.strings",
"com.oracle.truffle.api.utilities",
}

SDK_SITE, TRUFFLE_SITE, SDK_ARCHIVE, TRUFFLE_ARCHIVE = (Path(arg) for arg in sys.argv[1:5])
del sys.argv[1:5]


class ApiDocsTest(unittest.TestCase):
def check(self, site, archive, title, packages, pages):
listed = set(site.joinpath("element-list").read_text(encoding="utf-8").split())
self.assertEqual(packages, listed)

model = json.loads(site.joinpath("api.json").read_text(encoding="utf-8"))
self.assertEqual(title, model["module"]["name"])
self.assertEqual(packages, {pkg["name"] for pkg in model["packages"]})

for page in pages:
self.assertTrue(site.joinpath(page).is_file(), page)
# JDK types link to the JDK 25 reference through the checked-in element-list.
polyglot = site.joinpath("org/graalvm/polyglot/Context.html").read_text(encoding="utf-8")
self.assertIn("https://docs.oracle.com/en/java/javase/25/docs/api/java.base/", polyglot)

with tarfile.open(archive) as tar:
members = {m.name.removeprefix("./") for m in tar.getmembers() if m.isfile()}
files = {str(p.relative_to(site)) for p in site.rglob("*") if p.is_file()}
self.assertEqual(files, members)

def test_sdk(self):
self.check(
SDK_SITE,
SDK_ARCHIVE,
"GraalVM SDK",
SDK_PACKAGES,
["index.html", "org/graalvm/polyglot/Value.html", "org/graalvm/word/WordBase.html"],
)
# The implementation packages are left out, as `mx sdk javadoc` does.
self.assertFalse(SDK_SITE.joinpath("org/graalvm/polyglot/impl").exists())

def test_truffle(self):
self.check(
TRUFFLE_SITE,
TRUFFLE_ARCHIVE,
"Truffle",
TRUFFLE_PACKAGES,
[
"index.html",
"com/oracle/truffle/api/TruffleLanguage.html",
"com/oracle/truffle/api/strings/TruffleString.html",
"com/oracle/truffle/api/dsl/Specialization.html",
],
)
self.assertFalse(TRUFFLE_SITE.joinpath("com/oracle/truffle/api/impl").exists())


if __name__ == "__main__":
unittest.main()
Loading
Loading