Skip to content

Commit

Permalink
feat: import toolchains to use for copy actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Nov 17, 2023
1 parent a39ae94 commit 5e3082e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ EOF

awk 'f;/--SNIP--/{f=1}' e2e/workspace/WORKSPACE
echo "\`\`\`"

cat << EOF
To use rules_ts with bazel-lib 2.x, you must additionally register the coreutils toolchain.
\`\`\`starlark
load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains")
register_coreutils_toolchains()
\`\`\`
EOF
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "aspect_rules_js", version = "1.29.2")
bazel_dep(name = "aspect_bazel_lib", version = "1.29.2")
bazel_dep(name = "aspect_rules_js", version = "1.34.0")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")

# Similar to rules_python/MODULE.bazel, see https:/bazelbuild/rules_python/pull/832
# These are loaded only when using ts_proto_library
Expand Down
6 changes: 4 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_coreutils_toolchains")

aspect_bazel_lib_dependencies(override_local_config_platform = True)
aspect_bazel_lib_dependencies()

register_coreutils_toolchains()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

Expand Down
2 changes: 1 addition & 1 deletion e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
)

# repeated here only because we use the platforms definitions for rbe
bazel_dep(name = "aspect_rules_js", version = "1.29.2", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "1.34.0", dev_dependency = True)
bazel_dep(name = "aspect_rules_ts", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "rules_proto", version = "5.3.0-21.7", dev_dependency = True)
Expand Down
2 changes: 2 additions & 0 deletions ts/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ The most commonly used is the [ts_project](#ts_project) macro which accepts Type
inputs and produces JavaScript or declaration (.d.ts) outputs.
"""

load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS")
load("@aspect_bazel_lib//lib:utils.bzl", "to_label")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@bazel_skylib//lib:partial.bzl", "partial")
Expand All @@ -21,6 +22,7 @@ validate_options = rule(
See the documentation of [`ts_project`](#ts_project) for more information.""",
implementation = validate_lib.implementation,
attrs = validate_lib.attrs,
toolchains = COPY_FILE_TO_BIN_TOOLCHAINS,
)

ts_project_rule = _ts_project
Expand Down
3 changes: 2 additions & 1 deletion ts/private/ts_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"tsconfig.json files using extends"

load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_file_to_bin_action", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS", "copy_file_to_bin_action", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:paths.bzl", "relative_file")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
load("@aspect_rules_js//js:providers.bzl", "js_info")
Expand Down Expand Up @@ -111,6 +111,7 @@ of a `ts_library` or `ts_project` rule. However, if your `tsconfig.json` uses th
feature from TypeScript, then the Bazel implementation needs to know about that
extended configuration file as well, to pass them both to the TypeScript compiler.
""",
toolchains = COPY_FILE_TO_BIN_TOOLCHAINS,
)

def _filter_input_files(files, allow_js, resolve_json_module):
Expand Down
3 changes: 2 additions & 1 deletion ts/private/ts_project.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"ts_project rule"

load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_file_to_bin_action", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS", "copy_file_to_bin_action", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:paths.bzl", "to_output_relative_path")
load("@aspect_bazel_lib//lib:platform_utils.bzl", "platform_utils")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
Expand Down Expand Up @@ -325,4 +325,5 @@ ts_project = rule(
""",
implementation = lib.implementation,
attrs = lib.attrs,
toolchains = COPY_FILE_TO_BIN_TOOLCHAINS,
)
2 changes: 2 additions & 0 deletions ts/private/ts_proto_library.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"Private implementation details for ts_proto_library"

load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info")
load("@rules_proto//proto:defs.bzl", "ProtoInfo", "proto_common")
Expand Down Expand Up @@ -118,4 +119,5 @@ ts_proto_library = rule(
cfg = "exec",
),
},
toolchains = COPY_FILE_TO_BIN_TOOLCHAINS,
)
13 changes: 7 additions & 6 deletions ts/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def http_archive(**kwargs):
# ours took precedence. Such breakages are challenging for users, so any
# changes in this function should be marked as BREAKING in the commit message
# and released only in semver majors.
# buildifier: disable=function-docstring
def rules_ts_bazel_dependencies():
http_archive(
name = "bazel_skylib",
Expand All @@ -29,16 +30,16 @@ def rules_ts_bazel_dependencies():

http_archive(
name = "aspect_bazel_lib",
sha256 = "ee95bbc80f9ca219b93a8cc49fa19a2d4aa8649ddc9024f46abcdd33935753ca",
strip_prefix = "bazel-lib-1.29.2",
url = "https:/aspect-build/bazel-lib/releases/download/v1.29.2/bazel-lib-v1.29.2.tar.gz",
sha256 = "262e3d6693cdc16dd43880785cdae13c64e6a3f63f75b1993c716295093d117f",
strip_prefix = "bazel-lib-1.38.1",
url = "https:/aspect-build/bazel-lib/releases/download/v1.38.1/bazel-lib-v1.38.1.tar.gz",
)

http_archive(
name = "aspect_rules_js",
sha256 = "bdbd6df52fc7963f55281fe0a140e21de8ec587ab711a8a2fff0715b6710a4f8",
strip_prefix = "rules_js-1.32.0",
url = "https:/aspect-build/rules_js/releases/download/v1.32.0/rules_js-v1.32.0.tar.gz",
sha256 = "d9ceb89e97bb5ad53b278148e01a77a3e9100db272ce4ebdcd59889d26b9076e",
strip_prefix = "rules_js-1.34.0",
url = "https:/aspect-build/rules_js/releases/download/v1.34.0/rules_js-v1.34.0.tar.gz",
)

http_archive(
Expand Down

0 comments on commit 5e3082e

Please sign in to comment.