Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a serialization_configuration option for native_image #466

Merged
merged 1 commit into from
Sep 29, 2024
Merged
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 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
Loading