Skip to content

Commit

Permalink
feat: support for neverlink
Browse files Browse the repository at this point in the history
- add transitive inputs for compile-time jars
- mark applicable dependencies with `neverlink`

Relates-To: #243
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jan 14, 2024
1 parent bb3ae0a commit b61399c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
36 changes: 25 additions & 11 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,40 @@ bazel_dep(
# rules_jvm_external
################################################################################

MAVEN_ARTIFACTS = [
"org.graalvm.nativeimage:svm:%s" % GRAALVM_SDK_VERSION,
"org.graalvm.sdk:graal-sdk:%s" % GRAALVM_SDK_VERSION,
"org.graalvm.polyglot:polyglot:%s" % GRAALVM_SDK_VERSION,
]
maven = use_extension(
"@rules_jvm_external//:extensions.bzl",
"maven",
dev_dependency = True,
)
maven.artifact(
name = "maven_gvm",
group = "org.graalvm.nativeimage",
artifact= "svm",
version = GRAALVM_SDK_VERSION,
neverlink = True,
)
maven.artifact(
name = "maven_gvm",
group = "org.graalvm.sdk",
artifact= "graal_sdk",
version = GRAALVM_SDK_VERSION,
neverlink = True,
)
maven.artifact(
name = "maven_gvm",
group = "org.graalvm.polyglot",
artifact= "polyglot",
version = GRAALVM_SDK_VERSION,
)

MAVEN_REPOSITORIES = [
"https://maven.pkg.st",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
]

maven = use_extension(
"@rules_jvm_external//:extensions.bzl",
"maven",
dev_dependency = True,
)
maven.install(
name = "maven_gvm",
artifacts = MAVEN_ARTIFACTS,
lock_file = "//:maven_install.json",
repositories = MAVEN_REPOSITORIES,
)
Expand Down
9 changes: 9 additions & 0 deletions graalvm/artifacts/maven.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
"Defines Maven helpers and coordinates for GraalVM artifacts."

load("@rules_jvm_external//:specs.bzl", "maven")

# buildifier: disable=name-conventions
_MavenArtifacts = struct(
SVM = struct(
artifact = "svm",
group = "org.graalvm.nativeimage",
neverlink = True,
),
SDK = struct(
artifact = "graal-sdk",
group = "org.graalvm.sdk",
neverlink = True,
),
POLYGLOT = struct(
artifact = "polyglot",
Expand Down Expand Up @@ -111,6 +119,7 @@ def _graalvm_maven_artifact(maven, artifact, version):
artifact = artifact.artifact,
group = artifact.group,
version = version,
neverlink = artifact.get("neverlink", False),
)

# buildifier: disable=name-conventions
Expand Down
4 changes: 2 additions & 2 deletions internal/maven.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

load(
"//internal:config.bzl",
"GRAALVM_VERSION",
_GRAALVM_VERSION = "GRAALVM_VERSION",
)

def graalvm(artifact, repository = "@maven", version = None, group = None):
Expand All @@ -25,7 +25,7 @@ def graalvm(artifact, repository = "@maven", version = None, group = None):

group = (group or artifact.split(":")[0]).replace(".", "_")
name = (group and artifact or artifact.split(":")[1]).replace(".", "_")
resolved_version = version or GRAALVM_VERSION
resolved_version = version or _GRAALVM_VERSION

if resolved_version:
formatted_version = resolved_version.replace(".", "_")
Expand Down
6 changes: 5 additions & 1 deletion internal/native_image/classic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ def _graal_binary_classic_implementation(ctx):
dep[JavaInfo].transitive_runtime_jars
for dep in ctx.attr.deps
])
classpath_neverlink_depset = depset(transitive = [
dep[JavaInfo].transitive_compile_time_jars
for dep in ctx.attr.deps
])

direct_inputs = []
transitive_inputs = [classpath_depset]
transitive_inputs = [classpath_depset, classpath_neverlink_depset]

if graal_attr != None:
# otherwise, use the legacy code path. the `graal` value is used in the run
Expand Down

0 comments on commit b61399c

Please sign in to comment.