Skip to content

Commit

Permalink
fix: provide GRAALVM_HOME to native-image builds
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jan 5, 2024
1 parent 6616c29 commit 8554bf7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/native_image/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _graal_binary_implementation(ctx):
# add toolchain files to transitive inputs
transitive_inputs.append(gvm_toolchain.gvm_files[DefaultInfo].files)
transitive_inputs.append(gvm_toolchain.includes[DefaultInfo].files)
graalvm_home = graal.dirname

# if we're using an explicit tool, add it to the direct inputs
if graal:
Expand All @@ -94,6 +95,7 @@ def _graal_binary_implementation(ctx):
ctx,
transitive_inputs,
is_windows = is_windows,
graalvm_home = graalvm_home,
)

# shared libraries on macos are produced with an extension of `dylib`.
Expand Down
5 changes: 4 additions & 1 deletion internal/native_image/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load(
"find_cpp_toolchain",
)

def resolve_cc_toolchain(ctx, transitive_inputs, *, is_windows):
def resolve_cc_toolchain(ctx, transitive_inputs, *, is_windows, graalvm_home):
"""Build a context struct for accessing the native C toolchain.
Available struct properties:
Expand All @@ -32,6 +32,7 @@ def resolve_cc_toolchain(ctx, transitive_inputs, *, is_windows):
ctx: Context from the rule implementation.
transitive_inputs: List of transitive inputs (mutated).
is_windows: Whether the target (and hence execution) platform is Windows.
graalvm_home: Parent directory which should be used as `GRAALVM_HOME`.
Returns:
Resulting struct; see method documentation for parameters."""
Expand Down Expand Up @@ -118,9 +119,11 @@ def resolve_cc_toolchain(ctx, transitive_inputs, *, is_windows):

# seal paths with hack above
env["PATH"] = ctx.configuration.host_path_separator.join(paths)
env["GRAALVM_HOME"] = graalvm_home

return struct(
c_compiler_path = c_compiler_path,
env = env,
execution_requirements = execution_requirements,
graalvm_home = graalvm_home,
)

0 comments on commit 8554bf7

Please sign in to comment.