-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use bazel's native json decode method #659
Conversation
e9681e6
to
3e10de6
Compare
This means that `rules_jvm_external` is only compatible with Bazel 4 and later. That shipped on 2021-01-21, and so should be widely adopted already. Older versions of this ruleset will continue to work for repos using older versions of Bazel so it's not removing any existing functionality, and the new Bazel 5 release should have already shipped. The main reason for doing this is that the native json decoding is significantly faster than the starlark-based one. The following options were explored as alternatives: 1. Making the `json_parse` method check the bazel version and optionally use the `json` module if it was present. This doesn't work because of #12735 2. Create a `json` repository rule that creates a repo that exposes a `json.bzl` file that delegates to the native `json` module if present, or the starlark one if not (as determined by looking at the major version number of bazel). This doesn't work because `maven_install` is used by RJE's own `repositories.bzl` file, so there's no chance to load the repository rule before it's needed. Links: 12735: bazelbuild/bazel#12735
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! some nits.
coursier.bzl
Outdated
@@ -132,7 +122,9 @@ def _execute(repository_ctx, cmd, timeout = 600, environment = {}, progress_mess | |||
# The representation of a Windows path when read from the parsed Coursier JSON | |||
# is delimited by 4 back slashes. Replace them with 1 forward slash. | |||
def _normalize_to_unix_path(path): | |||
return path.replace("\\\\", "/") | |||
if path == None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? Seems error prone to have None
paths being passed around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just being paranoid. I'll back it out.
coursier.bzl
Outdated
@@ -227,7 +219,7 @@ def _compute_dependency_tree_signature(artifacts): | |||
if artifact["file"] != None: | |||
artifact_group.extend([ | |||
artifact["sha256"], | |||
artifact["file"], | |||
artifact["file"].replace("\\", "/"), # Make sure we represent files in a stable way cross-platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use _normalize_to_unix_path
? here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This means that
rules_jvm_external
is only compatible withBazel 4 and later. That shipped on 2021-01-21, and so should
be widely adopted already. Older versions of this ruleset
will continue to work for repos using older versions of Bazel
so it's not removing any existing functionality, and the new
Bazel 5 release should have already shipped.
The main reason for doing this is that the native json
decoding is significantly faster than the starlark-based one.
The following options were explored as alternatives:
json_parse
method check the bazel version andoptionally use the
json
module if it was present. Thisdoesn't work because of
Starlark: provide a way to probe builtins availability bazel#12735
json
repository rule that creates a repo thatexposes a
json.bzl
file that delegates to the nativejson
module if present, or the starlark one if not(as determined by looking at the major version number of
bazel). This doesn't work because
maven_install
is usedby RJE's own
repositories.bzl
file, so there's no chanceto load the repository rule before it's needed.