Skip to content

Commit 1f5e571

Browse files
authored
chore: allow DirectoryPathInfo to vary bazel_lib vs aspect_bazel_lib (#2421)
During the migration users will have a mix of both. For example rules_ts uses this provider, and can't switch to bazel_lib unless there's a release of its dependencies that permits either.
1 parent 8d24f3f commit 1f5e571

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

MODULE.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ module(
88

99
# Lower-bounds (minimum) versions for direct runtime dependencies.
1010
# Do not bump these unless rules_js requires a newer version to function.
11-
bazel_dep(name = "aspect_bazel_lib", version = "2.16.0")
11+
bazel_dep(name = "aspect_bazel_lib", version = "2.16.0") # TODO(alexeagle): remove
1212
bazel_dep(name = "aspect_tools_telemetry", version = "0.2.8")
1313
bazel_dep(name = "bazel_features", version = "1.9.0")
14+
bazel_dep(name = "bazel_lib", version = "3.0.0")
1415
bazel_dep(name = "bazel_skylib", version = "1.5.0")
1516
bazel_dep(name = "platforms", version = "0.0.5")
1617
bazel_dep(name = "rules_nodejs", version = "6.3.0")

docs/js_binary.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bzl_library(
3535
"@aspect_bazel_lib//lib:expand_make_vars",
3636
"@aspect_bazel_lib//lib:paths",
3737
"@aspect_bazel_lib//lib:windows_utils",
38+
"@bazel_lib//lib:directory_path",
3839
"@bazel_skylib//lib:dicts",
3940
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []),
4041
)

js/private/js_binary.bzl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ js_binary(
1616
"""
1717

1818
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS")
19-
load("@aspect_bazel_lib//lib:directory_path.bzl", "DirectoryPathInfo")
19+
load("@aspect_bazel_lib//lib:directory_path.bzl", _LegacyDirectoryPathInfo = "DirectoryPathInfo")
2020
load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations", "expand_variables")
2121
load("@aspect_bazel_lib//lib:windows_utils.bzl", "create_windows_native_launcher_script")
22+
load("@bazel_lib//lib:directory_path.bzl", "DirectoryPathInfo")
2223
load(":bash.bzl", "BASH_INITIALIZE_RUNFILES")
2324
load(":js_helpers.bzl", "LOG_LEVELS", "envs_for_log_level", "gather_runfiles")
2425

@@ -107,10 +108,10 @@ _ATTRS = {
107108
This is the module referenced by the `require.main` property in the runtime.
108109
109110
This must be a target that provides a single file or a `DirectoryPathInfo`
110-
from `@aspect_bazel_lib//lib::directory_path.bzl`.
111+
from `@bazel_lib//lib::directory_path.bzl`.
111112
112113
See https://github.com/bazel-contrib/bazel-lib/blob/main/docs/directory_path.md
113-
for more info on creating a target that provides a `DirectoryPathInfo`.
114+
for more info on creating a target that provides a `Info`.
114115
""",
115116
mandatory = True,
116117
),
@@ -507,11 +508,12 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [],
507508
else:
508509
nodeinfo = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo
509510

510-
if DirectoryPathInfo in ctx.attr.entry_point:
511-
entry_point = ctx.attr.entry_point[DirectoryPathInfo].directory
511+
directory_path_provider = DirectoryPathInfo if DirectoryPathInfo in ctx.attr.entry_point else _LegacyDirectoryPathInfo
512+
if directory_path_provider in ctx.attr.entry_point:
513+
entry_point = ctx.attr.entry_point[directory_path_provider].directory
512514
entry_point_path = "/".join([
513-
ctx.attr.entry_point[DirectoryPathInfo].directory.short_path,
514-
ctx.attr.entry_point[DirectoryPathInfo].path,
515+
ctx.attr.entry_point[directory_path_provider].directory.short_path,
516+
ctx.attr.entry_point[directory_path_provider].path,
515517
])
516518
else:
517519
if len(ctx.files.entry_point) != 1:

js/repositories.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ def rules_js_dependencies():
3232
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v2.16.0/bazel-lib-v2.16.0.tar.gz",
3333
)
3434

35+
http_archive(
36+
name = "bazel_lib",
37+
sha256 = "6fd3b1e1a38ca744f9664be4627ced80895c7d2ee353891c172f1ab61309c933",
38+
strip_prefix = "bazel-lib-3.0.0",
39+
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.0/bazel-lib-v3.0.0.tar.gz",
40+
)
41+
3542
http_archive(
3643
name = "aspect_tools_telemetry_report",
3744
sha256 = "fea3bc2f9b7896ab222756c27147b1f1b8f489df8114e03d252ffff475f8bce6",

0 commit comments

Comments
 (0)