Skip to content

Commit

Permalink
Support a serialization_configuration option for native_image (#466)
Browse files Browse the repository at this point in the history
feat: add `serialization_configuration` option for `native_image`

Fixes #465

Signed-off-by: Chris Gray <[email protected]>
  • Loading branch information
chrismgrayftsinc authored Sep 29, 2024
1 parent 00b337d commit 8d49aab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions graal/graal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def native_image(
include_resources = None,
reflection_configuration = None,
jni_configuration = None,
serialization_configuration = None,
initialize_at_build_time = [],
initialize_at_run_time = [],
native_features = [],
Expand Down Expand Up @@ -79,6 +80,7 @@ def native_image(
The special string `%target%`, if present, is replaced with `name`.
include_resources: Glob to pass to `IncludeResources`. No default; optional.
reflection_configuration: Reflection configuration file. No default; optional.
serialization_configuration: Serialization configuration file. No default; optional.
jni_configuration: JNI configuration file. No default; optional.
initialize_at_build_time: Classes or patterns to pass to `--initialize-at-build-time`. No default; optional.
initialize_at_run_time: Classes or patterns to pass to `--initialize-at-run-time`. No default; optional.
Expand Down Expand Up @@ -108,6 +110,7 @@ def native_image(
include_resources = include_resources,
reflection_configuration = reflection_configuration,
jni_configuration = jni_configuration,
serialization_configuration = serialization_configuration,
initialize_at_build_time = initialize_at_build_time,
initialize_at_run_time = initialize_at_run_time,
native_features = native_features,
Expand Down Expand Up @@ -136,6 +139,7 @@ def graal_binary(
include_resources = None,
reflection_configuration = None,
jni_configuration = None,
serialization_configuration = None,
initialize_at_build_time = [],
initialize_at_run_time = [],
native_features = [],
Expand Down Expand Up @@ -163,6 +167,7 @@ def graal_binary(
The special string `%target%`, if present, is replaced with `name`.
include_resources: Glob to pass to `IncludeResources`. No default; optional.
reflection_configuration: Reflection configuration file. No default; optional.
serialization_configuration: Serialization configuration file. No default; optional.
jni_configuration: JNI configuration file. No default; optional.
initialize_at_build_time: Classes or patterns to pass to `--initialize-at-build-time`. No default; optional.
initialize_at_run_time: Classes or patterns to pass to `--initialize-at-run-time`. No default; optional.
Expand Down Expand Up @@ -192,6 +197,7 @@ def graal_binary(
include_resources = include_resources,
reflection_configuration = reflection_configuration,
jni_configuration = jni_configuration,
serialization_configuration = serialization_configuration,
initialize_at_build_time = initialize_at_build_time,
initialize_at_run_time = initialize_at_run_time,
native_features = native_features,
Expand Down
4 changes: 4 additions & 0 deletions internal/native_image/builder.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def _configure_reflection(ctx, args, direct_inputs):
direct_inputs.append(ctx.file.jni_configuration)
args.add("-H:+JNI")

if ctx.attr.serialization_configuration != None:
args.add(ctx.file.serialization_configuration, format = "-H:SerializationConfigurationFiles=%s")
direct_inputs.append(ctx.file.serialization_configuration)

def _configure_native_compiler(ctx, args, c_compiler_path, gvm_toolchain):
"""Configure native compiler and linker flags for a Native Image build.
Expand Down
4 changes: 4 additions & 0 deletions internal/native_image/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ _NATIVE_IMAGE_ATTRS = {
mandatory = False,
allow_single_file = True,
),
"serialization_configuration": attr.label(
mandatory = False,
allow_single_file = True,
),
"debug": attr.bool(
mandatory = False,
default = False,
Expand Down

0 comments on commit 8d49aab

Please sign in to comment.