Skip to content

Commit

Permalink
Add java.java_info_constructor_module_flags (#48)
Browse files Browse the repository at this point in the history
Add a flag to examine support for `add_exports` and `add_opens` in
Bazel.
  • Loading branch information
timothyg-stripe authored Mar 7, 2024
1 parent 4b4f65e commit 2db269a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion features.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Defines all the features this module supports detecting."""

load("@bazel_features_globals//:globals.bzl", "globals")
load("//private:util.bzl", "ge", "lt")
load("//private:util.bzl", "ge", "ge_same_major", "lt")

_cc = struct(
# Whether @bazel_tools//tools/cpp:optional_current_cc_toolchain and the `mandatory` parameter
Expand Down Expand Up @@ -49,6 +49,13 @@ _flags = struct(
),
)

_java = struct(
# Whether the JavaInfo constructor has add_exports/add_opens named parameters. Added in
# https://github.com/bazelbuild/bazel/commit/d2783a3c3d1b899beb674e029bfea3519062e8be (HEAD)
# https://github.com/bazelbuild/bazel/commit/e2249f91ff84541565d8ba841592a0a8a43fcb66 (7.0.0)
java_info_constructor_module_flags = ge_same_major("7.0.0") or ge("8.0.0-pre.20240101.1"),
)

_rules = struct(
# Whether the computed_substitutions parameter of ctx.actions.expand_template and ctx.actions.template_dict are stable.
# https://github.com/bazelbuild/bazel/commit/61c31d255b6ba65c372253f65043d6ea3f10e1f9
Expand All @@ -74,6 +81,7 @@ bazel_features = struct(
external_deps = _external_deps,
flags = _flags,
globals = globals,
java = _java,
rules = _rules,
toolchains = _toolchains,
)
4 changes: 4 additions & 0 deletions private/util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ def ne(v):
def ge(v):
return BAZEL_VERSION >= parse_version(v)

def ge_same_major(v):
pv = parse_version(v)
return BAZEL_VERSION >= pv and BAZEL_VERSION[0] == pv[0]

def gt(v):
return BAZEL_VERSION > parse_version(v)

0 comments on commit 2db269a

Please sign in to comment.