From b98e9f1f16ea91f8f463c3811237559c704d5a5f Mon Sep 17 00:00:00 2001 From: loganasherjones Date: Mon, 19 Feb 2024 14:12:04 -0500 Subject: [PATCH] feat: add proxy config flag Signed-off-by: loganasherjones --- graalvm/nativeimage/rules.bzl | 3 +++ internal/native_image/builder.bzl | 16 ++++++++++++++++ internal/native_image/common.bzl | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/graalvm/nativeimage/rules.bzl b/graalvm/nativeimage/rules.bzl index 57c528c..9510b74 100644 --- a/graalvm/nativeimage/rules.bzl +++ b/graalvm/nativeimage/rules.bzl @@ -83,6 +83,7 @@ def native_image( native_image_tool = None, # uses toolchains by default native_image_settings = [_DEFAULT_NATIVE_IMAGE_SETTINGS], resource_configuration = None, + proxy_configuration = None, profiles = [], **kwargs): """Generates and compiles a GraalVM native image from a Java library target. @@ -117,6 +118,7 @@ def native_image( native_image_settings: Suite(s) of Native Image build settings to use. profiles: Profiles to use for profile-guided optimization (PGO) and obtained from a native image compiled with `--pgo-instrument`. resource_configuration: Resource configuration file. No default; optional. + proxy_configuration: Proxy configuration file. No default; optional. **kwargs: Extra keyword arguments are passed to the underlying `native_image` rule. """ @@ -144,5 +146,6 @@ def native_image( native_image_settings = native_image_settings, profiles = profiles, resource_configuration = resource_configuration, + proxy_configuration = proxy_configuration, **kwargs ) diff --git a/internal/native_image/builder.bzl b/internal/native_image/builder.bzl index 4a0cdf5..69e28c0 100644 --- a/internal/native_image/builder.bzl +++ b/internal/native_image/builder.bzl @@ -67,6 +67,19 @@ def _configure_optimization_mode(ctx, args): format = "-O%s", ) +def _configure_proxy(ctx, args, direct_inputs): + """Configure proxy settings for a Native Image build. + + Args: + ctx: Context of the Native Image rule implementation. + args: Args builder for the Native Image build. + direct_inputs: Direct Native Image build action inputs. + + """ + if ctx.attr.proxy_configuration != None: + args.add(ctx.file.proxy_configuration, format = "-H:DynamicProxyConfigurationFiles=%s") + direct_inputs.append(ctx.file.proxy_configuration) + def _configure_resources(ctx, args, direct_inputs): """Configure resource settings for a Native Image build. @@ -221,6 +234,9 @@ def assemble_native_build_options( # configure resources _configure_resources(ctx, args, direct_inputs) + # configure proxy + _configure_proxy(ctx, args, direct_inputs) + # if a static build is being performed against hermetic zlib, configure it if ctx.attr.static_zlib != None: _configure_static_zlib_compile( diff --git a/internal/native_image/common.bzl b/internal/native_image/common.bzl index 67236fa..c486830 100644 --- a/internal/native_image/common.bzl +++ b/internal/native_image/common.bzl @@ -117,6 +117,10 @@ _NATIVE_IMAGE_ATTRS = { mandatory = False, allow_single_file = True, ), + "proxy_configuration": attr.label( + mandatory = False, + allow_single_file = True, + ), "_cc_toolchain": attr.label( default = Label(_BAZEL_CURRENT_CPP_TOOLCHAIN), ),