Skip to content

Commit

Permalink
feat: add proxy config flag
Browse files Browse the repository at this point in the history
Signed-off-by: loganasherjones <loganasherjones@gmail.com>
  • Loading branch information
loganasherjones authored and sgammon committed Feb 19, 2024
1 parent e201dc6 commit d6bde1f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graalvm/nativeimage/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
"""

Expand Down Expand Up @@ -144,5 +146,6 @@ def native_image(
native_image_settings = native_image_settings,
profiles = profiles,
resource_configuration = resource_configuration,
proxy_configuration = proxy_configuration,
**kwargs
)
16 changes: 16 additions & 0 deletions internal/native_image/builder.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
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 @@ -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),
),
Expand Down

0 comments on commit d6bde1f

Please sign in to comment.